akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector<int> mochi;
  int i,j;
  int d;
  bool check;
  
  for(i=0;i<N;i++){
    cin >> d;
    check = false;
    for(j=0;j<mochi.size();j++){
      if(mochi.at(j) == d){
        check = true;
        break;
      }
    }
    if(check == false){
      mochi.push_back(d);
    }
  }
  
  cout << mochi.size() << endl;
        
      
  
  



}




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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(),a.end())
#define NP(a) next_permutation(a.begin(),a.end())

typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout<<"input"<<endl;freopen("input.txt","r",stdin);
    //cout<<"output"<<endl;freopen("output.txt","w",stdout);
    
    
    int n;
    cin>>n;
    pl minn , maxx;
    minn . F = LLONG_MAX;
    maxx . F = LLONG_MIN;
    minn . S = LLONG_MAX;
    maxx . S = LLONG_MIN;
    while(n--){
        ll x,y;
        cin>>x>>y;
        minn.F = min(minn.F,x+y);
        minn.S = min(minn.S,x-y);

        maxx.F = max(maxx.F,x+y);
        maxx.S = max(maxx.S,x-y);
    }
    cout<<max( abs(minn.F - maxx.F) , abs(minn.S - maxx.S));
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ul N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D;
  cin >> S;
  if (S.substr(A - 1, C - A + 1).find("##") != std::string::npos) {
    cout << "No" << endl;
    return 0;
  }
  if (S.substr(B - 1, D - B + 1).find("##") != std::string::npos) {
    cout << "No" << endl;
    return 0;
  }
  if (D < C) {
    std::string tmp_s1 = S.substr(A - 1, C - A + 1);
    std::string tmp_s2 = S.substr(A - 1, C - A + 1);
    if (S.substr(B - 1, D - B + 1).find("...") != std::string::npos) {
      cout << "Yes" << endl;
      return 0;
    }
    tmp_s1[D - A] = '#';
    tmp_s2[B - A] = '#';
    if ((tmp_s1.find("##") != std::string::npos) &&
        (tmp_s2.find("##") != std::string::npos)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


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

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }

template<class T> vector<pair<T,T>> factorize(T n)
{
    vector<pair<T,T>> factors;

    T lim = sqrt(n) + 0.1;
    
    T c = 0;
    while (n % 2 == 0) {
        n /= 2;
        c++;
    }
    if (c != 0)
        factors.push_back(make_pair(2, c));

    for (T p = 3; p <= lim; p += 2) { //cout << "p:" << p << " n:" << n <<" lim:" << lim << endl;
        T c = 0;
        while (n % p == 0) {
            n /= p;
            c++;
        }
        if (c != 0)
            factors.push_back(make_pair(p, c));
    }
    if (n != 1) {
        factors.push_back(make_pair(n, 1));
    }
    
    return factors;
}

template <class INT_T> INT_T powi(INT_T x, INT_T y) {
    if (y == 0) return 1;
    if (y == 1) return x;
    if (y & 1) return powi(x*x, y/2) * x;
    return powi(x*x, y/2);
}

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

    ll N, P;
    cin >> N >> P;

    vector<pair<ll, ll>> f = factorize(P);

    ll ans = 1;
    rep(i, f.size()) {
        if (f[i].second >= N) {
            ans *= powi(f[i].first, f[i].second/N);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
let N = Int(readLine()!)!
var res: [Int] = Array(repeating: 0, count: 4)

for _ in 1...N {
    let S: String = readLine()!
    if S == "AC" {
        res[0] += 1
    } else if S == "WA" {
        res[1] += 1
    } else if S == "TLE" {
        res[2] += 1
    } else {
        res[3] += 1
    }
}

print("""
AC x \(res[0])
WA x \(res[1])
TLE x \(res[2])
RE x \(res[3])
""")    // (๑•ૅㅁ•๑)

Measured memory_bytes: 8004
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 1005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int a[105];
int main()
{
    int n, tem, tot = 0;
    cin >>n;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        tot += a[i];
    }
    int ans = tot;
    int i;
    sort(a, a+n);
    if(tot % 10 == 0)
    {
        for(i = 0; i < n; ++i)
        {
            if((tot-a[i])%10 == 0) continue;
            else
            {
                tot -= a[i];
                break;
            }
        }
        if(i == n) tot = 0;
    }
    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>  
    using namespace std;  
    typedef long long LL;  
    const int maxn=1e5+10;  
    int n,a[maxn];  
    bool check()  
    {  
        LL s=0;  
        for (int i=1;i<=n;i++) s+=a[i];  
        s*=2;  
        if (s%((LL)n*(n+1))!=0) return 0;  
        s/=n;s/=(n+1);  
        for (int i=1;i<n;i++)  
        {  
            LL s1=a[i]-a[i+1]+s;  
            if (s1<0||s1%n!=0) return 0;  
        }  
        LL s1=a[n]-a[1]+s;  
        if (s1<0||s1%n!=0) return 0;  
        return 1;  
    }  
    int main()  
    {  
        cin>>n;  
        for (int i=1;i<=n;i++) scanf("%I64d",&a[i]);  
        if (check()) printf("YES");  
        else printf("NO");  
        return 0;  
    }  

Measured memory_bytes: 640
#!/usr/bin/env python3


def solv(ds):
    ds = sorted(ds, key=lambda d: -d[2])
    ds = sorted(ds, key=lambda d: d[1])
    return ds


if __name__ == '__main__':

    n = int(input())

    ds = []
    for n in range(n):
        s, p = (input().split())
        ds.append((n+1, s, int(p)))

    ans = solv(ds)

    for a in ans:
        print(a[0])


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

int main(){
	int midLeft;
	int midRight;

	int n;
	std::vector<int> xList;
	std::vector<int> sortedList;

	std::cin>>n;
	xList.resize(n);
	for(int i=0; i<n; i++)
		std::cin>>xList[i];

	std::copy(xList.begin(), xList.end(), std::back_inserter(sortedList));

	std::sort(sortedList.begin(), sortedList.end());
	midRight= sortedList[sortedList.size()/2];
	midLeft= sortedList[sortedList.size()/2 -1];

	for(int i=0; i<n; i++){
		if(xList[i]<=midLeft)
			std::cout<<midRight<<std::endl;
		else
			std::cout<<midLeft<<std::endl;
	}

	return 0;
	
}

Measured memory_bytes: 3828
a, b, h, m = gets.chomp.split(" ").map(&:to_f)

i = Math::PI * 2 * (h + m / 60 ) / 12
j = Math::PI * 2 * m / 60


puts Math.sqrt( a**2 + b**2 - 2 * a * b * Math.cos( ( i - j ).abs ) ) 


Measured memory_bytes: 14692
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string s;
  cin >> s;
  vector<int> a(26, 0);

  for(char c: s){
    a[c-'a']++;
  }

  rep(i, 26){
    if(a[i] > 1){
      print("no");
      return 0;
    }
  }
  print("yes");
}


Measured memory_bytes: 504
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int allXor = 0;
  rep(i, N) {
    cin >> a[i];
    allXor ^= a[i];
  }

  vector<int> ans(N);
  rep(i, N) {
    ans[i] = allXor ^ a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 6388
from math import factorial as fact

S = int(input())
MOD = 10**9+7

ans = 0
for i in range(1,S):
    if S < 3*i : break
    n = S-3*i+i-1
    r = i-1
    ans += fact(n) // (fact(r) * fact(n-r))


print(ans%MOD)

Measured memory_bytes: 78340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    ll a,b,k;cin>>a>>b>>k;
    if(a>=k) cout<<a-k<<" "<<b<<endl;
    else if(a+b>=k) cout<<"0 "<<a+b-k<<endl;
    else cout<<"0 "<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m; 
    cin >> n >> m;
    if(m == 0) {
        if(n != 1) {
            cout << 1;
        }
        for(int i=0;i<max(1, n-1);++i) {
            cout << 0;
        }
        cout << endl;
        return 0;
    }
    int a[m], b[m];
    vector<bool> zero(n, false);
    for(int j=0;j<m;++j) {
        cin >> a[j] >> b[j];
        --a[j];
        if(b[j] == 0) zero[a[j]] = true;
    }
    {
        for(int j=0;j<m-1;++j) {
            if(!zero[j]) break;
            if(zero[j] && !zero[j+1]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    for(int j=0;j<m-1;++j) {
        for(int k=j+1;k<m;++k) {
            if(a[j] == a[k] && b[j] != b[k]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for(int i=0;i<1000;++i) {
        int d = 0, nn = i;
        while(nn) {
            nn /= 10;
            ++d;
        }
        if(d == 0) d = 1;
        if(d != n) continue;
        nn = i;
        int x[n];
        for(int j=n-1;j>=0;--j) {
            x[j] = nn % 10;
            nn /= 10;
        }
        bool ok = true;
        for(int j=0;j<m;++j) {
            if(x[a[j]] != b[j]) {
                ok = false;
                break;
            }
        }
        if(ok) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
def solve(h):
	best_p = abs(h[0] - h[1])
	best_pp = 0
	n = 2
	while n < len(h):
		cost1 = best_p + abs(h[n] - h[n-1])
		cost2 = best_pp + abs(h[n] - h[n-2])
		best = min(cost1, cost2)
		best_pp, best_p = best_p, best
		n = n + 1
	return best_p


def main():
	N = int(input())
	heights = list(map(int, input().split()))
	assert len(heights) == N
	assert N >= 2
	res = solve(heights)
	print(res)


if __name__ == '__main__':
	main()

Measured memory_bytes: 13980
#include <algorithm>
#include <cstdio>
#include <set>
#define ALL(x) (x).begin(), (x).end()
const int MAXM = 3e5+5;
std::multiset<int> here, next, prev;
int M, N, S;

bool solve() {
  auto big = here.begin();
  next.insert(*big);
  here.erase(big);
  for (int i = 0; i < N; ++i) {
    prev = std::move(next);
    for (auto j: prev) {
      auto ptr = here.upper_bound(j);
      if (ptr == here.end()) {
        return false;
      }
      next.insert(*ptr);
      here.erase(ptr);
    }
    next.insert(ALL(prev));
  }
  return true;
}

int main() {
  scanf("%d", &N);
  M = 1 << N;
  for (int i = 0; i < M; ++i) {
    scanf("%d", &S);
    here.insert(-S);
  }
  puts(solve() ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 18688
#include <iostream>

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  while (H != 0 && W != 0) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cin >> H >> W;
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3060
n,k,q = map(int,input().split())
l = [k]*n
z = [int(input()) for i in range(q)]
i=0
while i<q:
    l[z[i]-1] += 1
    i += 1
for i in range(len(l)):
    l[i]-=q
    if l[i]>=1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
vector<int> v[50];

void dfs(int pos, int pre, bool *used, int i, int j){
	for(int k = 0; k < v[pos].size(); ++k){
		if(pos == i && j == k) continue;
		if(v[pos][k] != pre && !used[v[pos][k]]){
			used[v[pos][k]] = 1;
			dfs(v[pos][k], pos, used, i, j);
		}
	}
}

int main(){
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int a, b; cin >> a >> b;
		--a; --b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans = 0;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < v[i].size(); ++j){
			bool used[n] = {1};
			dfs(0, -1, used, i, j);
			for(int k = 0; k < n; ++k){
				if(!used[k]){
					++ans;
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h.at(i);
	vector<int> o(n - 1);
	rep(i, n - 1) {
		if (h.at(i) < h.at(i + 1)) o.at(i) = 0;
		else o.at(i) = 1;
	}
	vector<int> a(n);
	a.at(0) = 0;
	rep(i, n - 1) {
		if (o.at(i)) a.at(i + 1) = a.at(i) + 1;
		else a.at(i + 1) = 0;
	}
	cout << *max_element(a.begin(), a.end()) << endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	while (cin >> n, n) {
		vector<char> vc(n);
		REP(i, n)
			cin >> vc[i];
		char ansc;
		int ansi=-1;
		vector<pair<int,char>> hyou(26);
		REP(i, 26)
			hyou[i].second = 'A' + i;
		REP(i, n) {
			hyou[vc[i]-'A'].first++;
			vector<pair<int, char>> hyouC = hyou;
			RSORT(hyouC);
			if (hyouC[0].first - hyouC[1].first - (n - i - 1) > 0) {
				ansi = i+1;
				ansc = hyouC[0].second;
				break;
			}

		}

		if (ansi == -1)
			cout << "TIE" << endl;
		else
			cout << ansc << " " << ansi << endl;

	}
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, k;std::cin >> n >> k;
  vvl dat = VV(n, 70, 0, ll); // 2**i の移動先
  for(int i=0;i<n;i++) {
    scanf("%lld", &dat[i][0]);
    dat[i][0]--;
  }
  for(int i=1;i<70;i++){
    for(int j=0;j<n;j++){
      ll to = dat[j][i-1];
      dat[j][i] = dat[to][i-1];
    }
  }
  vll t(63, 1);
  for(int i=1;i<63;i++) t[i] = t[i-1] * 2;

  ll now = 0;
  for(int i=62;i>=0;i--){
    if(k>=t[i]){
      //std::cout << now << " -> " << dat[now][i] << " cost" << t[i] << '\n';
      now = dat[now][i];
      k -= t[i];
    }
  }
  std::cout << now + 1 << '\n';
  return 0;
}


Measured memory_bytes: 120092
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define N 100000
const int MOD = 1000000007;

int main(void)
{
	char a[102] = { "\0" };
	int num = 0,i = 0;
	scanf("%s", a);
	num = strlen(a);
	for (i = 0; i < num; i++)
	{
		if (i != num - 1)
		{
			printf("x");
		}
		else
		{
			printf("x\n");
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll =int long long;
map <int ,int> mpa,mpb;

int main (void){
  int a,b,c,d;
  int dis1,dis2,dis3;
  cin >>a >> b>> c>> d;
  dis1=abs(c-a);
  dis2=abs(b-a);
  dis3=abs(c-b);
  if(dis1<=d){
    cout <<"Yes";
    return 0;
  }else if(dis2<=d && dis3<=d){
    cout <<"Yes";
    return 0;
  }
  else{
    cout <<"No";
    return 0;
  }
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
t = LI()
v = LI()

max_v = [0]*(N+1)  # 0秒後,t1秒後,t1+t2秒後,…の時点で出せる最大速度
for i in range(N-1):
    max_v[i+1] = min(v[i],v[i+1],max_v[i]+t[i])
for i in range(N-2,-1,-1):
    max_v[i+1] = min(max_v[i+1],v[i],v[i+1],max_v[i+2]+t[i+1])

ans = 0
for i in range(N):
    if t[i] >= (v[i]-max_v[i]) + (v[i]-max_v[i+1]):
        ans += t[i]*v[i]-(v[i]-max_v[i])**2/2-(v[i]-max_v[i+1])**2/2
    else:
        x = (t[i]+max_v[i]+max_v[i+1])/2
        ans += t[i]*x-(x-max_v[i])**2/2-(x-max_v[i+1])**2/2

print(ans)


Measured memory_bytes: 62400
#include <stdio.h>

int main(){

    int a;
    int b;

    scanf("%d %d",&a,&b);

    if(a < b){
        printf("a < b\n",a,b);       
    }else if(a > b){
        printf("a > b\n",a,b);
    }else{
        printf("a == b\n",a,b);
    }

    return 0;
}

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

long ans;
int n, m, x, skill[15][15];
vector<int> costs;

void subsequences(vector<int> arr, int index,  
                       vector<int> subarr) 
{ 
    // Print the subsequence when reach 
    // the leaf of recursion tree 
    if (index == arr.size()) 
    { 
        int len = subarr.size();
        if(len)//To not process empty subsequences
        {
            long algo[m] = {0}, cost = 0;
            int flag = 1;
    
            for (int i = 0; i < len; i++)
            {
                cost += costs[subarr[i]];
                for(int j = 0 ; j < m ; j++)
                    algo[j] +=  skill[subarr[i]][j];
            }

            for(int j = 0 ; j < m ; j++)
                if(algo[j] < x)
                {
                    flag = 0;
                    break;
                }

            if(flag)
                ans = cost < ans ? cost : ans;
        }
    } 
    else
    { 
        // Subsequence without including 
        // the element at current index 
        subsequences(arr, index + 1, subarr); 
  
        subarr.push_back(arr[index]); 
  
        // Subsequence including the element 
        // at current index 
        subsequences(arr, index + 1, subarr); 
    } 
    return; 
} 

int main()
{
    vector<int> arr;
    scanf("%d %d %d",&n, &m, &x);
    
    for(int i = 0 ; i < n ; i++)
    {
        int ci;
        scanf("%d", &ci);
        costs.push_back(ci);
        arr.push_back(i);
        for(int j = 0 ; j < m ; j++)
            scanf("%d",&skill[i][j]);
        //printf("\n");
    }
    
    ans = LONG_MAX;
    //printf("%ld",ans);
    vector<int> b; 
    subsequences(arr, 0, b); 
    
    ans = (ans == LONG_MAX) ? -1 : ans;
    printf("%ld",ans);
    
    return 0;
  
}


Measured memory_bytes: 3792
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
 
int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
 
int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}
 
int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
 
int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/
 
signed main(void){
  int x;
  cin>>x;
  if(x>=400 && x<600) cout<<"8"<<endl;
  else if(x>=600 && x<800) cout<<"7"<<endl;
  else if(x>=800 && x<1000) cout<<"6"<<endl;
  else if(x>=1000 && x<1200) cout<<"5"<<endl;
  else if(x>=1200 && x<1400) cout<<"4"<<endl;
  else if(x>=1400 && x<1600) cout<<"3"<<endl;
  else if(x>=1600 && x<1800) cout<<"2"<<endl;
  else cout<<"1"<<endl;
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>

char str[8192];
int length;
std::vector<char*> table(8192);

struct Info {
	int start, length;
};

int find_diff(int);

int main()
{
	int k;
	Info ans[5]{};

	scanf("%s", str);
	for (int i = 0; str[i] != '\0'; ++i)
	{
		table[i] = str + i;
		length = i;
	}
	length++;
	scanf("%d", &k);

	std::sort(table.begin(), table.begin() + length,
		[](const char* l, const char* r) {return strcmp(l, r) < 0; }
	);

	ans[0] = Info({ 0, 0 });
	for (int i = 1; i < k; ++i)
	{
		if (table[ans[i - 1].start] + ans[i - 1].length + 1 < str + length)
		{
			ans[i].start = ans[i - 1].start;
			ans[i].length = ans[i - 1].length + 1;
		}
		else
		{
			ans[i].start = ans[i - 1].start + 1;
			ans[i].length = find_diff(ans[i - 1].start);
		}
	}

	for (int i = 0; i <= ans[k - 1].length; ++i)
	{
		printf("%c", table[ans[k - 1].start][i]);
	}
	printf("\n");

	return 0;
}

int find_diff(int pre)
{
	for (int i = 0;; ++i)
	{
		if (table[pre][i] != table[pre + 1][i]) return i;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

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



int main()
{
	int n;
	
	while(cin >> n,n)
	{
		int w,h,s,t,ret = 0;
		int x[n+1],y[n+1];
		cin >> w >> h;
		
		REP(i,n)
		{
			cin >> x[i] >> y[i];;
		}
		
		cin >> s >> t;
		
		REP(i,w)REP(j,h)
		{
			int tmp = 0;
			int ux = i + 1,uy = j + 1;
			int tx = i + s,ty = j + t;
			if(tx > w || ty > h)continue;
			REP(a,n)
			{
				if(x[a] >= ux && x[a] <= tx && y[a] >= uy && y[a] <= ty)tmp++;
			}
			
			ret = max(ret,tmp);
			
		}

		
		cout << ret <<endl;
		
		
			
	}
	
	return 0;
}

Measured memory_bytes: 2988
n,m,c=map(int,input().split())
b=[int(i) for i in input().split()]
a=[]
for i in range(n):
    a.append([int(i) for i in input().split()])
#print(n,m,c)
#print(b)
#print(a)
#print("----------")
s=[]
for i in range(n):
    s.append(0)
    for j in range(m):
        s[i]+=a[i][j]*b[j]
        #print(s)
    s[i]+=c
#print(s)

count=0
for i in s:
    if i>0:
        count+=1
print(count)






Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iterator>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int M, N, tmp;
    ll s=0;
    cin >> N >> M;
    string ans;
    vector<int> a(N);

    REP(i, N){
        cin >> tmp;
        a.push_back(tmp);
        s+=tmp;
    }
    sort(a.begin(), a.end(), std::greater<int>());
    if(a[M-1] < (float)s/(4*M)) ans = "No";
    else ans = "Yes";

    // REP(i, N) cout << a[i] << endl;

    // cout << s << endl;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

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

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;
vector<vector<bool>> used;
vector<ll> d;

int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    ll all = 0;
    for (int i = 0; i < n / 2ll; ++i)
    {
        ll t = a[2 * i] ^ a[2 * i + 1];
        all ^= t;
    }
    
    for (int i = 0; i < n; ++i)
    {
        cout << (all ^ a[i]);
        if (i == n - 1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
    
    return 0;
}

Measured memory_bytes: 4728
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int num[7];
int main(void){
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		memset(num,0,sizeof(num));
		for(int i=0;i<n;i++){
			int a;
			scanf("%d",&a);
			if(a>60)a=60;
			num[a/10]++;
		}
		for(int i=0;i<=6;i++)printf("%d\n",num[i]);
	}
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 1; i < n; i++) {
		if (v[i] < v[i - 1]) {
			cout << "No" << endl;
			return 0;
		}
		if (v[i] > v[i - 1]) v[i]--;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3776
import java.util.*

fun main(args: Array<String>) {
    val S = readLine()!!
    val T = readLine()!!

    if (S == T) {
        println("Yes")
        return
    }

    val s = ArrayDeque<Char>(S.toCharArray().toList())
    repeat(S.length - 1) {
        s.addFirst(s.removeLast())
        if (s.joinToString("") == T) {
            println("Yes")
            return
        }
    }
    println("No")
}


Measured memory_bytes: 35980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){

    int n, k;
    cin >> n >> k;

    vector<double> p(n+1, 1); 
    for(int i = 1; i <= n; i++){
        int tmp = i;
        while(tmp < k){
            tmp *= 2;
            p[i] *= 0.5;
        }
    }
    double ans = 0;
    for(int i = 1; i <= n; i++){
        ans += p[i];
    }
    printf("%.12lf", ans/n);
    
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
tmp = input().split(" ")
l = [int(i) for i in tmp]
ans = 1
ll = list()
ll.append(l[0])
for i in range(1,N):
    ll.append(min(ll[i-1],l[i]))
for i in range(1,N):
  if ll[i-1] > l[i]:
    ans+=1
print(ans)


Measured memory_bytes: 27304
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int a, b; cin >> a >> b;
	cout << max({ a + b, a - b, a*b }) << endl;
	return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n,m int
	fmt.Scan(&n,&m)
	
	sum,days := 0,0
	for i := 0; i < m; i++ {
		fmt.Scan(&days)
		sum += days
	}
	if sum > n {
		fmt.Println("-1")
	} else {
		fmt.Println(n - sum)
	}
}

Measured memory_bytes: 2376
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx = INT_MAX;
ll mn = INT_MIN;
ll INF = 1e18+10;
ll MOD = 1e9+7;
const ll maxs = 3e5+5;
const ll lg = 22; 
ll fast(ll base , ll expo){ ll res = 1; while(expo>=1){ if(expo%2) res *= base; base *= base; expo /= 2; } return res; }

void code_idhr_h(){
    ll N; cin>>N;
    ll A[N+1]; ll ans = 0;
    for(ll i=1; i<=N; i++) {
        cin>>A[i];
        if(i%2 and A[i]%2) ans++;
    }
    cout<<ans;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

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

int main()
{
	ll N, K;

	cin >> N >> K;

	ll a = N % K;
	cout << min(a, abs(a - K)) << endl;

	return 0;
}


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

int main(){
  string S;
  cin >> S;
  bool count = false;
  for(int i = 1; i < 4; i++){
    if(S.at(i - 1) == S.at(i))count = true;
  }
  if(count == false)cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n;
    cin >>n;
    ll p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p,p+n);
    ans=p[n/2]-p[n/2-1];
    
    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,l,ans=0,mi=1e9,cnt;
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;++i){
		int now=l+i-1;
		if(abs(now)<mi)mi=abs(now),cnt=now;
		ans+=now;
	}
	printf("%d",ans-cnt);
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  int a, b, c, t = 0;
  cin >> a >> b >> c;
  bool flag = true;
  REP(i, 10000000) {
    if(flag) {
      if(t <= c && c <= t+a) {
        cout << c << endl;
        return 0;
      }
      t += a;
      flag = false;
    } else {
      t += b;
      if(t >= c) c += 60;
      flag = true;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3080
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
using namespace std;
int main(){
	int N;
	cin >> N;
	string s;
	int res[256];
	memset(res, 0, sizeof(res));
	for(int i=0;i<N;++i)
	{
		cin >> s;
		res[s[0]]++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", res['A'], res['W'], res['T'], res['R']);
	return 0;
}


Measured memory_bytes: 3716
import math

n,k=map(int,input().split())

A=list(map(int,input().split()))

x=sum(A)

X=[]

for i in range(1,int(math.sqrt(x))+1):
    if x%i==0:
        X.append(i)
        X.append(x//i)
X.sort(reverse=True)

for i in X:
    B=[]
    for j in range(n):
        B.append(A[j]%i)
    B.sort()
    if sum(B[:-1*(sum(B)//i)])<=k:
        print(i)
        break

Measured memory_bytes: 3064
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {
	static double cnt = 0;
	static int count = 0;
	static double[][] dist;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[][] pos = new int[n][2];
		for (int i = 0; i < n; i++) {
			pos[i][0] = sc.nextInt();
			pos[i][1] = sc.nextInt();
		}
		dist = new double[n][n];
		for (int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				int x1 = pos[i][0],  x2 = pos[j][0] , y1 = pos[i][1] ,y2 = pos[j][1];
				int X = (x1-x2) * (x1-x2), Y = (y1-y2) * (y1-y2);
				double d = Math.sqrt( X+Y );
				dist[i][j] = d;
			}
		}
		
		int[] list = new int[n];
		for(int i = 0; i < n; i++)
			list[i] = i + 1;	
		permutation(list);
		double ans = cnt / count;
		out.print(ans);
		
	}
    static void permutation(int[] seed) {
        int[] perm = new int[seed.length];
        boolean[] used = new boolean[seed.length];
        buildPerm(seed, perm, used, 0);
    }

     static void buildPerm(int[] seed, int[] perm, boolean[] used, int index) {
        if (index == seed.length) {
            procPerm(perm);
            return;
        }

        for (int i = 0; i < seed.length; ++i) {
            if (used[i]) continue;
            perm[index] = seed[i];
            used[i] = true;
            buildPerm(seed, perm, used, index + 1);
            used[i] = false;
        }
    }

    static void procPerm(int[] perm) {
    	count++;
        for (int i = 0; i < perm.length - 1; i++) {
        	int a = perm[i], b = perm[i + 1];
        	cnt += dist[a - 1][b - 1];
        	//out.println(a + " → " + b + ": " + dist[a-1][b-1]);
        }
    }
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int h, w;
    cin >> h >> w;

    char s[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    int next_h, next_w;
    int move_h[] = {-1, -1, 0, 1, 1, 1,  0, -1};
    int move_w[] = { 0, 1, 1, 1, 0, -1, -1, -1};
    int cnt[h][w];
    bzero(cnt, sizeof(cnt));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < 8; k++) {
                next_h = i + move_h[k];
                next_w = j + move_w[k];

                if (0 <= next_h && next_h < h && 0 <= next_w && next_w < w) {
                    if (s[next_h][next_w] == '#') cnt[i][j]++;
                }
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') cout << '#';
            else cout << cnt[i][j];
        }
        cout << endl;
    }
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll N, sum_0 = 0;
    cin >> N;
    vector<ll> num(100001);
    for ( ll i = 0; i < N; i++ ) {
        ll a;
        cin >> a;
        sum_0 += a;
        num[a] ++; //数字が何個あるかカウントする
    }
    ll Q;
    cin >> Q;
    for ( ll i = 0; i < Q; i++ ) {
        ll b,c, dif;
        cin >> b >> c;
        dif = c - b;
        sum_0 += num[b] * dif;
        num[c] += num[b]; //bを全てcに変換しているのでbの数だけカウント数増やす
        num[b] = 0; //カウント数を0に
        cout << sum_0 << endl;
    }
}

Measured memory_bytes: 4020
#include <iostream>

//n : n????????°???????¶?????????§
//s : ?????????s?????????
int n, s; // 3 1
int ans;

void dfs(int a, int sum, int bmax) {
	if(a < n) {
			for(int i = bmax; i <= 9; ++i) {
				if(sum + i <= s)
					dfs(a + 1, sum + i, i + 1);
			}
	}
	else if(a == n) {
		if(s == sum)
			++ans;
	}
}

int main() {
	while(std::cin >> n >> s, !(n == 0 && s == 0)) {
		dfs(0, 0, 0);
		
		std::cout << ans << std::endl;
		
		ans = 0;
	}
}

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

int main() {
int a,b,c,i;
cin>>i;
for(int n=0; n<i; n++){
cin>>a>>b>>c;


if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a) {cout<<"YES"<<endl;}
else{cout<<"NO"<<endl;}	
}

// your code goes here
	return 0;
}

Measured memory_bytes: 1152
from queue import Queue
n, m = map(int, input().split())
adj = [[] for i in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)
parents = [None] * (n+1)
parents[1] = 0
parents[0] = 0
def bfs():
    q = Queue()
    q.put(1)
    while not q.empty():
        u = q.get()
        for v in adj[u]:
            if parents[v] is None:
                parents[v] = u
                q.put(v)
bfs()     
#print(parents)
if None in parents:
    print("No")
else:
    print("Yes")
    for i in range(2, n+1):
        print (parents[i])

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

int main() {
    set<int> se;
    int n, a;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        se.insert(a);
    }
    cout << se.size();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
   int A1,A2,A3,n;

   scanf("%d %d %d",&A1,&A2,&A3);
   if(1<=A1 && A1<=13 && 1<=A2 && A2<=13 && 1<=A3 && A3<=13){
    n=A1+A2+A3;
    if(n>=22){
        printf("bust");
    }
    else{
        printf("win");
    }
   }

   }



Measured memory_bytes: 128
#include <stdio.h>
int main(void){
  int a,b,c,i;
  int x,y,z;
  scanf("%d %d %d",&x,&y,&z);
  a=x;
  b=y;
  c=z;
  i=a;
  a=b;
  b=i;
  i=a;
  a=c;
  c=i;
  printf("%d %d %d",a,b,c);
  return 0;
}

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

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

    for (int i = 0; i < N; i++) {
        string s[2]; cin >> s[0] >> s[1];

        int n[2]= {0,0};
        for (int i = 0; i <2;i++ ) {
            char prev = '1';
            for (auto x : s[i]) {
                switch (x) {
                case 'm':
                    n[i] += (prev - '0')*1000;
                    prev = '1';
                    break;
                case 'c':
                    n[i] += (prev - '0')*100;
                    prev = '1';
                    break;
                case 'x':
                    n[i] += (prev - '0')*10;
                    prev = '1';
                    break;
                case 'i':
                    n[i] += (prev - '0')*1;
                    prev = '1';
                    break;
                default:
                    prev = x;
                    break;
                }
            }
        }

        n[0] += n[1];

        if (n[0] / 1000 >= 2) {
            cout << n[0]/1000;
        }
        if (n[0] / 1000 >= 1) {
            cout << 'm';
        }
        n[0] %= 1000;

        if (n[0] / 100 >= 2) {
            cout << n[0]/100;
        }
        if (n[0] / 100 >= 1) {
            cout << 'c';
        }
        n[0] %= 100;

        if (n[0] / 10 >= 2) {
            cout << n[0]/10;
        }
        if (n[0] / 10 >= 1) {
            cout << 'x';
        }
        n[0] %= 10;

        if (n[0] >= 2) {
            cout << n[0];
        }
        if (n[0] >= 1) {
            cout << 'i';
        }
        cout << endl;

    }
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> a = vector<int>(N);
	for(int i=0;i<N;i++){
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());

	int answer = 100000000000;
	int tmp;

	for(int x=a.at(0);x<=a.at(N-1);x++){
		tmp = 0;
		for(auto num : a){
			tmp += (num - x) * (num - x);
		}
		if(answer > tmp){
			answer = tmp;
		}
	}

	cout << answer << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int i=0;
	long long int N;
	string S="";
	cin>>N;
	while(N>0){
		N--;
		S[i]=(char)('a'+N%26);
		N/=26;
		i++;
	}
	for(int j=i-1;j>=0;j--)cout<<S[j];
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;


int main(){
  long double max,x;
  long long yokin;
  cin >> x;
  yokin = 100;
  max = pow(10,18);
  
  for (int i=1; i<max; i++){
    //yokin  = floor(yokin*1.01);
    yokin += yokin/100;
    if (yokin >= x){
      cout << i;
      break;
    }
  }
}

Measured memory_bytes: 3668
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()

j = dict()
j['AC']=0
j['WA']=0
j['TLE']=0
j['RE']=0
for i in range(n):
  s=input()
  j[s]+=1

print('AC x {}'.format(j['AC']))
print('WA x {}'.format(j['WA']))
print('TLE x {}'.format(j['TLE']))
print('RE x {}'.format(j['RE']))


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

typedef long long s64;
const s64 U=1e16+100;
#define rep(i,l,r) for(int i=l;i<=r;++i)
s64 a[55];

int main()
{
	s64 k;
	cin>>k;
	int n=50;
	s64 l=k/(n+1),r=(k+U)/(n+1);
	cout<<n<<endl;
	s64 s=k;
	rep(i,1,n)
	{
		s64 x=min(r,s-(n-i)*l);
		cout<<x*(n+1)-k+n-1<<" ";
		s-=x;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 2000001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,n,m,m1,m2,n1,n2,o,p1,p2,p3,p4,
q1,q2,q3,q4,r,s,t,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,cnt,lim;

vector<L>Graph[Mx];
L distance_[Mx],dir[Mx];

struct info{
    L u,dist;
    info(L _u, L _dist){
        u = _u;
        dist = _dist;
    }
    bool operator < ( const info& p ) const {
          return dist > p.dist;   
    }
};
void dijstkra(){
    for(L i=1;i<=n;i++) {
        distance_[i] = inf;
    }
    priority_queue<info>q;
    q.push(info(1,0));
    distance_[1] = 0;
    while(!q.empty()){
        info top = q.top();
        q.pop();
        L u=top.u;
        lim=Graph[u].size();
        for(L i=0;i<lim;i++){
            L v=Graph[u][i];
            if(distance_[u] + 1 < distance_[v]){
                distance_[v] = distance_[u] + 1;
                dir[v]=u;
                q.push(info(v, distance_[v]));
            }
        }
    }
    for(L i=2;i<=n;i++){
        if(distance_[i]==inf){
            printf("No\n");
            return ;
        }
    }
    printf("Yes\n");
    for(L i=2;i<=n;i++){
        printf("%lld\n",dir[i]);
    }
}
int main()
{
    L u,v;
    scanf("%lld%lld",&n,&m);
    for(L i=0;i<m;i++){
        scanf("%lld%lld",&u,&v);
        Graph[u].push_back(v);
        Graph[v].push_back(u);
    }
    dijstkra();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 59568