akhauriyash/Code-Regression huggingface dataset:
#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); }
};

vi ask(vi num) {
	vi res;
	int a = -1;
	REP(i, num.size()) {
		if (num[i]!=a) {
			res.push_back(num[i]);
		}
		a = num[i];
	}
	
	while (!(res.size() == 1 && res[0] == 0) && res[res.size() - 1] == 0)
		res.erase(res.begin() + res.size() - 1);
	return res;
}

struct st{
	vi num;
	int cnt;
};

int main() {
	int n;
	while (cin >> n, n) {
		string a, b;
		cin >> a >> b;
		vi sub;
		REP(i, n) {
			sub.push_back((a[i] - b[i]+10) % 10);
		}
		sub = ask(sub);
		map<vi, int> G;
		G[sub] = 0;
		queue<st> Q;
		Q.push({sub,0});
		int ans = 0;
		while (!Q.empty()) {
			st q = Q.front();Q.pop();
			if (q.num.size()==1&&q.num[0]==0) {
				ans = q.cnt;
				break;
			}
			int num2= q.num[0];
			REP(i, q.num.size()){
				vi vq = q.num;
				REP(j, i + 1) {
					vq[j] = (vq[j] - num2 + 10) % 10;
					vi vq2 = ask(vq);
					if (G.find(vq2) == G.end() || G[vq2]>q.cnt + 1) {
						G[vq2] = q.cnt + 1;
						Q.push({ vq2,q.cnt + 1 });
					}
				}
			}
			num2 = q.num[q.num.size() - 1];
			REP(i, q.num.size()) {
				vi vq = q.num;
				REP(j, i + 1) {
					vq[vq.size() - 1 - j] = (vq[vq.size() - 1 - j] - num2 + 10) % 10;
					vi vq2 = ask(vq);
					if (G.find(vq2) == G.end() || G[vq2]>q.cnt + 1) {
						G[vq2] = q.cnt + 1;
						Q.push({ vq2,q.cnt + 1 });
					}
				}
			}
		}
		cout << ans << endl;
	}
}

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

int main()
{
	int n,k;
	string s;
	scanf("%d%d",&n,&k);
	cin >> s;
	int len = s.size();
	
	int sum = 0,sk = 0;
	for(int i = 1;i < len;i++){
		if(s[i-1] == s[i]) sum++;
		if(s[i] != s[i-1] && s[i-1] == s[0]) sk++;
	}
	
	if(k < sk) sum += k*2;
	else if(k == sk){
		if(s[len-1] == s[0]) sum += k*2;
		else sum += (k-1)*2+1;
	}
	else sum = len-1;
	
	printf("%d\n",sum);
	return 0;
}

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

int main(void)
{
  char c;
  
  scanf("%c", &c);
  
  if (c == 'A'){
    printf("T");
  } else if(c == 'T'){
    printf("A");
  } else if (c == 'C'){
    printf("G");
  } else {
    printf("C");
  }
 
  
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
	int N,i;
	int count=0;
	int a[3];
	scanf("%d ",&N);
	while(count!=N){
	for(i=0;i<3;i++){
		scanf("%d ",&a[i]);
	}
	sort(a,a+3);
	if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1]){
		printf("YES\n");
		count++;
	}
	else{
		printf("NO\n");
		count++;
	}
	}
	return 0;
	}

Measured memory_bytes: 1028
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>

#define int ll
//#define double long double
//#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.14159265358979

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 7e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/

template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}

template <class T>
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}

inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
}

vector <vector <int>> g;
vector <int> used, ts;
void dts(int v)
{
    used[v] = true;
    for (auto &to : g[v])
        if (!used[to])
            dts(to);
    ts.pb(v);
}
vector <int> dp;
void dfs(int v)
{
    used[v] = true;
    dp[v] = 0;
    for (auto &to : g[v])
    {
        if (!used[to])
            dfs(to);
        dp[v] = max(dp[v], dp[to] + 1);
    }
}

signed main()
{
    Start();
    string s;
    cin >> s;
    int n = s.size();
    g.resize(n + 1);
    for (int i = 0; i < n; ++i)
    {
        if (s[i] == '>')
            g[i].pb(i + 1);
        else
            g[i + 1].pb(i);
    }
    used.resize(n + 1);
    for (int i = 0; i < n + 1; ++i)
    {
        if (!used[i])
            dts(i);
    }
    reverse(all(ts));
    used.assign(n + 1, 0);
    dp.assign(n + 1, 0);
    for (auto &v : ts)
    {
        if (!used[v])
            dfs(v);
    }
    int ans = 0;
    for (auto &i : dp)
        ans += i;
    cout << ans;
    return 0;
}



Measured memory_bytes: 55056
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;
 
int main(void)
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (a + b > c + d)
	{
		cout << "Left" << '\n';
	}
	else if (a + b == c + d)
	{
		cout << "Balanced" << '\n';
	}
	else
	{
		cout << "Right" << '\n';
	}

	return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (b <= a) cout << "delicious" << endl;
  else if (b <= a + x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}



Measured memory_bytes: 256
def dis(d, x, y):
    a = 0
    for i in range(d):
        a += (x[i] - y[i])**2
    return a**0.5
    
n, d = map(int,input().split())
#print(n,d)

l = []
for j in range(n):
    l.append(input().split())

c=[]
for j in l:
    b=[]
    for k in j:
        b.append(int(k))
    c.append(b)
#print(c)

z = []
for e in range(n):
    for f in range(e,n):
        g = dis(d, c[e], c[f])
        if g == int(g) and g != 0:
            z.append(g)
print(len(z))




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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> k(m);
    int s[11][11];
    vector<int> p(m);
    //入力
    for (int i=0;i<m;i++){
        cin >> k.at(i);
        for (int j=0;j<k.at(i);j++){
            int tmp;
            cin >> tmp ;
            tmp--;
            s[i][j] =tmp;
        }
    }    
    for (int i=0;i<m;i++){
        cin >> p.at(i);
    }
    int ans_cnt=0;
    //スイッチの状態を全列挙
    for (int bit=0;bit<(1<<n);bit++){
        int cnt=0;
        vector<bool> sw(n);
        //スイッチの状態(onかoffか)
        for (int i=0;i<n;++i){
            if(bit & (1<<i)){
                sw.at(i) = true;
            }
        }
        //電球jについて
        for (int j=0;j<m;j++){
            int s_cnt=0;
            //電球とつながってるスイッチを確認
            for(int l=0;l<k.at(j);l++){
                if(sw[s[j][l]]) s_cnt++;
            }
            if((s_cnt % 2) == p.at(j)) {
                cnt++;
                continue;
            }
            else break;
            
        }
        if( cnt == m )
            ans_cnt++;
    }
    cout << ans_cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl; 
#define De(...)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
using namespace std; 

int _; 

int n,q,a[100050],b[100050],c[100050],cnt[100050];
long long sum=0;

int main()
{
	//for(scanf("%d",&_);_;_--)
	for(int i=0;i<100050;i++)
		cnt[i]=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		sum += a[i];
		cnt[a[i]]++;
	} 
	scanf("%d",&q);
	for(int i=0;i<q;i++)
		scanf("%d%d",b+i,c+i);
	for(int i=0;i<q;i++)
	{
		sum += (c[i]-b[i])*cnt[b[i]];
		cnt[c[i]] += cnt[b[i]];
		cnt[b[i]]=0;
		printf("%lld\n",sum);
	}
	return 0;
}


Measured memory_bytes: 5280
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
struct Fenwick
{
	vector<lli> bit;
	int n;
	Fenwick(int n)
	{
		this->n = n;
		bit.assign(n, 0);
	}
	Fenwick(vector<lli> a): Fenwick((int)a.size())
	{
		for (int i = 0; i < (int)a.size(); ++i)
			add(i, a[i]);
	}
	lli sum(int idx)
	{
		lli res = 0ll;
		for (; idx >= 0; idx = (idx & (idx + 1)) - 1)
			res += bit[idx];
		return res;
	}
	lli sum(int l, int r)
	{
		return sum(r) - sum(l - 1);
	}
	void add(int idx, int delta)
	{
		for (; idx < n; idx = idx | (idx + 1))
			bit[idx] += delta;
	}
};
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, q = 0, ch = 0, p = 0, l = 0, r = 0; lli x = 0ll;
	cin >> n >> q;
	vector<lli> a(n);
	for (auto &i : a)
		cin >> i;
	Fenwick v(a);
	for (int i = 0; i < q; ++i)
	{
		cin >> ch;
		if (ch == 0)
		{
			cin >> p >> x;
			v.add(p, x);
		}
		else
		{
			cin >> l >> r;
			cout << v.sum(l, r - 1) << "\n";
		}
	}
}

Measured memory_bytes: 15080
#include <stdio.h>

#define KI_MAX (1 << 18) /* 262144 */

int ki[KI_MAX * 2 - 1];

void ki_set(int idx, int value) {
	int pos = idx + (KI_MAX - 1);
	ki[pos] = value;
	do {
		int a, b;
		pos = (pos - 1) / 2;
		a = ki[pos * 2 + 1];
		b = ki[pos * 2 + 2];
		ki[pos] = a >= b ? a : b;
	} while (pos > 0);
}

int ki_get_i(int idx, int qs, int qe, int ss, int se) {
	if (qe <= ss || se <= qs) { /* 完全に外れている */
		return -114514;
	} else if (qs <= ss && se <= qe) { /* セグメントがクエリに完全に含まれる */
		return ki[idx];
	} else {
		int sm = ss + (se - ss) / 2;
		int left = ki_get_i(idx * 2 + 1, qs, qe, ss, sm);
		int right = ki_get_i(idx * 2 + 2, qs, qe, sm, se);
		return left >= right ? left : right;
	}
}

int ki_get(int qs, int qe) {
	return qs < qe ? ki_get_i(0, qs, qe, 0, KI_MAX) : -114514;
}

int main(void) {
	int N, Q;
	int i;
	if (scanf("%d%d", &N, &Q) != 2) return 1;
	for (i = 1; i <= N; i++) {
		int A;
		if (scanf("%d", &A) != 1) return 1;
		ki_set(i, A);
	}
	ki_set(N + 1, 1010101010);
	for (i = 0; i < Q; i++) {
		int T, hoge, fuga;
		if (scanf("%d%d%d", &T, &hoge, &fuga) != 3) return 1;
		switch(T) {
			case 1:
				ki_set(hoge, fuga);
				break;
			case 2:
				printf("%d\n", ki_get(hoge, fuga + 1));
				break;
			case 3:
				{
					int no = hoge - 1, yes = N + 1;
					while (no + 1 < yes) {
						int mid = no + (yes - no) / 2;
						if (ki_get(hoge, mid + 1) >= fuga) yes = mid; else no = mid;
					}
					printf("%d\n", yes);
				}
				break;
		}
	}
	return 0;
}


Measured memory_bytes: 3280
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	int ans = 0;
	VI bi[20];
	
	REP(i, N) {
		REP(j, 20) {
			if (A[i] & (1 << j))bi[j].push_back(i);
		}
	}
	REP(j, 20) {
		bi[j].push_back(N);
		bi[j].push_back(N);
	}

	REP(L, N) {
		int R = INF;

		REP(j, 20) {
			auto it = UB(bi[j], L);
			if (A[L] & (1 << j)) {
				
			}
			else {
				it++;
			}
			chmin(R, *it);
		}



		ans += R - L;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 21060
import sys
input = sys.stdin.readline
from itertools import permutations

H, W = [int(x) for x in input().split()]
c = []
for _ in range(10):
    c.append([int(x) for x in input().split()])
A = []
for _ in range(H):
    A.append([int(x) for x in input().split()])

cost = []
for i in range(10):
    tmp = 10 ** 10
    factor = [int(x) for x in range(10) if x != i]
    per = list(permutations(factor))
    for j in per:
        a = [i] + list(j)
        cnt = 0
        for k in range(9):
            if a[k + 1] != 1:
                cnt += c[a[k]][a[k + 1]]
            else:
                cnt += c[a[k]][a[k + 1]]
                tmp = min(tmp, cnt)
                break
    cost.append(tmp)
ans = 0
for i in A:
    for j in i:
        if j != 1 and j != -1:
            ans += cost[j]
print(ans)





    



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

int main() { 
    int n, k;
    double sum = 0, ma = 0;
    cin >> n >> k;
    int p[n];
    double a[n];   
    for(int i = 0; i < n; ++i) cin >> p[i];
    for(int i = 0; i < n; ++i) {
        a[i] = (p[n-i-1]*(p[n-i-1]+1))/2.0/p[n-i-1];
    }
    for(int i = 0; i < n; ++i) {
        if(i < k) {
            sum += a[i];
        } else {
            sum += a[i];
            sum -= a[i-k];
        }
        ma = max(sum, ma);
    }
    printf("%20.10lf\n", ma);

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#include <map>
//#include <set>
//#include <list>
//#include <cmath>
//#include <ctime>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <string>
//#include <bitset>
//#include <cstdio>
//#include <limits>
//#include <vector>
//#include <climits>
//#include <cstring>
//#include <cstdlib>
//#include <fstream>
//#include <numeric>
//#include <sstream>
//#include <iomanip>
//#include <iostream>
//#include <algorithm>
//#include <unordered_map>

using namespace std;

#define file freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.141592653589793238462643383279502884
#define MAX 1000100
#define mod 1000000007
#define EPS 1E-9
#define int long long
#define endl "\n"

int fix(int cur, int m)
{
    return ((cur%m) + m) % m;
}

int fast_power(int x, int y,int m)
{
    if (y == 0)
        return 1;
    int temp = fast_power(x, y / 2, m) ;
    temp = (temp*temp)% m;
    if (y % 2 != 0)
        temp = (temp*x)% m;
    return temp;

}


int32_t main()
{
    //freopen("D:/Important Files/Cocktail/SOLVE/TestLib/testcases/input/input11.txt", "r", stdin);
    //freopen("D:/Important Files/Cocktail/SOLVE/TestLib/testcases/output/output11.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.tie(0);

    string s,t;
    int a,b;
    map<string,int>mp;
    cin >> s >> t;
    cin >> a >> b;
    mp[s]=a;
    mp[t]=b;
    string u;
    cin >> u;
    mp[u]--;
    cout << mp[s] << " " << mp[t] << endl;




    return 0;
}


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

#define MOD 1000000007

int N, M;
vector<bool> issafe;

int main() {
  cin >> N >> M;  
  issafe.assign(N+1, true);
  for (int i = 0; i < M; i++) {
    int a; cin >> a;
    issafe[a] = false;
  }
  
  vector<int> dp(N+1, 0);
  dp[0] = 1;
  if (issafe[1]) dp[1] = 1;

  for (int i = 2; i <= N; i++) {
    if(issafe[i-1]) dp[i] += dp[i-1];
    if(issafe[i-2]) dp[i] += dp[i-2];
    dp[i] %= MOD;
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long int a,b;
    scanf("%lld %lld",&a,&b);
    if(a==1&&b==1) printf("1");
    else if(a==1)
        printf("%lld",b-2);
    else if(b==1)
        printf("%lld",a-2);
    else
        printf("%lld",(a-2)*(b-2));
    return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            out.print((n - a) % b);
        }

    }
}



Measured memory_bytes: 19924
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;

int dp[201][201][201];
int calc(int a){
	if(a<0) return a*-1;
	else return a;
}

int main(){
	for(int i=0; i<201; ++i){
		for(int j=0; j<201; ++j){
			for(int k=0; k<201; ++k){
				dp[i][j][k]=0;
			}
		}
	}
	int D,N,ans=0;
	cin >> D >> N;
	vector<int> temp(D+1);
	vector<int> c1(N);
	vector<int> c2(N);
	vector<int> c3(N);
	for(int i=1; i<=D; ++i){
		cin >> temp[i];
	}
	for(int i=0; i<N; ++i){
		int a,b,c;
		cin >> a >> b >> c;
		c1[i]=a;
		c2[i]=b;
		c3[i]=c;
	}
	for(int i=0; i<N; ++i){
		if(c1[i]<=temp[2]&&temp[2]<=c2[i]){
			for(int j=0; j<N; ++j){
				if(c1[j]<=temp[1]&&temp[1]<=c2[j]){
					dp[2][i][j]=calc(c3[i]-c3[j]);
				}
			}
		}
	}
	for(int i=3; i<=D; ++i){
		for(int j=0; j<N; ++j){
			if(c1[j]<=temp[i]&&temp[i]<=c2[j]){
				for(int k=0; k<N; ++k){
					if(c1[k]<=temp[i-1]&&temp[i-1]<=c2[k]){
						for(int l=0; l<N; ++l){
							if(c1[l]<=temp[i-2]&&temp[i-2]<=c2[l]){
								dp[i][j][k]=max(dp[i][j][k],dp[i-1][k][l]+calc(c3[j]-c3[k]));
							}
						}
					}
				}
			}
		}
	}
	for(int i=0; i<N; ++i){
		for(int j=0; j<N; ++j){
			ans=max(ans,dp[D][i][j]);
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 32924
n = int(input())
abba = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
    top = int(str(i)[0])
    btm = i % 10
    abba[top][btm] += 1
cnt = 0
for i in range(10):
    for j in range(10):
        cnt += abba[i][j] * abba[j][i]
print(cnt)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main()
{
    double m,M,c=0,sum=0;
    int N,i;
    scanf("%d %lf",&N,&M);
    m=1/(4*M);
    double arr1[N],arr2[N];
    for(i=0;i<N;i++)
    {
        scanf("%lf",&arr1[i]);
        sum=sum+arr1[i];
    }
    for(i=0;i<N;i++)
    {
        arr2[i]=(arr1[i])/(sum);
        if(arr2[i]>=m)
        {
            c++;
        }
        else
        {
            continue;
        }
    }
    if(c>=M)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;

}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll X;

int main()
{
    cin >> X;

    ll M = 100;
    ll ans = 0;
    while (true) {
        ans++;
        M = M * 1.01;
        if (M >= X) {
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
n,m,c = map(int,input().split())
li = list(map(int,input().split()))
count = 0
total = 0
for i in range(n):
    nli = list(map(int,input().split()))
    for j in range(m):
        total += li[j] * nli[j]
    if total + c > 0:
        count += 1
    total = 0
print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))




int main(void)
{
	//変数の宣言
	int n;
	int a[110];
	int iro[10];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	llong int ans=0;
	int count=0;
	int sum=0;
	long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<10;i++){
		iro[i]=0;
	}
	
	for(i=0;i<n;i++){
		temp=a[i]/400;
		if(temp<=7){
			iro[temp]++;
		}else{
			iro[9]++;
		}
	}
	
	for(i=0;i<=7;i++){
		if(iro[i]>0){
			count++;
		}
	}
	
	if(count==0){
		if(iro[9]==0){
			min=0;
			max=0;
		}else{
			min=1;
			max=iro[9];
		}
	}else{
		min=count;
		max=count+iro[9];
	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%d %d",min,max);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
package main

import "fmt"

type magic struct {
	name int
	attack int
	mp int
}

func dynamic(ibis []magic, h int, dp []int) []int {
	if h <= 0{
		return dp
	}
	if dp[h] != 0{
		return dp
	}
	eff := 9223372036854775807
	temp := make([]int,h)
	for i:=0 ; i<len(ibis) ; i++ {
		temp = dynamic(ibis,h-ibis[i].attack,dp)
		if h-ibis[i].attack > 0 {
			if temp[h-ibis[i].attack] + ibis[i].mp < eff {
				eff = temp[h-ibis[i].attack] + ibis[i].mp
			}
		} else if ibis[i].mp < eff {
			eff = ibis[i].mp
		}
	}
	dp[h] = eff
	return dp
}


func main(){
	var h,n,a,b int
	fmt.Scan(&h,&n)
	ibis := make([]magic,n)
	dp := make([]int,h+1) //dp[x]:xダメージ与えるために必要なMPの最小値
	for i:=0 ; i<n ;i++ {
		fmt.Scan(&a,&b)
		ibis[i].name = i
		ibis[i].attack = a
		ibis[i].mp = b
	}
	dp = dynamic(ibis,h,dp)
	fmt.Println(dp[h])
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b or (n==1 and a!=b)){
        cout<<0<<en;
        return;
    }
    cout<< (b-a)*(n-2)+1<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1e+9 + 7;
// --------------------------------------------------------


const int MAX_N = 1e+5;
VI dp(MAX_N, 0);

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

    int N; cin >> N;
    VI h(N); REP(i,N) cin >> h[i];

    dp[1] = dp[0] + abs(h[1] - h[0]);
    FOR(i,2,N) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[N-1] << '\n';

    return 0;
}

// https://atcoder.jp/contests/dp/tasks/dp_a


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }
  return ret;
}

vl a;
ll n,m;

bool check(ll H){
  ll K = 0;
  rep(i,n) {
    int p = lower_bound(all(a),H-a[i]) - a.begin();
    K += n-p;
  }
  return K <= m;
}

int main(){
  cin >> n >> m;
  a.resize(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll ok = 3e5, ng = 0;
  while (abs(ng-ok)>1){
    ll mid = (ok+ng)/2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  ll H = ok;
  vl s(n+1); rep(i,n) s[i+1] = s[i] + a[i];
  ll ans = 0, K = 0;
  rep(i,n) {
    ll p = lower_bound(all(a),H-a[i]) - a.begin();
    ans += s[n] - s[p];
    K += n-p;
    ans += (n-p)*a[i];
  }
  ans += (H-1)*(m-K);
  cout << ans << endl;}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pii pair<int,int>
#define endl "\n"
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    if(a<=m/2&&b<=n/2)
    {
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(i<b&&j<a) cout<<1;
                else if(i>=b&&j>=a) cout<<1;
                else cout<<0;
            }cout<<endl;
        }
    }
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int n,m,s;
pair<int,int> p[1000000];

int main(){
	while(cin>>n&&n){
		rep(i,n){
			cin>>p[i].second;
			int t=0;
			rep(j,4){cin>>m>>s;t+=m*60+s;}
			p[i].first=t;
		}
		sort(p,p+n);
		cout<<p[0].second<<endl<<p[1].second<<endl<<p[n-2].second<<endl;
	}
}

Measured memory_bytes: 8680
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i+=1)
using namespace std;
int main() {
  int N;
  string S;
  cin>>N;
  cin>>S;
  if(N%2==1) {
    cout<<"No"<<endl;
  }
  else {
    bool ans=true;
    rep(i,N/2) if(S[i]!=S[i+N/2])
        ans=false;
    if(ans)
        cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}
    
  
      
      
      
    
  
  

Measured memory_bytes: 256
//#include<stdio.h>
//#include<stdlib.h>
#include<bits/stdc++.h>
//#define Min(a,b,c) min((a),min((b),(c)))
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define MEM(x) memset(x,0,sizeof(x))
//#define N 200005
#define M
#define pi 3.14159265359
using namespace std;
typedef long long LL;
vector<LL> ans; 
int mod=1e9+7;
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	LL x[100006],y[100006];
	for(int i=0;i<n;i++)
	scanf("%lld",&x[i]);
	for(int j=0;j<m;j++)
	scanf("%lld",&y[j]);
	sort(x,x+n);
	sort(y,y+m);
	LL sum=0;
	for(int i=0;i<n-1;i++){
		sum+=(x[i+1]-x[i])*(i+1)%mod*(n-i-1)%mod;
		sum%=mod; 
	}
	LL total=0;
	for(int i=0;i<m-1;i++){
		total+=sum*(y[i+1]-y[i])%mod*(i+1)%mod*(m-i-1)%mod;
		total%=mod;
	}
	printf("%lld\n",total);
}
/*
Y  * (5y-4)(y+1)*/


Measured memory_bytes: 1920
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      Arrays.sort(a);
      if(a[0]==0){
        if(n%2==0){
        	System.out.println(0);
            return;
        }else{
          for(int i = 1;i < n-1 ;i+=2){
          	if(a[i]!=a[i+1]||a[i]!=i+1){
          		System.out.println(0);
            	return;
          	}
      	  }
        }
      }else if(a[0]==1){
      	if(n%2==1){
        	System.out.println(0);
            return;
        }else{
          for(int i = 0;i < n-1;i+=2){
          	if(a[i]!=a[i+1]||a[i]!=i+1){
            	System.out.println(0);
                return;
            }
          }
        }
      }else{
      	System.out.println(0);
        return;
      }
      long x = (long)n/2;
      long q = 1000000007;
      long p = pow(2,x,q);
      System.out.println(p%q);
    }
  public static long pow(long a,long x,long mod){
        if(x == 0) return 1;
		if(x == 1) return a % mod;
		else if(x % 2 == 0) return pow((a*a)% mod,x/2,mod) % mod;
		else return (a*pow((a*a)%mod,x/2,mod))%mod;
  }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

Measured memory_bytes: 49868
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#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 FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B;
    R(A,B);
    W(max({A+B,A-B,A*B}));
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
int A[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",A+i);
	if(A[n]!=2){
		puts("-1");
		return 0;
	}
	long long L=1,R=1;
	for(int i=n;i>1;--i){
		//ceil(L/A[i])<=floor(A[i-1]*x/A[i])<=R/A[i]
		//ceil(L/A[i])*A[i]<=A[i-1]*x<=floor(R/A[i])*A[i]
		L=(L*A[i]-1)/A[i-1]+1;
		if((R+1)*A[i]%A[i-1]==0)R=(R+1)*A[i]/A[i-1]-1;
		else R=(R+1)*A[i]/A[i-1];
	}
	L=L*A[1];
	R=(R+1)*A[1]-1;
	if(L<=R)printf("%lld %lld\n",L,R);
	else puts("-1");
	return 0;
}


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

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

  string ans = "No";
  if (S[2] == S[3] && S[4] == S[5]) {
    ans = "Yes";
  }

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


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int ResurrectionOfLosersN[] = new int[6];
		double ResurrectionOfLosersT[] = new double[6];
		double time[][] = new double[3][8];
		int num[][] = new int[3][8];
		BigDecimal number;
		DecimalFormat format = new DecimalFormat("#.#");
		format.setMinimumFractionDigits(2);
		format.setMaximumFractionDigits(2);

		for(int i = 0 ; i < 3 ; i++){
			for(int j = 0 ; j < 8 ; j++){
				num[i][j] = scan.nextInt();
				time[i][j] =scan.nextDouble();
			}
		}
		for(int i = 0 ; i < 3 ; i++){
			for(int j = 0 ; j < 8 ; j++){
				for(int k = 0 ; k < 7-j ; k++){
					if(time[i][k] > time[i][k+1]){
						double D = time[i][k];
						time[i][k] = time[i][k+1];
						time[i][k+1] = D;
						int d = num[i][k];
						num[i][k] = num[i][k+1];
						num[i][k+1] = d;
					}
				}
			}
		}


		for(int i = 0 ; i < 3 ; i++){
			number = new BigDecimal(time[i][0]);
			System.out.println(num[i][0] + " " + format.format(number));
			number = new BigDecimal(time[i][1]);
			System.out.println(num[i][1] + " " + format.format(number));
			ResurrectionOfLosersN[i*2] = num[i][2];
			ResurrectionOfLosersT[i*2] = time[i][2];
			ResurrectionOfLosersN[i*2+1] = num[i][3];
			ResurrectionOfLosersT[i*2+1] = time[i][3];
		}
		for(int j = 0 ; j < 6 ; j++){
			for(int k = 0 ; k < 5-j ; k++){
				if(ResurrectionOfLosersT[k] >= ResurrectionOfLosersT[k+1]){
					double D = ResurrectionOfLosersT[k];
					ResurrectionOfLosersT[k] = ResurrectionOfLosersT[k+1];
					ResurrectionOfLosersT[k+1] = D;
					int d = ResurrectionOfLosersN[k];
					ResurrectionOfLosersN[k] = ResurrectionOfLosersN[k+1];
					ResurrectionOfLosersN[k+1] = d;
				}
			}
		}
		number = new BigDecimal(ResurrectionOfLosersT[0]);
		System.out.println(ResurrectionOfLosersN[0] + " " + format.format(number));
		number = new BigDecimal(ResurrectionOfLosersT[1]);
		System.out.println(ResurrectionOfLosersN[1] + " " + format.format(number));
	}
}

Measured memory_bytes: 28412
#include<bits/stdc++.h>
#define tujare ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    long long a,b,c,k,p=0,x,y,z;
    cin>>a>>b>>c>>k;
    x=min(k,a);
    p+=x*1;
    k=max(0LL,k-a);
    y=min(k,b);
    k=max(0LL,k-b);
    z=min(k,c);
    k=max(0LL,k-c);
    p-=z;
    cout<<p;
    return 0;
}


Measured memory_bytes: 3624
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, d int
	fmt.Scan(&n, &d)

	list := make([][]int, n)
	for i := 0; i < n; i++ {
		list[i] = make([]int, d)
		for j := 0; j < d; j++ {
			fmt.Scan(&list[i][j])
		}
	}
	count := 0

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			distance := 0.0
			for k := 0; k < d; k++ {
				distance += math.Pow(float64(list[i][k]-list[j][k]), 2.0)
			}
			for l := 1; l <= int(distance); l++ {
				if l*l == int(distance) {
					count++
				}
			}
		}
	}
	fmt.Println(count)

}


Measured memory_bytes: 512
N, K = map(int, input().rstrip().split())
S = input().rstrip()
if S[K-1] == "A":
  print(S[:K-1] + "a" + S[K:])
elif S[K-1] == "B":
  print(S[:K-1] + "b" + S[K:])
else:
  print(S[:K-1] + "c" + S[K:])

Measured memory_bytes: 3060
s=readline()
answer=""
let
hantei1=false
hantei2=false
for i in 1:length(s)
    hantei1=hantei1?true:is(s[i],'C')
    hantei2=hantei1?(hantei2||is(s[i],'F')):false
end
answer=hantei2?"Yes":"No"
end
println(answer)

Measured memory_bytes: 56380
#include <bits/stdc++.h>
using namespace std;
int len(int ay, int ax, int by, int bx);

int main() {
  int n;
  cin >> n;
  int a, b, c, d;
  int mina = INT_MAX - 1;
  cin >> a >> b >> c >> d;
  a--;
  b--;
  c--;
  d--;
  for(int w = 1; w <= n; ++w) {
    mina = min(mina, len(a / w, a % w, b / w, b % w) + len(c / w, c % w, d / w, d % w));
  }
  cout << mina << endl;
  return 0;
}

int len(int ay, int ax, int by, int bx) {
  return abs(ay - by) + abs(ax - bx);
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
 
int N, Q, K;
vector<vector<P>> root(100001);  //pair<辺の距離, 行先の頂点>
vector<ll> dist(100001, LLONG_MAX); //distance[i]はstartから頂点iへの最短距離が入る
bitset<100001> used;

void Dijkstra(ll start){ //start = 始点
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(make_pair(0, start));
    while(!que.empty()){
        ll d, t; //d:startからの距離, t:行先
        tie(d, t) = que.top(); que.pop();
        if(used[t]) continue;   //探索済み
        used[t] = true, dist[t] = d;
        for(auto e : root[t]){
            if(dist[e.second] <= d + e.first) continue;
            que.push(make_pair(d + e.first, e.second));
        }
    }
    return;
}

int main(void){
    
    cin >> N;
    for(int i = 0; i < N - 1; ++i){
        ll a, b, c; scanf("%lld %lld %lld", &a, &b, &c);
        root[a].push_back(make_pair(c, b)), root[b].push_back(make_pair(c, a));
    }
    
    scanf("%d %d", &Q, &K);
    Dijkstra(K);
    for(int i = 0; i < Q; ++i){
        ll x, y; cin >> x >> y;
        printf("%lld\n", dist[x] + dist[y]);
    }
    
    return 0;
}

Measured memory_bytes: 11648
#include<iostream>

#if 0
08-182020の方のものを参照。

#endif


using namespace std;

int a[10000];
int s;
int n;
int p;
int gx,gy;
int T[15+10][15+10];
int Verz[15+10][15+10], Horiz[15+10][15+10];
/*
pair<int, int> pd;
int matatabix[10000],matatabiy[10000];
pair<int, int> matatabi1[10000], matatabi2[10000];
int Verz[10000][10000], Horiz[10000][10000];
*/

int main(){
  cin >> n;
  while(n!=0){
    n = n - 1;
    for(int i = 0; i < 15+10; ++i){
      for(int j = 0; j < 15+10; ++j){
        T[i][j] = (i == 0 && j == 0);
        Verz[i][j] = (j != 0);
        Horiz[i][j] = (i != 0);
      }
    }
    cin >> gx >> gy;//秘密の場所の座標
    cin >> p;
    int x1,x2,y1,y2;
    for(int i = 0; i < p; ++i){
      cin >> x1 >> y1 >> x2 >> y2;
      if(x1 == x2){
        Verz[max(x1, x2)][max(y1,y2)] = false;
      }
      if(y1 == y2){
        Horiz[max(x1, x2)][max(y1, y2)] = false;
      }
    }
    for (int x = 0; x <= gx; x++) {
      for (int y = 0; y <= gy; y++) {
        if (!(x == 0 && y == 0)) {
          T[x][y] = (Horiz[x][y] ? T[x-1][y] : 0) + (Verz[x][y] ? T[x][y-1] : 0);
        }
      }
    }
    cout << (T[gx][gy] ? to_string(T[gx][gy]) : "Miserable Hokusai!") << endl;
    /*
    cin >> pd.first >> pd.second;
    cin >> p;
    for(int i = 0; i < p; ++i){
      cin >> matatabi1[i].first >> matatabi1[i].second >> matatabi2[i].first >> matatabi2[i].second;
    }
    for(int i = 0; i < pd.first; ++i){
      for(int j = 0; j < pd.second; ++j){
        Verz[i][j] = true;
        Horiz[i][j] = true;
      }
    }
    for(int i = 0; i < pd.first; ++i){
      for(int j = 0; j < pd.second; ++j){
        if(matatabi1[j].second == matatabi2[j].second){
          Horiz[matatabi1[i].first ][max(matatabi1[j].second, matatabi2[j].second) ] = false;
        }
        if(matatabi1[i].first == matatabi2[i].first){
          Verz[max(matatabi1[i].first , matatabi2[i].first)][matatabi2[j].second] = false; 
        }
      }
    }
    for(int i = 0; i < pd.first; ++i){
      for(int j = 0; j < pd.second; ++j){
        T[0][0] = 1;
        if(i < 0 || j < 0){
          T[i][j] = 0;
        }
        else if(i ==0 && j == 0){
          T[i][j] = 1;
        }
        else if(Verz[i][j] == false && Horiz[i][j] == false){
          T[i][j] = 0;
        }
        else if(Verz[i][j] == false && Horiz[i][j] == true){
          T[i][j] = T[i - 1][j];
        }
        else if(Horiz[i][j] == false && Verz[i][j] ==true){
          T[i][j] = T[i][j - 1];
        }
        else{
          T[i][j] =T[i - 1][j] +T[i][j - 1];
        }
      }
    }
    if(T[pd.first][pd.second] != 0){
      cout << T[pd.first][pd.second] << endl;
    }
    else{
      cout << "Miserable Hokusai!" << endl;
      
    }
    */
  }
}


Measured memory_bytes: 3116
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	IOS;

	int a, b;
  	cin >> a >> b;

  	int m1 = a+b;
  	m1 = max(m1, a-b);
  	m1 = max(m1, a*b);
  	cout << m1;
  
	return 0;
}

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

int main()
{
	int n, k, count = 1;
	scanf("%d", &n);
	k = sqrt(n * 2);
	if (n * 2 == k * (k + 1))
	{
		int table[1000][1000]{};
		for (int i = 0; i < k + 1; ++i)
		{
			for (int j = i; j < k; ++j)
			{
				table[i][j] = table[j + 1][i] = count;
				++count;
			}
		}
		printf("Yes\n%d\n", k + 1);
		for (int i = 0; i < k + 1; ++i)
		{
			printf("%d", k);
			for (int j = 0; j < k; ++j)
			{
				printf(" %d", table[i][j]);
			}
			printf("\n");
		}
	}
	else
		std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
using namespace std;
typedef long long Int;

int main(){
    Int sum = 0;
    Int kingaku;

    int n;
    cin >> n;

    for(int i=1; i<=n; i++){
        cin >> kingaku;
        sum += kingaku;
    }
    cout << sum / n << endl;

    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
using namespace std;
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  ll sum=0;
  for(ll i=1;i<n;i++)
  {
       sum+=max(a[i-1]-a[i],(ll)0);
       a[i]=max(a[i],a[i-1]);
  }
  cout<<sum;
}


Measured memory_bytes: 4760
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
using namespace std;

int main(){
    int degree, ans, mod_last, divide_last;
    cin >> degree;
    if(360%degree==0){
        ans = 360 / degree;
    }
    else{
        mod_last = 360 % degree;
        divide_last = 360 / degree;
        ans = (360 / mod_last) * divide_last;
    }
    cout << ans;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;
    
    //code

    int h , w , n;
    cin >> h >> w >> n;
    int x , y;
    map<pair<int,int>,int> mp;

    for(int zz = 0 ; zz < n ; ++zz){
    	cin >> x >> y;
    	for(int i = -1 ; i <= 1 ; ++i){
    		for(int j = -1 ; j <= 1 ; ++j){
    			if( x+i >= 2 and x + i < h and y+j >= 2 and y + j < w){
    				mp[{x+i,y+j}]++;
    			}
    		}
    	}
    }
    int a[10] = {0};
    for(auto i : mp){
    	a[i.second]++;
    }

    
    // int cnt;
    // for(auto i : mp){
    // 	int mpf = i.first.first;
    // 	int mps = i.first.second;
    // 	if(mps + 2 <= w and mpf + 2 <= h){
    // 		cnt = 0;
    // 		for(int j = 0; j <= 2 ; ++j){
    // 			for(int k = 0 ; k <= 2 ; ++k){
    // 				if(mp[{mpf+j , mps+k}]){
    // 					cnt++;
    // 				}
    // 			}
    // 		}
    // 		a[cnt]++;
    // 	}
    // }
    int sum = 0;
    for(int i = 1 ; i <= 9 ; ++i){
    	sum += a[i];
    }
    cout << (h-2)*(w-2) - sum << "\n";
    for(int i = 1 ; i <= 9 ; ++i){
    	cout << a[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 56576