akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, q;
	cin >> n >> q;
    vector<set<int>> tr(n); 
    for(int i=1; i<n; ++i){
        int a, b;
        cin >> a >> b;
        --a; --b;
        tr[a].insert(b);
        tr[b].insert(a);
    }

    vector<int> v(n,0);
    for(int i=0; i<q; ++i){
        int p, x;
        cin >> p >> x;
        v[--p] += x;
    }
    stack<int> s;
    s.push(0);
    while(!s.empty()){
        int z=s.top();
        s.pop();
        for(int i : tr[z]){
            v[i] += v[z];
            s.push(i);
            tr[i].erase(z);
        }
    }

	for(int i : v) cout << i << endl;
}

Measured memory_bytes: 31644
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod;
    } 
    return res%mod; 
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    cin>>n;
    int a[n];
    inp_arr(a,n);
    a[0] -= 1;
    int f = 0;
    for(int i=1;i<n;++i) {
        if(a[i] - 1 >= a[i-1]) {
            a[i] -= 1;
        }
        else if(a[i] >= a[i-1]) {
            continue;
        }
        else {
            f = 1;
            break;
        }
    }
    if(f) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int a,b;cin>>a>>b;
    cout<<((a-b<=0)?a:a-1)<<endl;
}

Measured memory_bytes: 3560
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 5e3+5;
int n;

int main(){
    cin >> n;
    int cnt = 0;
    while(n){
        if(n % 10 == 7) cnt++;
        n /= 10;
    }
    puts(cnt ? "Yes" : "No");
}


Measured memory_bytes: 3592
H, W = map(int,input().split())
A = [input() for i in range(H)]
i = 0
for a in range(H):
    if '#' not in A[i]:
        del A[i]
        H -= 1
        i -= 1
    i += 1
#ここまでで行消去
i = 0
for a in range(W):
    f = True
    for j in range(H):
        if A[j][i] == '#':
            f = False
            break
    if f:
        for j in range(H):
            A[j] = A[j][:i] + A[j][i+1:]
        W -= 1
        i -= 1
    i += 1
for a in A:
    print(a)

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int v[3];
    v[0]=a;v[1]=b;v[2]=c;
    sort(v,v+3);
    cout<<v[2]-v[1]+v[1]-v[0];

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

struct Node {
	vector<ll> use;
	ll sum, cost;
};
bool operator>(const Node& n1, const Node& n2) {
	ll c1 = n1.use[0] + n1.use[1];
	ll c2 = n2.use[0] + n2.use[1];
	if (c1 == c2) {
		if (n1.cost == n2.cost) {
			return n1.use > n2.use;
		}
		return n1.cost > n2.cost;
	}
	return c1 > c2;
}
bool operator<(const Node& n1, const Node& n2) {
	return n2 > n1;
}

const int offset = 30000;
ll dist[offset+50000+1];
Node dijkstra(int A, int B, int D) {
	vector<int> to = {A, B};
	fill(dist, dist+offset+50000+1, linf); dist[0] = {0};
	priority_queue<Node, vector<Node>, greater<Node> > Q; Q.push({{0, 0}, 0, 0});
	Node res = {{inf, inf}, inf, inf};
	while ( !Q.empty() ) {
		Node node = Q.top(); Q.pop();
		vector<ll> use = node.use;
		ll sum = node.sum, cost = node.cost;
		if (cost > dist[offset+sum]) continue;
//		cout << sum << " " << cost << endl;
		if (sum == D && node < res) {
			res = node;
		}
		REP(i, 2) {
			ll nsum = sum+to[i], ncost = cost+abs(to[i]);
			vector<ll> nuse = use; nuse[i]++;
			if (0 <= offset+nsum && offset+nsum <= offset+D && ncost < dist[offset+nsum]) {
				dist[offset+nsum] = ncost;
				Q.push({nuse, nsum, ncost});
			}
		}
	}
	return res;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int a, b, d;
	while (cin >> a >> b >> d, a || b || d) {
		Node ans = dijkstra(a, b, d);
		ans = min(ans, dijkstra(-a, b, d));
		ans = min(ans, dijkstra(a, -b, d));
		cout << ans.use[0] << " " << ans.use[1] << endl;
	}
}

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

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if (x - r < 0 || W < x + r) {
    cout << "No" << endl;
  } else if (y - r < 0 || H < y + r) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3108
n, a, b = map(int, input().split())
s = input()

for e in s:
    ans = "No"

    if e == "a":
        if a + b > 0:
            ans = "Yes"
            a -= 1

    elif e == "b":
        if a + b > 0 and b > 0:
            ans = "Yes"
            b -= 1

    print(ans)


Measured memory_bytes: 4016
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int64> x(N), y(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  map<pair<int64, int64>, int> mp;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      pair<int64, int64> p = make_pair(x[i] - x[j], y[i] - y[j]);
      if (mp.count(p))
        mp[p]++;
      else
        mp[p] = 1;
    }
  }
  debug(mp);
  int max_pair_num = 0;
  for (auto v : mp) {
    max_pair_num = max(max_pair_num, v.second);
  }
  cout << N - max_pair_num << endl;
  return 0;
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

int main()
{
    boost;
    ll tt = 1, n, m, k = 0, i, j;
    ll q, l = 0, r = 0, x, y, z, h, a, b, c, d;

    bool poss = true;
    string s;
    ll ans = 0;

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;
        vi a(n);

        loop(z, a) cin >> z;

        map<ll, int> mp;
        for(i = 0; i < n; i++){
            mp[a[i] + i + 1]++;
        }

        for(i = 0; i < n; i++){
            ans += mp[i - a[i] + 1];
        }
        
        cout << ans << nl;
    }   
    return 0;
}

Measured memory_bytes: 27472
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  ll n,k;
  cin>>n>>k;
  ll a=n%k;
  ll b=k-(n%k);
  ll ans;
  ans=min(a,b);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    vector<string> v = {"maerd", "remaerd", "esare", "resare"};
    int p = 0;
    while (p < S.size()) {
        bool update = false;
        REP (i, 4) {
            if (S.substr(p, v[i].size()) == v[i]) {
                p += v[i].size();
                update = true;
                break;
            }
        }
        if (!update) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int memo[101][101][3][3];
int dfs(int x,int y,int bef1,int bef2){
  int ret = 0;
  if(x == 1 && y == 1) return 1;
  if(memo[x][y][bef1][bef2] != -1) return memo[x][y][bef1][bef2];
  if(x-1 >= 1){
    if(bef1 == bef2 || bef1 != 1) ret = (ret + dfs(x-1,y,bef2,1))%100000;
  }
  if(y-1 >= 1){
    if(bef1 == bef2 || bef1 != 2) ret = (ret + dfs(x,y-1,bef2,2))%100000;
  }
  return memo[x][y][bef1][bef2] = ret;
}
int main(){
  int w,h;
  while(scanf("%d %d",&w,&h),w!=0&&h!=0){
    for(int i=1;i<101;i++){
      for(int j=1;j<101;j++){
	for(int k=0;k<3;k++){
	  for(int l=0;l<3;l++) memo[i][j][k][l] = -1;
	}
      }
    }
    printf("%d\n",dfs(w,h,0,0));
  }
  return (0);
}

Measured memory_bytes: 3520
n,m = map(int,raw_input().split())
A = [[0 for i in range(m)] for i in range(n)]
B = [ 0 for i in range(m)]


for i in range(n):
    A[i] = map(int,raw_input().split())
for i in range(m):
    B[i] = input()

for i in range(n):
    sum = 0
    for j in range(m):
        sum += A[i][j] * B[j] 
    print sum

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {

    int n;
    cin>>n;

    vector<int>cnt(26),cntzero(26),cntmin(26,51);

    rep(i,n){
        string s;
        cin>>s;

        rep(i,s.size()){
            cnt[s[i]-'a']++;
        }

        rep(i,26){
            if(cnt[i]<cntmin[i]){
                cntmin[i]=cnt[i];
            }
        }

        cnt=cntzero;
    }

    string ans;

    rep(i,26){
            rep(j,cntmin[i]){
                ans.push_back(i+'a');
        }
    }

    cout<<ans<<endl;

    /*
    rep(i,26){
        cout<<cntmin[i]<<endl;
    }
    */
}


Measured memory_bytes: 256
n, x = map(int, input().split())
l = 2 * n - 1

if x == 1 or x == l:
    print('No')
    exit(0)

if n == 2:
    print('Yes\n1\n2\n3')
    exit(0)

ans = list(map(lambda k: (k - n + x) % l + 1, range(l)))
ans[n - 3], ans[n + 1] = ans[n + 1], ans[n - 3]
print('Yes')
for v in ans:
    print(v)


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

ll pathy(int level)
{
    return 1+2*(pow(2,level)-1);
}

ll buger(int level)
{
    if(level==0)
    {
        return 1;
    }
    return 1+4*(pow(2,level)-1);
}

int main()
{
    int n;
    ll x;
    ll ans=0;
    cin>>n>>x;
    int currentlevel=n;
    ll edge=buger(n);
    ll start=1;
    while(edge-start>0)
    {
        ll point=(edge+start)/2;
        if(x==point)
        {
            ans+=pathy(currentlevel-1)+1;
            cout<<ans;
            return 0;
        }
        if(x<point)
        {
            edge=point-1;
            start+=1;
        }
        else
        {
            ans+=pathy(currentlevel-1)+1;
            start=point+1;
            edge-=1;
        }
        currentlevel-=1;
    }
    if(edge<=x)ans++;
     
    cout<<ans;
    
    

}


Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
#define pt pair<double,double>
#define x first
#define y second
const double INF=1e7;
pt p[100010];
double pw2(double d){return d*d;}
double dist(pt a,pt b){return sqrt(pw2(a.x-b.x)+pw2(a.y-b.y));}
bool cmp(pt a,pt b){return a.y<b.y;}
double closest(int l,int r)
{
  if(l==r) return INF;
  int mid=(l+r)/2,pp=l,qq=mid+1;
  double midline=p[mid].x;
  double ret=min(closest(l,mid),closest(mid+1,r));
  vector<pt> slab;
  inplace_merge(p+l,p+mid+1,p+r+1,cmp);
  for(int i=l;i<r;i++)if(p[i].y>p[i+1].y)cout<<"ERROR\n";
  //conquer
  for(int i=l;i<=r;i++)
    if(abs(p[i].x-midline)<ret)
      slab.push_back(p[i]);
  for(int i=0;i<slab.size();i++)
    for(int j=i+1;j<slab.size() && abs(slab[i].y-slab[j].y)<ret;j++)
      ret=min(ret,dist(slab[i],slab[j]));
  return ret;
}
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>p[i].x>>p[i].y;
  sort(p+1,p+n+1);
  cout<<fixed<<closest(1,n)<<endl;
  return 0;
}

Measured memory_bytes: 7788
import re

A, B = map(int, input().split())
S = input()

former = S[0:A]
later = S[(A+1):(A+B+3)]

r_f = re.compile('\d{' + str(A) + '}')
r_l = re.compile('\d{' + str(B) + '}')

if r_f.findall(former) and r_l.findall(later) and S[A] == '-':
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9832
def main():
    n = int(input())
    ranges = [[int(x) for x in input().split()] for _ in range(n)]

    mins = []
    maxs = []
    for a, b in ranges:
        mins.append(a)
        maxs.append(b)
    mins.sort()
    maxs.sort()
    if n % 2 == 0:
        min_mid = mins[n // 2 - 1] + mins[n // 2]
        max_mid = maxs[n // 2 - 1] + maxs[n // 2]
        ans = max_mid - min_mid + 1
    else:
        min_mid = mins[(n + 1) // 2 - 1]
        max_mid = maxs[(n + 1) // 2 - 1]
        ans = max_mid - min_mid + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46204
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#include <unordered_map>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007 
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
using namespace std;
long long dp[300000][2] = {};
int sosuu(int now) {
	for (int q = 2; q <= sqrt(now); ++q) {
		if (now%q == 0) return 0;
	}
	return 1;
}
int main() {
	int n;
	cin >> n;
	vector<int> a;
	a.push_back(0);
	REP(i, n) {
		int b;
		cin >> b;
		a.push_back(b);
	}
	dp[0][0] = 1;
	dp[1][1] = -1;
	n++;
	for (int i = 1; i < n; ++i) {
		if (sosuu(a[i]) == 1) {
			//back 2
			if (sosuu(a[i-1]) == 1&&a[i - 1] < a[i]) {
				dp[i][0] += dp[i - 1][0];
			}
			if (i >= 2 && sosuu(a[i - 2]) == 1 && a[i - 2] < a[i]) {
				dp[i][0] += dp[i - 1][1];
			}
			dp[i][0] %= MAX_MOD;
		}
		dp[i][1] += dp[i - 1][0];
		dp[i][1] %= MAX_MOD;
	}
	cout << (dp[n - 1][0] + dp[n - 1][1]) % MAX_MOD << endl;
	return 0;
}


Measured memory_bytes: 4932
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class BMinorChange {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s,t;in>>s>>t;
	    ll cnt=0;
	    rep(i,s.size()){
	        if(s.at(i)!=t.at(i)) ++cnt;
	    }
	    out<<cnt<<endl;

	}
};


int main() {
	BMinorChange solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3436
object Main extends App {
  val l = io.StdIn.readLine()
  val nums = l.split(" ").map((s) => s.toInt)
  if (nums.count((i) => i == 5) == 2 && nums.count((i) => i == 7) == 1 ) {
    println("YES")
  } else {
    println("NO")
  }
}

Measured memory_bytes: 21448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll l, r, d;
  cin >> l >> r >> d;
  ll ans = 0;
  rep2(i, l, r + 1) {
    if(i % d == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        long[] v = new long[N];
        for (int i = 0 ; i < N ; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextLong();
        }
        long[][] dp = new long[N + 1][W + 1];
        for (int i = 0 ; i < N ; i++) {
            for (int j = 0 ; j <= W ; j++) {
                dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j]);
                if (j + w[i] <= W) {
                    dp[i + 1][j + w[i]] = Math.max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
                }
            }
        }
        System.out.println(dp[N][W]);
    }

}


Measured memory_bytes: 129616
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	int x, y, z;
	int s, ans;
	scanf("%d %d", &x, &y);
	scanf("%d %d", &z, &s);
	if (x != z)printf("1\n");
	else printf("0\n");

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
 
int main(){
  string a,b;
  cin >> a >> b;

  a.push_back(b.at(b.size()-1));
  if(a == b){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }

  }


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

main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0; i<N;i++){
cin >> A[i];
  }
 
  int max1 =0;
for(int i=0; i<N;i++){
 if(max1<A[i]) max1=A[i];
  }

  int min1=1000000001;
  for(int i=0; i<N;i++){
 if(min1 > A[i]) min1=A[i];
  }

  cout << max1-min1 <<endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	map<char,int> m;
	string S;
	
	cin>>S;
	
	for (int i = 0; i < 4; i++) {
		m[S[i]]++;
	}
	
	bool flg=true;
	for(auto tmp:m){
		if(tmp.second!=2){
			flg=false;
		}
	}
	
	yn(flg);

	return 0;
}

Measured memory_bytes: 256
while s=gets
  i=s.chomp.to_i
  count=0
  if i>2000 then
    i=4000-i
  end

  1001.times{ |a|
    if a>i then
      break
    end
    1001.times{ |b|
      if a+b>i || i-a-b>2000 then
        break
      end
      if i-a-b>1000 then
        count+=(2001-(i-a-b))
      else
        count+=(i-a-b+1)
      end

    }
  }
  p count
end



Measured memory_bytes: 8912
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int x, y;
  scanf("%d %d", &x, &y);
  if (x % y == 0) printf("-1\n");
  else printf("%d\n", x);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]

from fractions import gcd

xs1 = []

r = A[0]
for x in A:
    r = gcd(x, r)
    xs1.append(r)

xs2 = []

r = A[-1]
for x in A[::-1]:
    r = gcd(x, r)
    xs2.append(r)

xs2 = xs2[::-1]

#print(xs1)
#print(xs2)

result = max(xs1[-2], xs2[1])

for i in range(N - 2):
    r = gcd(xs1[i], xs2[i + 2])
    result = max(result, r)

print(result)


Measured memory_bytes: 14060
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete



main = do
    [n, m] <- getInts
    unless (n==0 && m==0) $ do
        getInts >>= print . sum . map (sum . take (m-1)) . splitRec m . sortBy (flip compare) >> main


Measured memory_bytes: 5492
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        System.out.println(solve(N));

        sc.close();
    }

    static int solve(int N) {
        return Integer.highestOneBit(N);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

int main(){
    long n, k, q;
    cin >> n >> k >> q;
    vector <int> win(q);
    rep(i,q) cin >> win[i];

    vector <int> point(n,k);
    vector <int> countlose (n,q);
    for(int i=0; i<q; i++){
        countlose[win[i] - 1] --;
    }

    rep(i,n) point[i] -= countlose[i];

    for(int i=0; i<n; i++){
        if(point[i] > 0) cout << "Yes" <<endl;
        else cout << "No" << endl;
    }

}


Measured memory_bytes: 4512
use proconio::marker::{Bytes,Usize1};
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        k: usize,
        x1: Usize1,
        y1: Usize1,
        x2: Usize1,
        y2: Usize1,
        c: [Bytes;h],
    }
    let mut d=vec![vec![INF;w];h];
    let mut q=vec![];
    q.push((x1,y1));
    let mut i=0;
    d[x1][y1]=i;
    let mut p=vec![];
    while !q.is_empty() {
        i+=1;
        while let Some((x,y))=q.pop() {
            let dxy=[0,!0,0,1,0];
            for j in 0..4 {
                let dx=dxy[j];
                let dy=dxy[j+1];
                for k in 1..=k {
                    let x=x.wrapping_add(k.wrapping_mul(dx));
                    let y=y.wrapping_add(k.wrapping_mul(dy));
                    if x>=h || y>=w || c[x][y]==b'@' || d[x][y]<i {
                        break;
                    }
                    if d[x][y]>i {
                        p.push((x,y));
                        d[x][y]=i;
                    }
                }
            }
        }
        std::mem::swap(&mut q, &mut p);
    }
    if d[x2][y2]<INF {
        println!("{}",d[x2][y2]);
    }
    else {
        println!("-1");
    }
}
const INF: i32=std::i32::MAX;

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

int main() {
  string N;
  cin >> N;
  int M = N.size();
  int sum = 0;
  for (int i =0; i<M ; i++){
    if (N.at(i) == '1'){
      sum += 1;
    }
    else if (N.at(i) == '2' ){
      sum += 2;
    }
        else if (N.at(i) == '3' ){
      sum += 3;
    }
    else if (N.at(i) == '4' ){
      sum += 4;
    }
    else if (N.at(i) == '5' ){
      sum += 5;
    }
    else if (N.at(i) == '6' ){
      sum += 6;
    }
    else if (N.at(i) == '7' ){
      sum += 7;
    }
    else if (N.at(i) == '8' ){
      sum += 8;
    }
    else if (N.at(i) == '9' ){
      sum += 9;
    }
  }
  
  if ( sum%9 == 0 ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N;
int z[MC];
int c[MC];
int dp[1<<16];
int dp2[1<<16];
/*
int solve(int s){
	if(~dp[s]) return dp[s];
	dp[s] = 123456789;
	repp(i,2,16) if(s&(1<<i)){
		repp(j,1,i) if(s&(1<<j)){
			repp(k,1,16){
				int w = 1;
				if(s&(1<<(i^k))) ++w;
				if(s&(1<<(j^k))) ++w;
				int t = s ^ (1<<i) ^ (1<<j) ^ (1<<(i^k)) ^ (1<<(j^k));
				if(s>t) dp[s] = min(dp[s],solve(t)+w);
			}
		}
	}
	return dp[s];
}*/

int main(){
	cin >> N;
	repp(i,1,N){
		int x,y,a;
		cin >> x >> y >> a;
		z[x] ^= a;
		z[y] ^= a;
	}
	repp(i,0,N) ++c[z[i]];
	int ans = 0;
	int s = 0;
	repp(i,1,16){
		ans += c[i]/2;
		if(c[i]%2==1) s |= (1<<i);
	}
	fill(dp,dp+(1<<16),-1);
	dp[0] = dp[1] = 0;
	fill(dp2,dp2+(1<<16),-1);
	dp2[0] = dp2[1] = 0;
	repp(i,2,1<<16){
		if(i&1) continue;
		int p = 0 , q = 0;
		repp(k,1,16) if(i&(1<<k)){
			++p;
			q ^= k;
		}
		if(q) continue;
		dp2[i] = p-1;
		for(int j = (i-1)&i ; j > 0 ; j = (j-1)&i){
			if(~dp2[j]) dp2[i] = min(dp2[i] , dp2[j] + dp2[i^j]);
		}
		//if(solve(i) != dp2[i]) cout << i << ' ' << dp[i] << ' ' << dp2[i] << endl;
	}
	cout << ans + dp2[s] << endl;
	return 0;
}


Measured memory_bytes: 1280
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class EGetEverything {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, M;
        in >> N >> M;
        vector<int> a(M), b(M), c(M);
        REP(i,0,M) {
            in >> a[i] >> b[i];
            REP(j,0,b[i]) {
                int ci;
                in >> ci;
                c[i] += 1 << (ci - 1);
            }
        }

        vector<int> dp(1 << N, INT_MAX);
        dp[0] = 0;

        REP(i,0,(1 << N) - 1) {
            if (dp[i] == INT_MAX) continue;
            REP(j,0,M) {
                int next = c[j] | i;
                if (next == i) continue;
                dp[next] = min(dp[next], dp[i] + a[j]);
            }
        }

        out << (dp[(1 << N) - 1] == INT_MAX ? -1 : dp[(1 << N) - 1]) << "\n";
    }
};


int main() {
	EGetEverything solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;

int main() {
    cin >> n;
    long long sum = 0;
    for(int i = 1; i <= n; ++i) {
        if(i % 3 == 0 || i % 5 == 0) {

        }else {
            sum += i;
        }
    }
    cout << sum << endl;
}

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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;
const int N = 1e5 + 7;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    string s1, s2;
    cin>>s1>>s2;

    int minVal = INT_MAX;
    for(int i=0;i<=(s1.size() - s2.size());i++)
    {
        int ans = 0;
        for(int j = 0;j<s2.size();j++)
        {
            if(s1[i+j] != s2[j])
                ans++;
        }
        minVal = min( minVal, ans);
    }
    cout<<minVal<<endl;

}


Measured memory_bytes: 3616
import java.util.Scanner

fun main(args:Array<String>){
    val cin = Scanner(System.`in`)

    while(true){
	    val h = cin.nextInt()
	    val w = cin.nextInt()

	    if(h == 0 || w == 0){
	        break
	    }else{
            for(i in 1..h){
	            for(j in 1..w){
		            if((i+j)%2 == 0){
		                print("#")
		            }else{
		                print(".")
		            }
	            }
	            print("%n".format())
	        }
	        print("%n".format())
	    }
    }
}



Measured memory_bytes: 38568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int M = in.Int();
            int[] A = in.Int(M);
            int sum = 0;
            for (int i = 0; i < M; i++) {
                sum += A[i];
            }
            int ans = N - sum;
            ans = ans < 0 ? -1 : ans;
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 27420
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, A;
  int S = 0;
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> A;
    S += A;
  }
  if(N < S) {
    cout << -1 << endl;
  }
  else {
    cout << N - S << endl;
  }
}

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

int is_prime(int x) {
	int root;
	if(x==2) return 1;
	if(x%2==0) return 0;
	root=ceil(sqrt(x));
	for(int i=3;i<=root;i+=2) if(x%i==0) return 0;
		return 1;
}
int main()
{
	int x;
	cin>>x;
	while(1) {
		if(is_prime(x)==1) {cout<<x<<endl;break;}
		x++;
	}
	return 0;
}

Measured memory_bytes: 3704
import itertools

# input
H, W, K = map(int, input().split())
S = [list(map(int, input())) for _ in range(H)]

# process
ans = H*W

for divr in range(1<<(H-1)):    # 横方向の分割を総当たり
    row = 0
    Sr = [[S[0][i] for i in range(W)]]
    for i in range(1, H):
        if 1&(divr>>i-1):
            row += 1
            Sr.append([S[i][j] for j in range(W)])
        else:
            Sr[row] = [Sr[row][j]+S[i][j] for j in range(W)]

    # 縦方向の分割を加算
    cnt = [0]*(row+1)
    ans_ = row
    flg = True
    for i in range(W):
        for j in range(row+1):
            if Sr[j][i] > K:
                flg = False
                break
            cnt[j] += Sr[j][i]
            if cnt[j] > K:
                ans_ += 1
                cnt = [0]*(row+1)
                for l in range(row+1):
                    cnt[l] += Sr[l][i]
                break

        if ans_ >= ans or not flg:
            break

    if flg:
        ans = min(ans, ans_)

# output
print(ans)


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

int main() {
double a,b;
cin >> a >> b;
double o = a + b;
double x = o/2 + 0.5;
//十分の一の位が５以下のときは
//0.5を足しても一の位に繰り上がらない（十分の一の位の最大値は９）。
//５以上の時は0.5を足すと一の位に繰り上がる。
//int型は十分の一の位を切り捨てるので繰り上がったように見せることができる。

int X = x;
cout << X << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[101];
  int ans = 0;
  scanf("%s", &s);
  for(int i = 0; i < strlen(s) / 2; ++i){
    if(s[i] != s[strlen(s) - 1 - i]) ans++;
    //printf("%d : %c %c\n", i + 1, s[i], )
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  while (n != 0)
  {
    if (n % 10 == 7)
    {
      cout<<"Yes";
      return 0;
    }
    n = n / 10;
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3632
import sys
import io

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):
    QUE=n
    EatSM=0
    Sum=QUE.count("+")
    Minus=QUE.count("-")
    return EatSM+Sum-Minus

def readQuestion():
    line = sys.stdin.readline().rstrip()
    return line

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from itertools import product
N=int(input())
f=[0]*N
for x,y,z in product(range(1,100),repeat=3):
    n=x**2+y**2+z**2+x*y+y*z+z*x
    if n<=N:
        f[n-1]+=1
for i in range(N):
    print(f[i])

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

using namespace std;

int main ()
{
    int a,b;
    cin >> a >> b;
    if(a>=13)
        cout << b << endl;
    else if(a>=6 && a<=12)
        cout << b/2 << endl;
    else
        cout << 0 << endl;
    return 0;
}

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

int main()
{
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double elapsed = 60.0 * H + M;
    double argH = 0.5 * elapsed;
    double argM = 6.0 * elapsed;
    double theta = abs(argH - argM);
    cout << fixed << setprecision(12) << sqrt(A * A + B * B - 2.0 * A * B * cos(M_PI * theta / 180.0)) << endl;
    return 0;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, Aamount = 0, Bamount = 0, answer;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for(int i = 0; i < N; i+=2){
    Aamount += a.at(i);
  }
  for(int i = 1; i < N; i+=2){
    Bamount += a.at(i);
  }
  answer = Aamount - Bamount;
  cout << answer << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define ins insert
#define F first
#define S second
#define var auto
using namespace std;
typedef long long ll;
const int Max = 5e3 + 10;
const int Mod = 1e9 + 7;

int whiteScore[Max][Max];
int blackScore[Max][Max];
pair<int,int> bs[Max][Max];//F: white S: black
pair<int,int> ls[Max][Max];

int main()
{
	int n , k;cin >> n >> k;
	for(int i = 0; i < n ; i++)
	{
		int x , y;cin >> x >> y;
		char ch;cin >> ch;
		x %= 2*k;	y %= 2*k;
		x += k;		y += k;

		if(ch == 'B')
			blackScore[x][y]++;
		else
			whiteScore[x][y]++;
	}

	for(int i = 0; i < 3 * k; i++)
	{
		for(int j = 1; j < 3 * k; j++)
		{
			ls[i][j] = {ls[i][j - 1].F + whiteScore[i][j + k - 1] - whiteScore[i][j - 1]
					  , ls[i][j - 1].S + blackScore[i][j + k - 1] - blackScore[i][j - 1]};
		}
	}
	
	for(int i = 1; i < 3 * k;i++)
	{
		for(int j = 1; j < 3 * k;j++)
		{
			bs[i][j] = {bs[i - 1][j].F + ls[i + k - 1][j].F - ls[i - 1][j].F
					  , bs[i - 1][j].S + ls[i + k - 1][j].S - ls[i - 1][j].S};
		}
	}

	int ANS = 0;
	for(int i = 0; i < k ; i++)
	{
		for(int j = 0; j < k; j++)
		{
			int ans = 0;
			ans = bs[i][j].S + bs[i + k][j + k].S + bs[i][j + 2 * k].S + bs[i + 2 * k][j + 2 * k].S + bs[i + 2 * k][j].S +
				  bs[i + k][j].F + bs[i][j + k].F + bs[i + 2 * k][j + k].F + bs[i + k][j + 2 * k].F;
			int ansprim = 0;
			ansprim = bs[i][j].F + bs[i + k][j + k].F + bs[i][j + 2 * k].F + bs[i + 2 * k][j + 2 * k].F + bs[i + 2 * k][j].F +
					  bs[i + k][j].S + bs[i][j + k].S + bs[i + 2 * k][j + k].S + bs[i + k][j + 2 * k].S;
			ans = max(ans , ansprim);
			ANS = max(ans , ANS);
		}
	}
	cout << ANS << '\n';
}



Measured memory_bytes: 212768
/*
[dp] I - Coins
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 2999;

int N;
double p[MAX_N];
double dp[2][MAX_N + 1];

double solve() {
    dp[0][0] = 1.0;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i % 2][j] = 0;
        }
        for (int j = 0; j < i; j++) {
            dp[i % 2][j] += dp[(i - 1) % 2][j] * (1 - p[i - 1]);
        }
        for (int j = 1; j <= i; j++) {
            dp[i % 2][j] += dp[(i - 1) % 2][j - 1] * p[i - 1];
        }
    }

    double ans = 0;
    for (int j = N; j > N - j; j--) {
        ans += dp[N % 2][j];
    }

    return ans;
}

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

    cout << setprecision(10) << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
const int INF = 1e18;
#define pb push_back
#define ii pair<int,int>
int ans[N];
bool check[N];
vector<int> g[N];
priority_queue<ii,vector<ii>,greater<ii> > pq;
signed main(){
	int n; cin >> n;
	for(int i = 1 ; i < n ; ++i)
	{
		int a, b; cin >> a >> b;
		g[a].pb(b); g[b].pb(a);
	}
	int k; cin >> k;
	for(int i = 1 ; i <= n ; ++i) ans[i] = INF;
	for(int i = 1 ; i <= k ; ++i)
	{
		int u , num; cin >> u >> num;
		pq.push(ii(num , u));
		ans[u] = num; 
	}
	while(!pq.empty())
	{
		int u = pq.top().second;
		int num = pq.top().first;
		pq.pop();
		for(int i = 0 ; i < g[u].size() ; ++i)
		{
			int v = g[u][i];
			if(ans[v] == INF)
			{
				ans[v] = num + 1;
				pq.push(ii(ans[v] , v));
			}
			if(abs(ans[u]-ans[v])!=1)
			{
				cout << "No" << "\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
	for(int i = 1 ; i <= n ; ++i) cout << ans[i] << "\n";
	
}

Measured memory_bytes: 9460
import java.util.Scanner;
import java.util.Arrays;

/**
 * Created by Reopard on 2014/05/27.
 */


public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String args[]){
        int count;
        boolean left;
        String line;
        char[] tmp;
        Character[] qwert = {'q','w','e','r','t',
                             'a','s','d','f','g',
                             'z','x','c','v','b'};
        /*Character[] yuiop = {'y','u','i','o','p',
                             'h','j','k','l',
                             'n','m'};*/
        while(!(line = sc.next()).equals("#")){
            count = 0;
            tmp = line.toCharArray();
            left = Arrays.asList(qwert).contains(tmp[0]);
            for(int i = 1; i < tmp.length; i++){
                if(Arrays.asList(qwert).contains(tmp[i])){
                    if(!left){
                        left = true;
                        count++;
                    }
                }else{
                    if(left){
                        left = false;
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 20084
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll N, H, W;
	cin >> N >> H >> W;
	cout << (N - H + 1)*(N - W + 1);
	


	system("PAUSE");
}


Measured memory_bytes: 504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int n = Integer.parseInt(br.readLine());
			int k = Integer.parseInt(br.readLine());

			int i = 0;
			int value = 1;
			for (; i < n && value <= k; i++) {
				value *= 2;
			}

			for (; i < n; i++) {
				value += k;
			}

			System.out.println(value);
		}
	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int N,K,l,r;
int main(){
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  while(K--){
    vector<int>B(N+1,0);
    for(int i=0;i<N;i++){
      l=max(0,i-A[i]);
      r=min(N-1,i+A[i]);
      B[l]++;
      B[r+1]--;
    }
    bool changed=false;
    for(int i=0;i<N;i++){
      changed|=(A[i]!=B[i]);
      A[i]=B[i];
      B[i+1]+=B[i];
    }
    if(!changed)break;
  }
  for(int i=0;i<N;i++)cout<<A[i]<<" \n"[i==N-1];
}


Measured memory_bytes: 4772
li = input()
n = len(li)
child_li = [0]*n

ruiseki = 0
for i in range(n-1):
    if li[i] == 'R':
        ruiseki += 1
        if li[i+1] == 'L':
            child_li[i+1] = ruiseki//2
            child_li[i] = (ruiseki+1)//2
    else:
        ruiseki = 0


ruiseki = 0
for i in range(n-1, 0, -1):
    if li[i] == 'L':
        ruiseki += 1
        if li[i-1] == 'R':
            child_li[i-1] += ruiseki//2
            child_li[i] += (ruiseki+1)//2
    else:
        ruiseki = 0

print(*child_li)


Measured memory_bytes: 47684