akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val emptyCards = Array.fill(13)(-1)
  val result = (0 until n).foldLeft(Map.empty[String, Array[Int]]){ (acc, _) =>
    val Array(inpict, innum) = StdIn.readLine().split(' ')
    val temp = acc.getOrElse(inpict, emptyCards.clone())
    temp(innum.toInt-1) = 1
    acc.updated(inpict, temp)
  }
  
  List("S","H","C","D").foreach{ pict =>
    val buff = result.getOrElse(pict, emptyCards.clone())
    (0 until 13).foreach{ index =>
      if(buff(index) == - 1){
        println(pict + " " + (index + 1))
      }
    }
  }
}


Measured memory_bytes: 44064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int i;
  int x[100000];
  for (i=0;i<m;i++){
    cin >> x[i];
  }
  int max[m-1];
  sort(x,x+m);
  for (i=0;i<m-1;i++){
    max[i] = x[i+1] - x[i];
  }
  sort(max,max+m-1);
  int ans = x[m-1] - x[0];
  for (i=0;i<n-1;i++){
    ans = ans - max[m-2-i];
  }
  if (n<m){
  cout << ans << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, arr[305];

void fail() {
	cout << -1;
	exit(0);
}

void solve(ll s, ll x) {
	if (s < x) fail();
	ll a = (s-x+1)/2, resa = 0, resb = 0;
	vi v;
	DEC(i, ceil(log2(s)), 0) {
		ll xi = (x & (1ll<<i)), ai = (a & (1ll<<i));
		//cout << i << " " << xi << " " << ai << "\n";
		if (xi == 0 and ai == 0) {
		} else if (xi == 0 and ai > 0) {
			resa |= (1ll<<i);
			resb |= (1ll<<i);
		} else if (xi > 0 and ai == 0) v.pb(i);
		else fail();
	}
	for (auto i:v) {
		if ((resb | (1ll<<i)) <= arr[1]) resb |= (1ll<<i);
		else resa |= (1ll<<i);
	}
	if (resb == 0 or resb > arr[1]) fail();
	//cout << resa << " " << resb << " ";
	cout << arr[1] - resb;
}

int main() {
	fastio; cin >> n >> arr[1] >> arr[2];
	ll x = 0;
	FOR(i, 3, n) {
		cin >> arr[i];
		x ^= arr[i];
	}
	if ((arr[1] ^ arr[2]) == x) {
		cout << 0;
		return 0;
	}
	solve(arr[1] + arr[2], x);
}


Measured memory_bytes: 3768
$m1=1000000007
def f(d)
	if d<0
		return 0
	elsif d<2
		return 1
	else
		f1=0
		f2=1
		d.times{
			t=(f1+f2)%$m1
			f1=f2
			f2=t
		}
		return f2
	end
end 

main=
d=gets.split(" ").map{|e| e.to_i}
arr=[-1]
d[1].times{
	arr<<gets.to_i
}
ans=1
arr<<(d[0]+1)
(arr.size-1).times{|i|
		ans=(ans*f((arr[i+1]-1)-(arr[i]+1)))%$m1
}
p ans

Measured memory_bytes: 3836
n,m = map(int,input().split())
q = [list(map(int,input().split())) for p in range(n)]
ans = [0]*m
for qq in q:
	for t in qq[1:]:
		ans[t-1] += 1
t = 0
for a in ans:
	if a == n:
		t += 1
print(t)

Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;
const double PI = 3.14159265358979323846;
int main() {
    int n;
    cin >> n;
    int i = n % 10;
    if(i == 2 || i == 4 || i == 5 || i == 7 || i == 9) {
        cout << "hon" << endl;
    } else if(i == 3) {
        cout << "bon" << endl;
    } else {
        cout << "pon" << endl;
    }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n,w; cin >> n >> w;
  vector<vector<int>> v(4);
  int a,b; cin >> a >> b;
  v[0].push_back(b);
  for(int i = 1; i < n; i++){
    int c,d; cin >> c >> d;
    v[c-a].push_back(d);
  }
  for(int i = 0; i < 4; i++){
    sort(v[i].rbegin(),v[i].rend());
  }

  static int dp[4][101];
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < v[i].size(); j++){
      dp[i][j+1] = dp[i][j] + v[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i <= v[0].size(); i++){
    for(int j = 0; j <= v[1].size(); j++){
      for(int k = 0; k <= v[2].size(); k++){
        for(int l = 0; l <= v[3].size(); l++){
          int weight = a*i + (a+1)*j + (a+2)*k + (a+3)*l;
          if(weight > w) continue;
          int res = dp[0][i] + dp[1][j] + dp[2][k] + dp[3][l];
          ans = max(ans,res);
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<climits>
#include<iostream>
#include<map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;

int dp[100005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> hs(n);
    for(int i = 0; i < n; ++i) cin >> hs[i];
    dp[0] = 0;
    for(int i = 1; i < n; ++i) {
        dp[i] = INF;
        for(int j = 1; j <= k && i - j >= 0; ++j) {
            if(i - j >= 0) dp[i] = min(dp[i], dp[i - j] + abs(hs[i] - hs[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}



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

int keta(int n)
{
	int ret=1;
	while(1)
	{
		n/=10;
		if(n!=0)
		{
			ret++;
			continue;
		}
		else{
			break;
		}
	}
	return ret;
}

class ip{
	public:
	int f,s;
	bool operator<(const ip &rhs)
	{
		return this->s < rhs.s;
	}
	void print()
	{
		string str="";
		int l=6-keta(f+1);
		for(int i=0;i<l;i++)str+="0";
		cout << str;
		cout << f+1;
		str="";
		l=6-keta(s);
		for(int i=0;i<l;i++)str+="0";
		cout << str;
		cout << s;
		cout << endl;
	}
};

int main()
{
	
	int N,M;
	ip tmp;
	vector<vector<ip>> ken;
	vector<ip> ans;
	
	cin >> N >> M;
	int P[M+10],Y[M+10];
	
	ken.resize(N);
	ans.resize(M);
	for(int i=0;i<M;i++)
	{
		cin >> P[i] >> Y[i];
		tmp.f=i;
		tmp.s=Y[i]-1;
		ken[P[i]-1].push_back(tmp);
	}
	
	for(int i=0;i<N;i++)
	{
		sort(ken[i].begin(),ken[i].end());
		int cnt=1;
		for(auto itr=ken[i].begin();itr!=ken[i].end();++itr)
		{
			ans[itr->f].f=i;
			ans[itr->f].s=cnt;
			cnt++;
		}
	}
	for(auto itr=ans.begin();itr!=ans.end();++itr)
	{
		itr->print();
	}
	return 0;
}


Measured memory_bytes: 8576
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(3*n)]
    for _ in range(m):
        u,v=map(int,input().split())
        u-=1; v-=1
        E[3*u].append(3*v+1)
        E[3*u+1].append(3*v+2)
        E[3*u+2].append(3*v)
    s,t=map(int,input().split())
    s-=1; t-=1

    # BFS (startは0、goalは3n-3)
    from collections import deque
    d=[-1]*(3*n)
    d[3*s]=0
    Q=deque()
    Q.append(3*s)
    while(Q):
        v=Q.popleft()
        for nv in E[v]:
            if(d[nv]!=-1): continue
            d[nv]=d[v]+1
            Q.append(nv)
    ans=d[3*t]
    print(ans//3 if(ans!=-1) else -1)
resolve()

Measured memory_bytes: 78372
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  const u32 a = scan<u32>();
  const u32 b = scan<u32>();
  if (difference(a, b) % static_cast<u32>(2) == static_cast<u32>(0)) {
    std::cout << (a + b) / static_cast<u32>(2) << std::endl;
  } else {
    std::cout << "IMPOSSIBLE" << std::endl;
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,b;
  string tmp;
  cin >> a >> b;
  rep(i,b+2){
    cout << "#";
  }
  cout << endl;
  rep(i,a){
    cin >> tmp;
    cout << "#" << tmp << "#" << endl;
  }
  rep(i,b+2){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 3568
#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    if (n == 1) {
        printf("%d\n",1);
        return 0;
    }

    if (m == 1) {
        printf("%d\n", 1);
        return 0;
    }
    int all = (m + m + 1) / 2;
    long long ans = 1ll * all *(n / 2) + (n &1) * ((m + 1) / 2);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1140&lang=jp
typedef long long ll;
typedef pair<int, int> pii;
#define INF 1<<30
#define LINF 1LL<<60

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

struct edge {
	int from;
	int to;
	int dist;
	edge() {}
	edge(int from, int to, int dist) :from(from), to(to), dist(dist) {}
};

void calc_cost(int x, int y,vector<vector<int>>& cost,vector<vector<char>>& masu) {
	queue<pii> q; q.push({ x,y });
	cost[x][y] = 0;
	while (!q.empty()) {
		pii p = q.front(); q.pop();
		for (int i = 0; i < 4;i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (masu[nx][ny] == 'x')continue;
			if (cost[nx][ny] > cost[p.first][p.second] + 1) {
				cost[nx][ny] = cost[p.first][p.second] + 1;
				q.push({ nx,ny });
			}
		}
	}
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	int w, h;
	while (cin >> w >> h, w | h) {
		vector<vector<char>> masu(h + 2, vector<char>(w + 2, 'x'));
		vector<pii> yogore;
		int sx, sy;
		for (int i = 1; i <= h;i++) {
			for (int j = 1;j <= w;j++) {
				cin >> masu[i][j];
				if (masu[i][j] == '*'||masu[i][j] == 'o') {
					if (masu[i][j] == 'o') { sx = i, sy = j; }
					else yogore.push_back({ i,j });
					masu[i][j] = '.';
					continue;
				}
			}
		}
		int Size = yogore.size();

		queue<pii> q;
		vector<vector<int>> dp(Size, vector<int>(1 << Size, INF));

		vector<vector<edge>> G(Size);
		for (int i = -1; i < Size;i++) {
			vector<vector<int>> cost(h + 2, vector<int>(w + 2, INF));

			if(i == -1) calc_cost(sx, sy, cost, masu);
			else calc_cost(yogore[i].first, yogore[i].second, cost, masu);

			for (int j = 0; j < Size;j++) {
				if (i == -1) {
					dp[j][1 << j] = cost[yogore[j].first][yogore[j].second];
					q.push({ j, 1 << j });
				}
				else {
					if (i == j)continue;
					if (cost[yogore[j].first][yogore[j].second] == INF)continue;
					G[i].push_back(edge(i, j, cost[yogore[j].first][yogore[j].second]));
				}
			}
		}
		while (!q.empty()) {
			auto p = q.front(); q.pop();
			int n = p.first, bit = p.second;
			for (auto e : G[n]) {
				if ((1 << e.to)&bit)continue;
				if (dp[e.to][(1 << e.to) | bit] > dp[n][bit] + e.dist) {
					dp[e.to][(1 << e.to) | bit] = dp[n][bit] + e.dist;
					q.push({ e.to,(1 << e.to) | bit });
				}
			}
		}
		int ans = INF;
		for (int i = 0; i < Size;i++) {
			ans = min(ans, dp[i][(1 << Size) - 1]);
		}
		cout << ((ans != INF) ? ans : -1) << endl;
	}

	return 0;
}

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

int main()
{
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    ll train = A;
    ll bus = min(train, B);
    ll taxi = min(bus, C);
    ll plane = min(taxi, D);
    ll ship = min(plane, E);

    ll ans;
    if (N % ship == 0) {
        ans = 4 + (N / ship);
    } else {
        ans = 5 + (N / ship);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod =1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
// ----------------------DEBUG TEMPLATE--------------------------

int solve(vi& weight,vi& val,int N,int W){
    int dp[N+1][W+1];
    
    for(int i =0;i <=N;i++){
        dp[i][0]=0;
    }
    for(int i =0;i <=W;i++){
        dp[0][i]=0;
    }

    for(int i =1;i <=N;i++){
        for(int j =1;j<=W;j++){
            if(weight[i]>j){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = max(dp[i-1][j-weight[i]]+val[i],dp[i-1][j]);
            }
        }
    }
    return dp[N][W];

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int N,W;
    cin>>N>>W;
    vector<int>weight(N+1),val(N+1);
    for(int i =1;i <=N;i++){
        cin>>weight[i]>>val[i];
    }
    cout<<solve(weight,val,N,W)<<endl;


}
    

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

int main(){
    list<int> l;

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

    for(int i=0;i<n;i++){
        l.push_back(i);
    }

    //残った生徒の確立
    list<int>::iterator btn = l.begin();
    for(int i=0;i<m;i++){
        int a;
        cin >> a;

        if(a%2==0){
            for(int j=0;j<a;j++){
                btn++;
                if(btn==l.end()){
                    btn = l.begin();
                }
            }
        }else{
            for(int j=0;j<a;j++){
                if(btn==l.begin()){
                    btn = l.end();
                }
                btn--;
            }
        }

        list<int>::iterator it = btn;
        btn++;
        if(btn==l.end()){
            btn = l.begin();
        }
        l.erase(it);
    }


    //query
    for(int i=0;i<q;i++){
        int query;
        cin >> query;

        list<int>::iterator it;

        for(it=l.begin();it!=l.end();it++){
            if(*it==query){
                break;
            }
        }

        if(it!=l.end()){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 9328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
#include <stdio.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)
#pragma GCC optimize("Ofast")




int main() {
	string s;
	cin >> s;
	string t = s;
	reverse(t.begin(), t.end());
	if (t[0] != 's') {
		s.push_back('s');
	}
	else {
		s.push_back('e');
		s.push_back('s');
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define F first
#define S second

const int sz = 1e5+5;
int n, m, a[sz];

void solve(){
    cin >> n >> m;
    for(int i = 0; i < n; ++i) cin >> a[i];


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

    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 6940
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double ang = abs(2.0 * M_PI * (h / 12 + 1.0 / 12.0 * m / 60 - m / 60));
    ang = min(2.0 * M_PI - ang, ang);
    dump(ang);
    cout << setprecision(10) << sqrt(a * a + b * b - 2.0 * a * b * cos(ang)) << endl;
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
#define ll long long
#define inf 1000000000ll
using namespace std;

ll n,W;
ll v[105],w[105],dp[105][100005];
ll ww;

ll solve(ll i, ll val){
    if(val<0)return inf;
    if(dp[i][val]==-1){
        if(val==0)return 0;
        if(i==n && val==0)return 0;
        if(i==n && val>0)return inf;
        return dp[i][val]=min(solve(i+1,val-v[i]) + w[i], solve(i+1,val));
    }
    return dp[i][val];
}

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    ll a,b;
    cin>>n>>W;
    ll mx=0;
    for(ll x=0; x<n; x++){
        cin>>w[x]>>v[x];
        mx+=v[x];
    }
    for(ll x=0; x<=n;x++){
        for(ll y=0; y<=mx; y++){
            dp[x][y]=-1;
        }
    }
    for(ll x=mx; x>=0; x--){
        a=solve(0,x);
        if(a<=W){
            cout<<x;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 80128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long[] a = new long[n];

        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                a[i] = long.Parse(words[i]);
            }
        }

        long[] x = new long[n];

        long sum = a.Sum();

        x[0] = sum;
        for (int i = 1; i < n; i = i + 2)
        {
            x[0] = x[0] - (a[i] * 2);
        }

        for (int i = 1; i < n; i++)
        {
            x[i] = a[i - 1] * 2 - x[i - 1];
        }

        Console.WriteLine(string.Join(" ", x));
    }
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

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

  int n,d,x;cin>>n>>d>>x;
  VVI p(d,vector<int>(n,0));
  for(int i=0;i<d;i++)for(int j=0;j<n;j++) cin>>p[i][j];
  std::vector<int> dp(100001);
  for(int i=0;i<d-1;i++){
      for(int j=0;j<=x;j++) dp[j]=j;
      for(int j=0;j<n;j++)for(int k=0;k<=x;k++){
          if(k-p[i][j]>=0){
              dp[k]=max(dp[k],dp[k-p[i][j]]+p[i+1][j]);
          }
      }
      for(int j=0;j<=x;j++) x=max(x,dp[j]);
  }
  cout<<x<<endl;
}

Measured memory_bytes: 3368
#include"bits/stdc++.h"
using namespace std;
int main(void){
  int n;
  string s[50],x;
  int t[50];
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>s[i]>>t[i];
  }
  cin>>x;
  bool w=false;
  int ans=0;
  for(int i=0;i<n;++i){
    if(w){
      ans+=t[i];
    }
    if(x==s[i]){
      w=true;
    }}
  cout<<ans;
}

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

const long long MOD = 998244353;

long long fact[10000005];

long long powmod(long long a, long long b){
    long long x = 1;
    long long y = a;
    while(b){
        if(b&1){ x = (x*y)%MOD; }
        y = (y*y)%MOD;
        b >>= 1;
    }
    return x;
}

inline long long ncr(long long a, long long b){
    return fact[a]*powmod((fact[a-b]*fact[b])%MOD, MOD-2)%MOD;
}

int main(){
    int N;
    scanf("%d", &N);

    fact[0] = 1;
    for(int i = 1; i <= N; i ++){
        fact[i] = (fact[i-1]*i)%MOD;
    }

    long long tempPow2 = 1;
    long long ans = 0;
    for(int i = N; i > (N>>1); i --){
        ans += tempPow2*ncr(N, i)%MOD;

        tempPow2 += tempPow2;
        if(tempPow2 >= MOD){tempPow2 -= MOD;}
    }
    //printf("ans(%d)=%lld\n", N, ans);
    ans = (ans+ans)%MOD;
    long long finalAns = (powmod(3, N)-ans+MOD)%MOD;

    printf("%lld", finalAns);
    return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
const int maxn=111;
const int inf=0x3f3f3f3f;
int e[maxn][maxn];
int n;
int  p[maxn];
int b[maxn];
int vis[maxn];
void prime()
{
    memset(vis,0,sizeof(vis));
    memset(p,-1,sizeof(p));
    for(int i=0; i<n; i++)
        b[i]=inf;
    b[0]=0;
    while(1)
    {
        int ans=inf;
        int v=-1;
        for(int i=0; i<n; i++)
        {
            if(vis[i]==0&&b[i]<ans)
            {
                v=i;
                ans=b[i];
            }
        }
        if(v==-1)
            break;
        vis[v]=1;
        for(int i=0; i<n; i++)
        {
            if(b[i]>e[v][i]&&vis[i]==0)
            {
                b[i]=e[v][i];
                p[i]=v;
                //printf("%d\n",v);
            }
        }
    }
 
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(p[i]!=-1)
            sum+=e[p[i]][i];
    }
    printf("%d\n",sum);
}
int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            int x;
            scanf("%d",&x);
            if(x==-1)
                e[i][j]=inf;
            else e[i][j]=x;
        }
    prime();
    return 0;
}


Measured memory_bytes: 3252
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
T = input()

s = [[] for _ in range(26)]
t = [[] for _ in range(26)]

l = len(S)

for i in range(l):
    s[ord(S[i]) - ord('a')].append(i)
    t[ord(T[i]) - ord('a')].append(i)


def ok():
    ch = [False] * 26
    for i in range(l):
        if not ch[ord(S[i]) - ord('a')]:
            ch[ord(S[i]) - ord('a')] = True
            ls = s[ord(S[i]) - ord('a')]
            lt = t[ord(T[i]) - ord('a')]
            if ls != lt:
                return False
    return True

print("Yes" if ok() else "No")

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

using namespace std;

long long x, k, d;

int main() {
    scanf("%lld%lld%lld", &x, &k, &d);

    x = abs(x);

    if (x / d >= k) return 0 * printf("%lld\n", x - k * d);

    long long cnt = k - x / d;

    if (cnt % 2 == 0) printf("%lld\n", x % d);
    else printf("%lld\n", d - x % d);
}


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define _upgrade                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template <typename _T>
inline void _DBG(const char *s, _T x)
{
    cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a)
{
    while (*s != ',')
        cerr << *s++;
    cerr << " = " << x << ',';
    _DBG(s + 1, a...);
}

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr \
    if (0)   \
    cout
#endif

// ********************** CODE ********************** //

int main()
{
    _upgrade
    LL x, y; cin >> x >> y;
    if(x % y == 0)
    {
        cout << -1;
    }
    else
    {
        cout << x;
    }
    return 0;
}


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

#define int ll

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

typedef long double ld;

const int MOD = 1E9 + 7;
const ld EPS = 1E-20;

int binpow(int base, int e) {
	int ret = 1;
	while(e) {
		if(e & 1)
			ret = (ret * base) % MOD;
		e >>= 1;
		base = base * base % MOD;
	}
	return ret;
}

int sub(int x, int y) {
	x -= y;
	if(x < 0)
		x += MOD;
	return x;
}

int sgnm(int x) {
	if(x >= 0)
		return 1;
	return -1;
}

int32_t main() {
	// cout << __gcd(-6, 0) << '\n';
	int n;
	cin >> n;
	int res = 1, bad = 0;
	map<pi, int> mp;
	set<pi> vis, in;
	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if(a == 0 && b == 0) {
			bad++;
			continue;
		}
		int g = __gcd(a, b);
		a /= g;
		b /= g;
		mp[{a, b}]++;
		in.insert({a, b});
	}
	for(pi pp : in) {
		if(vis.count(pp))
			continue;
		int na = 0, nb = 0;
		int a = pp.fs, b = pp.sd;
		na = mp[{a, b}] + mp[{-a, -b}];
		nb = mp[{-b, a}] + mp[{b, -a}];
		vis.insert({a, b});
		vis.insert({-a, -b});
		vis.insert({-b, a});
		vis.insert({b, -a});
		// int a = pp.fs, b = pp.sd;
		// vis.insert({a, b});
		// vis.insert({-b * sgnm(a), a * sgnm(a)});
		// int n1 = mp[{a, b}], n2 = mp[{-b * sgnm(a), a * sgnm(a)}];
		res = (res * (binpow(2, na) + binpow(2, nb) - 1)) % MOD;
	}
	cout << ((res - 1 + bad) % MOD + MOD) % MOD << '\n';
}

/*
3
1 1
1 -1
2 -2

3
2 0
0 1
0 0

*/


Measured memory_bytes: 115932
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  char ch;
  cin>>ch;
  if(ch<='Z'&&ch>='A') cout<<'A';
  else cout<<'a';
}

Measured memory_bytes: 3600
using System;
using System.Linq;

namespace Welcome_to_AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            var array = input.Split(' ').Select(_ => int.Parse(_)).ToArray();
            var n = array[0];
            var d = array[1];

            var hoge = d * 2 + 1;
            int result = n % hoge == 0 ? (n / hoge) : (n / hoge) + 1;

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to;
};
struct RLAQ {
	ll sst[1 << 18];
	ll adt[1 << 18];
	RLAQ() {
		fill(sst, sst + (1 << 18), 0);
		fill(adt, adt + (1 << 18), 0);
	}
	void add(int p, int q, ll x, int k = 0, int l = 0, int r = (1 << 17)) {
		if (r <= p || q <= l) return;
		if (p <= l && r <= q) {
			adt[k] += x;
			return;
		}
		add(p, q, x, 2 * k + 1, l, (l + r) / 2);
		add(p, q, x, 2 * k + 2, (l + r) / 2, r);
		sst[k] = max(sst[2 * k + 1] + adt[2 * k + 1], sst[2 * k + 2] + adt[2 * k + 2]);
	}
	ll find(int p, int q, int k = 0, int l = 0, int r = (1 << 17)) {
		if (r <= p || q <= l) return LLONG_MIN / 2;
		if (p <= l && r <= q) return sst[k] + adt[k];
		ll m1, m2;
		m1 = find(p, q, 2 * k + 1, l, (l + r) / 2);
		m2 = find(p, q, 2 * k + 2, (l + r) / 2, r);
		return max(m1, m2) + adt[k];
	}
};

int arr[1000001], pc;
void Eratosthenes(int N) {//Nまでの素数表
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = i * 2; j <= N; j += i) {
				arr[j] = 0;
			}
		}
	}

	int cou = 0;
	for (int i = 2; i < N; i++) {
		if (arr[i] == 1) {
			arr[cou] = i;
			cou++;
		}
	}
	pc = cou;
}
int main() {

	int n, k;
	cin >> n >> k;
	ll ans = 0;
	rep(b, k + 1, n + 1) {

		ll lbm = k,rbm = b-1;
		ll cy = ((n - rbm) / b) + 1;
		ans += cy * (rbm - lbm + 1);

		ans += max(0LL,n - (cy * b + lbm) + 1);
		if (lbm == 0)
			ans--;

	}

	cout << ans << endl;

	return 0;
}

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

int main(){

   int n;
   cin >> n;
   string s;
   cin >> s;
   for(int i = 0; i < s.size(); i++){
         int val = s[i] - 'A';
         val += n;
         val %= 26;
         s[i] = val + 'A';
   }  cout << s << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
using namespace std;
int main(void){
    int h, w, k;
    int ans = 0;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(is, 1<<h)rep(js, 1<<w){
        int cnt = 0;
        rep(i, h)rep(j, w){
            if (is>>i&1) continue;
            if (js>>j&1) continue;
            if (s[i][j] == '#') cnt++;
        }
        if (cnt == k) ans++; 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);


    while(true){
        int m = sc.nextInt();
        int f = sc.nextInt();
        int r = sc.nextInt();

        if(m==-1 && f == -1 && r == -1) break;

        if(m==-1 || f==-1)  System.out.println("F");
        else if(m + f >=80) System.out.println("A");
        else if(m + f >=65) System.out.println("B");
        else if(m + f>=50)  System.out.println("C");
        else if(m + f >=30){
            if(r >= 50) System.out.println("C");
            else    System.out.println("D");
        }else   System.out.println("F");
    }
        sc.close();
    }
}


Measured memory_bytes: 26140
#include <stdio.h>
int main(){

  int i,j,k,H,W;

  while (1){

    scanf("%d %d",&H,&W);
  
    if (H != 0 && W != 0){

      for (i = 0; i < W; i++){
    
	printf("#");

      }
      
      printf("\n");

      for (j = 0; j < H-2; j++){

	printf("#");
	
	for (k = 0; k < W-2; k++){
	  
	  printf(".");
	  
	}
	
	printf("#\n");
	
      }
      
      for (i = 0; i < W; i++){
	
	printf("#");
	
      }
      
      printf("\n\n");
      
    } else {
      
      break;
      
    }
    
  }
  
  return 0;

}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back

int main() {
    ios
    int tests=1 ;
//    cin>>  tests;
    while(tests--)
    {
        int n,k;cin>> n >> k;
        vector<int> v;
        vector<int> dp(n+1);
        
        rep(i,0,n)
        {
            int data;
            cin>> data;
            v.pb(data);
        }
        dp[1]=0; dp[2]=abs(v[0]-v[1]);
        rep(i,3,n+1)
        dp[i]=INT_MAX;
//        cout << dp[0] << "  " << dp[1]<< "  " << dp[2];
        
        rep(i,3,n+1)
        {
            rep(j,1,k+1)
            if(i-j-1 >=0)
                dp[i]=min(dp[i],dp[i-j]+abs(v[i-j-1]-v[i-1]));
//            cout << dp[i] << endl;
        }
        cout << dp[n];
        
    }
    
    return 0;
}



Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"Yes\n";} void NO(){cout<<"No\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const bool DEBUG = 0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	ll a[n],b[n];
	forn(i,0,n) cin>>a[i];
	forn(i,0,n) cin>>b[i];
	
	sort(b,b+n,greater<ll>());
	
	int L=-1,R=-1;
	forn(i,0,n)
	{
		if(a[i]==b[i])
		{
			if(L==-1) L=i;
			R=i;
		}
	}
	
	if(L==-1)
	{
		YES();
		forn(i,0,n) cout<<b[i]<<" ";
		cout<<'\n';
		return 0;
	}
	
	if(a[0]==a[L] && b[n-1]==b[L])
	{
		NO(); return 0;
	}
	
	int ptr=0;
	for(int i=L;i<=R;i++)
	{
		while(ptr<n && (a[ptr]==a[i] || b[ptr]==a[i])) ptr++;
		if(ptr==n){ NO(); return 0; }
		swap(b[ptr],b[i]);
		ptr++;
	}
	
	YES();
	forn(i,0,n) cout<<b[i]<<" ";
	cout<<'\n';
	
	return 0;
}


Measured memory_bytes: 6780
N = input()
A = list(map(int,input().split()))
raw =sum(A)
con = 0

if len(A) == 1:
    print(0)
    
else:
    for i in A:
        if A[con] > A[con+1]:
            A[con+1] =  A[con]
        
        if A[con+1] == A[-1]:
            break

        con += 1

    ans = sum(A) - raw
    print(ans)

Measured memory_bytes: 32120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

ll n, m;
//
//struct edge{
//	ll to, cost;
//};
//
//ll pre[110];
//
//int d[110];
//vector<edge> G[110];
//
//void djikstra(int start){
//	fill(d, d + 110, INF);
//	fill(pre, pre + 110, -1);
//	d[start] = 0;
//	priority_queue<P, vector<P>, greater<P> > que;
//	que.push(P(0, start));
//
//	while (!que.empty()){
//		P p = que.top(); que.pop();
//		int v = p.second;
//
//		if (d[v] < p.first)continue;//更新する必要のない点
//
//		for (int i = 0; i < G[v].size(); i++){
//			edge e = G[v][i];
//			if (d[e.to] > d[v] + e.cost){
//				d[e.to] = d[v] + e.cost;
//				pre[e.to] = v;
//				que.push({ d[e.to], e.to });
//			}
//		}
//	}
//}
//
//bool ans[110][110];
//
//int main(){
//	cin >> n >> m;
//	REP(i, m){
//		ll a, b, c;
//		cin >> a >> b >> c;
//		G[a].push_back({ b, c });
//		G[b].push_back({ a, c });
//		ans[a][b] = 1;
//		ans[b][a] = 1;
//	}
//	REP(i, n + 1){
//		djikstra(i);
//		FOR(j, i + 1, n + 1){
//			for (ll v = j; pre[v] != -1; v = pre[v]){
//				ans[v][pre[v]] = 0;
//				ans[pre[v]][v] = 0;
//			}
//		}
//	}
//	ll res = 0;
//	REP(i, n + 1){
//		FOR(j, i + 1, n + 1){
//			if (ans[i][j]){
//				res++;
//			}
//		}
//	}
//	cout << res << endl;
//}

ll dp[110][110];
ll d[110][110];

int main(){
	cin >> n >> m;
	REP(i, n)REP(j, n)dp[i][j] = INF;
	REP(i, m){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		dp[a][b] = c;
		dp[b][a] = c;
		d[a][b] = c;
	}

	REP(k, n){
		REP(i, n){
			REP(j, n){
				dp[i][j] = min(dp[i][k] + dp[k][j], dp[i][j]);
			}
		}
	}

	int ans = 0;
	REP(i, n){
		REP(j, n){
			if (dp[i][j] < d[i][j])ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import collections


def f(x):  # 何個取り出せるか
    if x == 0:
        return 0
    elif 1 <= x <= 2:
        return 1
    elif 3 <= x <= 5:
        return 2
    elif 6 <= x <= 9:
        return 3
    elif 10 <= x <= 14:
        return 4
    elif 15 <= x <= 20:
        return 5
    elif 21 <= x <= 27:
        return 6
    elif 28 <= x <= 35:
        return 7
    elif 36 <= x <= 44:
        return 8
    else:
        return 9



def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n = int(input())

if n == 1:
    print(0)
    quit()

c = collections.Counter(prime_factorize(n))
cl = c.values()

ans = 0
for i in cl:
    ans += f(i)

if ans == 0:
    print(1)
else:
    print(ans)

Measured memory_bytes: 9492
# include <iostream>
# include <string>

using namespace std;


int main () {
    string s;
    cin >> s;

    int nb = 0;
    long long ans = 0;

    for (char c: s) {
        if (c == 'W') {
            ans += nb;
        }
        else {
            nb++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


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


def resolve():
    n = int(input())

    sum_fizz_buzz = 0

    for i in range(1, n+1):
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            sum_fizz_buzz += i

    print(sum_fizz_buzz)



if __name__ == "__main__":
    resolve()



Measured memory_bytes: 67280
#include <bits/stdc++.h>
using namespace std;
main(){
int N,M,i,j;
cin>>N>>M;
vector<int>D(N);
vector<int>C(M);
for(i=0;i<N;i++){cin>>D[i];}
for(i=0;i<M;i++){cin>>C[i];}
vector<vector<int> >dp(M+1,vector<int>(N+1,1<<30));dp[0][0]=0;
for(i=0;i<M;i++){for(j=0;j<=N;j++){
if(j==0){dp[i+1][j]=dp[i][j];}
else{dp[i+1][j]=min(dp[i][j],dp[i][j-1]+C[i]*D[j-1]);}}}
cout<<dp[M][N]<<endl;
return 0;}

Measured memory_bytes: 5920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;

string tmp, s;

int main()
{
	ios::sync_with_stdio(0);
	cin >> tmp;
	s = "";
	int sz = tmp.size();
	tmp += ' ';
	for (int i = 0; i < sz; ++i) {
		if (tmp[i] == 'B' && tmp[i + 1] == 'C') s += 'D', ++i;
		else s += tmp[i];
	}
	sz = s.size();
	s += ' ';
	ll ans = 0LL;
	for (int i = 0; i < sz; ++i) {
		if (s[i] == 'A' || s[i] == 'D') {
			int ed = i;
			while (ed < sz && (s[ed] == 'A' || s[ed] == 'D')) ed++;
			ed--;
			int pt = 0;
			for (int j = i; j <= ed; ++j) {
				if (s[j] == 'D') ans += (ll)j - i - pt, pt++;
			}
			i = ed;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 916
import math

menu = []
for _ in range(5):
    m = input()
    e = int(m[-1])
    if e == 0:
        e = 10
    menu.append([int(m), e])
menu.sort(key=lambda x: x[1])

ans = 0
for m in menu[1:]:
    ans += math.ceil(m[0]/10)*10
print(ans + menu[0][0])

Measured memory_bytes: 3060
from collections import deque
N = int(input())
H = list(map(int, input().split()))
V = deque()
for i in range(len(H)):
    counter = 0
    for j in range(i):
        if H[i] >= H[j]:
            counter += 1
    if counter == i :
        V.append(H[i])
print(len(V))




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

int main() {
  int N, M, A = 0, W = 0;
  cin >> N >> M;
  vector<int> a(N, 0), b(N, 0);
  for(int i = 0;i < M;i++) {
    int p;
    string s;
    cin >> p >> s;
    if(a[p-1] == 0) {
      if(s == "AC") {
        a[p-1] = 1;
        A++;
      } else {
        b[p-1]++;
      }
    }
  }
  for(int i = 0;i < N;i++) {
    if(a[i] == 1) W += b[i];
  }
  cout << A << " " << W << endl;
}

Measured memory_bytes: 4032
#include <stdio.h>

int main() 
{
    char ch;
    int i,j=0,k;
    for(i=0;(ch=getchar())!='\n';i++)
    {
    	if(ch=='7')
    	{
    		j=1;
    		break;
		}
	}
	if(j==1)
	  printf("Yes");
	  else printf("No");
	return 0;
}


Measured memory_bytes: 1576
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e5 + 5;

int n,m,f[N];

int find(int x){
    return x==f[x]?x:f[x]=find(f[x]);
}

void merge(int x,int y){
    int u=find(x),v=find(y);
    if(u!=v) f[v]=u;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m;
    for(int i=1;i<=n;i++) f[i]=i;
    for(int i=1;i<=m;i++){
        int u,v;cin>>u>>v;
        merge(u,v);
    }
    int cnt=0;
    for(int i=1;i<=n;i++) if(f[i]==i) cnt++;
    cout<<cnt-1<<'\n';
    return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+1;
ll a[maxn];
int main()
{
	int n,k;
	while(scanf("%d%d",&n,&k)!=EOF)
	{
		ll ans=2e18;
		for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
		if(a[n]<=0) {printf("%lld\n",abs(a[n-k+1]));continue;}
		if(a[1]>=0) {printf("%lld\n",abs(a[k]));continue;}
		int pos=lower_bound(a+1,a+1+n,0)-a;
		if(pos+k-1<=n) ans=min(ans,abs(a[pos+k-1]));
		int l=pos-k;
		if(a[pos]==0) l++;
		if(l>=1) ans=min(ans,abs(a[l]));
		for(int i=max(l+1,1);i+k-1<=n&&i<pos;++i)
		{
			ans=min(ans,min(abs(a[i])*2+abs(a[i+k-1]),abs(a[i])+abs(a[i+k-1])*2));
		}
		
		printf("%lld\n",ans);
 	}
}

Measured memory_bytes: 1024