akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int shellsort(long long array[],int n)
{
    long long span,tmp;
    for(span=n/2;span>=1;span/=2)
    {
        for(long long i=span;i<n;i++)
        {
            for(long long s=i;s>=span;s=s-span)
            {
                if(array[s-span]<array[s])
                break;
                //swap
                tmp=array[s-span];
                array[s-span]=array[s];
                array[s]=tmp;
            }
        }
    }
}
int main(){
    int n,m;
    long long ans,ret=-1;
    cin>>n>>m;
    long long x[n],y[n],z[n],sum[n];
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i]>>z[i];
    }
    for(int i=0;i<8;i++)
    {
        ans=0;
        for(int w=0;w<n;w++)
        {
            sum[w]=0;
        }
        if(i&1)
        {
            for(int a=0;a<n;a++)
            {
                sum[a]-=x[a];
            }
        }
        else
        {
            for(int A=0;A<n;A++)
            {
                sum[A]+=x[A];
            }
        }
        if(i&2)
        {
            for(int b=0;b<n;b++)
            {
                sum[b]-=y[b];
            }
        }
        else{
            for(int B=0;B<n;B++)
            {
                sum[B]+=y[B];
            }
        }
        if(i&4)
        {
            for(int c=0;c<n;c++)
            {
                sum[c]-=z[c];
            }
        }
        else{
            for(int C=0;C<n;C++)
            {
                sum[C]+=z[C];
            }
        }
        shellsort(sum,n);
        for(int s=n-1;s>=n-m;s--)
        {
            ans+=sum[s];
        }
        ret=max(ret,ans);
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cingroup(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfgroup(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
typedef unsigned long long ull;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int maxi=-1,mini=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=0)
		{
			maxi=max(a[i],maxi);
		}
		else
		{
			mini=min(a[i],mini);
		}
	}
	vector <pii> vec;
	if(maxi>-mini)
	{
		int k=-1;
		for(int i=0;i<n;i++)
		{
			if(a[i]==maxi) k=i;
		}
		for(int i=0;i<n;i++)
		{
			vec.push_back(mp(k+1,i+1));
		}
		for(int i=1;i<n;i++)
		{
			vec.push_back(mp(i,i+1));
		}
	}
	else
	{
		int k=-1;
		for(int i=0;i<n;i++)
		{
			if(a[i]==mini) k=i;
		}
		for(int i=0;i<n;i++)
		{
			vec.push_back(mp(k+1,i+1));
		}
		for(int i=n-1;i>0;i--)
		{
			vec.push_back(mp(i+1,i));
		}
	}
	cout<<vec.size()<<endl;
	rep(vec.size())
	{
		cout<<vec[i].first<<' '<<vec[i].second<<endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 22;
const int INF = 1e9;

int H, W;
string S[MAX];
vi edge[MAX*MAX];
int dist[MAX*MAX][MAX*MAX];

int of_pos(ii pos) {
    return pos.first * MAX + pos.second;
}

ii pos_of(int val) {
    return make_pair(val/MAX, val%MAX);
}

void warshall_floyd() {
    int N = MAX*MAX;
    REP (k, N) REP (j, N) REP (i, N)
        dist[j][i] = min(dist[j][i], dist[j][k] + dist[k][i]);
}

int solve() {
    REP (h, MAX*MAX) REP (w, MAX*MAX) {
        if (h == w) dist[h][w] = 0;
        else dist[h][w] = INF;
    }
    REP (h, H) REP (w, W-1) if (S[h][w] == '.' && S[h][w+1] == '.') {
        int val1 = of_pos(make_pair(h, w));
        int val2 = of_pos(make_pair(h, w+1));
        edge[val1].push_back(val2);
        edge[val2].push_back(val1);
        dist[val1][val2] = dist[val2][val1] = 1;
    }
    REP (h, H-1) REP (w, W) if (S[h][w] == '.' && S[h+1][w] == '.') {
        int val1 = of_pos(make_pair(h, w));
        int val2 = of_pos(make_pair(h+1, w));
        edge[val1].push_back(val2);
        edge[val2].push_back(val1);
        dist[val1][val2] = dist[val2][val1] = 1;
    }

    warshall_floyd();
    int ans = 0;
    REP (h, MAX*MAX) REP (w, MAX*MAX) {
        if (dist[h][w] != INF) ans = max(ans, dist[h][w]);
    }
    return ans;
}

int main() {
    cin >> H >> W;
    REP (i, H) cin >> S[i];
    cout << solve() << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  
  cin >> n >> a;
  
  int tmp = n % 500;
  
  if ((tmp - a) <= 0) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000


int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i,j;
    scanf("%d",&n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for (i = 0;i <= VMAX;i++)C[i] = 0;

  for ( i = 0; i < n;i++){
    scanf("%hu", &A[i+1]);
    C[A[i+1]]++;
  }
  for ( i = 1;i <= VMAX;i++)C[i] =C[i] + C[i-1];

  for (j = 1;j <= n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for (i = 1; i<= n; i++){
    if(i > 1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}
    
	



Measured memory_bytes: 9620
#include <iostream>

int main()
{
  int64_t N,D;
  std::cin>>N>>D;
  
  int64_t result=0;
  for(int64_t i=0;i!=N;i++)
  {
    int64_t X,Y;
    std::cin>>X>>Y;
    if(X*X+Y*Y<=D*D)
      result++;
  }
  
  std::cout<<result<<std::endl;
  
  return 0;
}

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

using namespace std;

using ll = long long;

constexpr int MAX_MONEY = 5000;

struct State {
    int at;
    int money;
    ll cost;
    //int prev;
    State(int at, int money, ll cost/*, int prev*/) : at(at), money(money), cost(cost)/*, prev(prev)*/ {}
    bool operator>(const State& s) const {
        return cost > s.cost;
    }
};

struct Edge {
    int to;
    int money;
    ll cost;
    Edge(int to, int money, ll cost) : to(to), money(money), cost(cost) {}
};

using Graph = vector< vector<Edge> >; //隣接リスト

const ll INF = 1e18;
//const int NONE = -1;

//sは始点、mincは最短経路のコスト、prevsは最短経路をたどる際の前の頂点
void dijkstra(int s, const Graph& graph, vector< vector<ll> >& minc, int S, const vector<int>& c, const vector<ll>& d){
    minc.assign(graph.size(), vector<ll>(MAX_MONEY + 1, INF));
    //prevs.assign(graph.size(), NONE);
    
    priority_queue<State, vector<State>, greater<State> > pq;
    S = min(S, MAX_MONEY);
    pq.emplace(s, S, 0/*, NONE*/);
    minc[s][S] = 0;

    while(!pq.empty()) {
        State cur = pq.top();
        pq.pop();
        if (minc[cur.at][cur.money] < cur.cost) continue;

        for(const Edge& e : graph[cur.at]) {
            int money = cur.money - e.money;
            if (money < 0) continue;

            ll cost = cur.cost + e.cost;
            if (minc[e.to][money] <= cost) continue;

            minc[e.to][money] = cost;
            pq.emplace(e.to, money, cost/*, cur.at*/);
        }

        if (cur.money == MAX_MONEY) continue;
        int money = min(cur.money + c[cur.at], MAX_MONEY);
        ll cost = cur.cost + d[cur.at];
        
        if (minc[cur.at][money] <= cost) continue;
        minc[cur.at][money] = cost;
        pq.emplace(cur.at, money, cost/*, cur.at*/);
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    ll s;
    cin >> n >> m >> s;
    
    Graph g(n);
    for (int i = 0; i < m; ++i) {
        int u, v, a;
        ll b;
        cin >> u >> v >> a >> b;
        --u; --v;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }

    vector<int> c(n);
    vector<ll> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> c[i] >> d[i];
    }

    vector< vector<ll> > minc;
    dijkstra(0, g, minc, s, c, d);

    for (int i = 1; i < n; ++i) {
        ll ans = INF;
        for (int j = 0; j <= MAX_MONEY; ++j) {
            ans = min(ans, minc[i][j]);
        }
        cout << ans << "\n";
    }
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	int dx=tx-sx;
	int dy=ty-sy;
	for(int i=0;i<dx;++i) cout<<'R';
	for(int i=0;i<dy;++i) cout<<'U';
	for(int i=0;i<dx;++i) cout<<'L';
	for(int i=0;i<dy;++i) cout<<'D';
	cout<<'D';
	for(int i=0;i<dx+1;++i) cout<<'R';
	for(int i=0;i<dy+1;++i) cout<<'U';
	cout<<'L';
	cout<<'U';
	for(int i=0;i<dx+1;++i) cout<<'L';
	for(int i=0;i<dy+1;++i) cout<<'D';
	cout<<'R';
	cout<<endl;
}




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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  long long n; scanf("%lld", &n);
  string s;
  while (n) {
    --n;
    s.push_back(n%26+'a');
    n /= 26;
  }
  reverse(s.begin(), s.end());
  printf("%s", s.c_str());
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3824
// E. Magical Permutation
// time limit per test1 second
// memory limit per test256 megabytes
// inputstandard input
// outputstandard output
// Kuro has just learned about permutations and he is really excited to create a
// new permutation type. He has chosen 𝑛 distinct positive integers and put all
// of them in a set 𝑆. Now he defines a magical permutation to be:

// A permutation of integers from 0 to 2𝑥−1, where 𝑥 is a non-negative integer.
// The bitwise xor of any two consecutive elements in the permutation is an
// element in 𝑆. Since Kuro is really excited about magical permutations, he
// wants to create the longest magical permutation possible. In other words, he
// wants to find the largest non-negative integer 𝑥 such that there is a magical
// permutation of integers from 0 to 2𝑥−1. Since he is a newbie in the subject,
// he wants you to help him find this value of 𝑥 and also the magical
// permutation for that 𝑥.

// Input
// The first line contains the integer 𝑛 (1≤𝑛≤2⋅105) — the number of elements in
// the set 𝑆.

// The next line contains 𝑛 distinct integers 𝑆1,𝑆2,…,𝑆𝑛 (1≤𝑆𝑖≤2⋅105) — the
// elements in the set 𝑆.

// Output
// In the first line print the largest non-negative integer 𝑥, such that there
// is a magical permutation of integers from 0 to 2𝑥−1.

// Then print 2𝑥 integers describing a magical permutation of integers from 0 to
// 2𝑥−1. If there are multiple such magical permutations, print any of them.

// Examples
// inputCopy
// 3
// 1 2 3
// outputCopy
// 2
// 0 1 3 2
// inputCopy
// 2
// 2 3
// outputCopy
// 2
// 0 2 1 3
// inputCopy
// 4
// 1 2 3 4
// outputCopy
// 3
// 0 1 3 2 6 7 5 4
// inputCopy
// 2
// 2 4
// outputCopy
// 0
// 0
// inputCopy
// 1
// 20
// outputCopy
// 0
// 0
// inputCopy
// 1
// 1
// outputCopy
// 1
// 0 1
// Note
// In the first example, 0,1,3,2 is a magical permutation since:

// 0⊕1=1∈𝑆
// 1⊕3=2∈𝑆
// 3⊕2=1∈𝑆
// Where ⊕ denotes bitwise xor operation.

#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

using namespace std;

int n, m;
int i, j, k;

void solve() {
  vector<pair<int, int>> tasks;
  int n, m;
  cin >> n >> m;
  int a, b;
  for (i = 0; i < n; ++i) {
    cin >> a >> b;
    tasks.push_back(make_pair(b, a));
  }
  sort(tasks.begin(), tasks.end(), [](pair<int, int>& a, pair<int, int>& b) {
    return a.first > b.first || (a.first == b.first && a.second > b.second);
  });
  vector<int> take(m);
  iota(take.begin(), take.end(), 1);
  long long res = 0;
  for (auto& task : tasks) {
    b = task.first;
    a = task.second;
    if (take.back() < a) continue;
    auto it = lower_bound(take.begin(), take.end(), a);
    if (it == take.end()) continue;
    take.erase(it);
    res += b;
  }
  cout << res << endl;
}

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


Measured memory_bytes: 1400
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define VI vector<int>
#define VII vector<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const int MOD = 1000000007;
int main()
{
	int a;
	int b;
	int c;
	bool flag=false;
	cin >> a;
	cin >> b;
	cin >> c;
	REP(i, 1000)
	{
		if ((i + 1)*a%b == c)
		{
			flag = true;
		}
	}
	if (flag==true)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi freopen("input.txt","r",stdin)
#define fo freopen("output.txt","w",stdout)
#define l(s) int(s.size())
#define pb push_back
string s;
int main()
{
	cin>>s;
	int n=s.size();
	long long ans=0;
	for(int i=0;i<1<<(n-1);i++)
	{
		long long sum=0,now=0;
		for(int j=0;j<n;j++)
		{
			now*=10;
			now+=s[j]-'0';
			if(j<n-1&&(i>>j&1))
			{
				sum+=now;
				now=0;
			}
		}
		sum+=now;
		ans+=sum;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>

#define MAX 999999

using namespace std;


int main(){
	int n = 0;
	int count;
	bool flag = false;
	vector<int> sosu;
	sosu.push_back(0);
	sosu.push_back(0);
	sosu.push_back(1);

	count = 1;
	for(int i = 3; i <= MAX; i += 2){
		for(int j = 3; j * j <= i; j += 2){
			if(i % j == 0){
				flag = true;
				break;
			}
		}
		if(flag != true){
			count++;
		}
		else{
			flag = false;
		}
		sosu.push_back(count);
		sosu.push_back(count);
	}
	

	while(cin >> n){
		cout << sosu[n] << endl;	
	}

	return 0;
}

Measured memory_bytes: 6904
n = int(input())

btc = 380000.0

ans = 0
for _ in range(n):
    x, u = input().split()
    #x = int(x)
    #print(u)
    if u == 'JPY':
        x = int(x)
        ans += x
    else:
        x = float(x)
        ans += x * btc

print(ans)

Measured memory_bytes: 3060
from collections import *
import sys
try: inp = raw_input
except: inp = input
def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
A = nl()
subs = [0]*N
for a in A:
    subs[a-1] += 1
print('\n'.join(map(str, subs)))


Measured memory_bytes: 102020
//2019年12月8日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElms(&a[0], a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


vi edge[100005];
int par_counter[100005];
int parrent[100005];
int donecnt[100005];

int main(){
	int n,m;
	cin >> n >> m;
	rep(i,n-1+m){
		int a,b;
		cin >> a >> b;
		edge[a].push_back(b);
		par_counter[b]++;
	}
	rep1(i,n) parrent[i] = -1;

	int root = 0;
	rep1(i,n){
		if(par_counter[i] == 0){
			root = i;
			par_counter[i]++;
			break;
		}
	}

	//qの中身は{参照する頂点,親}
	queue<pii> q;

	q.push(mp(root,0));
	while(!q.empty()){
		pii tmp = q.front();
		q.pop();
		donecnt[tmp.F]++;
		if(donecnt[tmp.F] == par_counter[tmp.F]){
			parrent[tmp.F] = tmp.S;
			for(const auto& nx : edge[tmp.F]) q.push(mp(nx,tmp.F));
		}
	}

	rep1(i,n) prints(parrent[i]);




	return 0;
}



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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int sum[2018][2018];
void solve(vector<pair<P, P> > vp){
    rep(i, vp.size()){
        P l = vp[i].fi, r = vp[i].se;
        if(l.fi > r.fi || l.se > r.se) continue;
        sum[l.fi][l.se]++;
        sum[l.fi][r.se+1]--;
        sum[r.fi+1][l.se]--;
        sum[r.fi+1][r.se+1]++;
    }
}

int main(){
    ii(n); lint k; cin >> k;
    rep(i, n){
        lint x, y; cin >> x >> y; char c; cin >> c;
        if(c == 'B'){
            x %= 2*k; y %= 2*k;
        }
        else{
            x = (x+k)%(2*k); y %= 2*k;
        }
        if(x >= k && y < k){
            x -= k; y += k;
        }
        else if(x >= k && y >= k){
            x -= k; y -= k;
        }
        vector<pair<P, P> > vp;
        if(y < k){
            vp.push_back(make_pair(P(0,0),P(x,y)));
            vp.push_back(make_pair(P(x+1, y+1), P(x+k, y+k)));
            vp.push_back(make_pair(P(0, y+k+1), P(x, 2*k-1)));
            vp.push_back(make_pair(P(x+k+1, 0), P(2*k-1, y)));
            vp.push_back(make_pair(P(x+k+1, y+k+1), P(2*k-1, 2*k-1)));
            solve(vp);
        }else{
            vp.push_back(make_pair(P(0, y-k+1), P(x, y)));
            vp.push_back(make_pair(P(x+k+1, y-k+1), P(2*k-1, y)));
            vp.push_back(make_pair(P(x+1, y+1), P(x+k, 2*k-1)));
            vp.push_back(make_pair(P(x+1, 0), P(x+k, y-k)));
            solve(vp);
        }
    }
    rep(i, 2*k) rep(j, 2*k){
        if(i == 0 && j == 0) continue;
        if(i == 0){
            sum[0][j] += sum[0][j-1]; continue;
        }
        if(j == 0){
            sum[i][0] += sum[i-1][0]; continue;
        }
        sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
    }
    int res = 0;
    rep(i, 2*k) rep(j, 2*k){
        res = max(res, sum[i][j]);
    }
    out(res);
}

Measured memory_bytes: 16000
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int rec(int n, int sum, int used, int x, int N)
{
    if (used == 3 && sum == x) return 1;
    if (used == 3 || n > N) return 0;
    int ret = 0;
    ret += rec(n + 1, sum + n, used + 1, x, N) + rec(n + 1, sum, used, x, N);
    return ret;
}

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

    while (true)
    {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;

        cout << rec(1, 0, 0, x, n) << "\n";
    }

    return 0;
}



Measured memory_bytes: 3204
#include<stdio.h>
#include<string.h>
int main()
{
    char s[200];
    char a[200],b[200];
    long int n;
    while(~scanf("%ld%s",&n,s))
    {
        int u=0;
        if(n%2!=0)
            printf("No\n");
        else
        {
            for(int i=0;i<=n/2-1;i++)
                a[i]=s[i];
            a[n/2]='\0';
            for(long int i=n/2;i<=n-1;i++)
                b[u++]=s[i];
            b[n/2]='\0';
            if(strcmp(a,b)==0)
                printf("Yes\n");
            else
                printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;

ll modpow(ll a, ll n ) {
  ll res = 1;
  while(n > 0) {
    if(n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main()
{
  int n,k;
  cin >> n >> k;
  vector<ll> cnt(k+1, 0);
  cnt[k] = 1;
  ll ans = k;
  for(int i=k-1; i>=1; i--){
    int tmp = k/i;
    cnt[i] = modpow(tmp, n);
    for(int j=i+i; j<=k; j+=i){
      cnt[i] = cnt[i] + MOD - cnt[j];
      cnt[i] %= MOD;
    }
    ans += 1LL * cnt[i] * i;
    ans %= MOD;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4024
import java.util.*;
public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
		char a = sc.next().charAt(0);
      	char b = sc.next().charAt(0);
      
      	if(a=='D'&&b=='D'){
        	System.out.println("H");
        }else if(a=='D'&&b=='H'){
        	System.out.println("D");
        }else if(a=='H'&&b=='H'){
        	System.out.println("H");
        }else{
        	System.out.println("D");
        }
    }
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  ll n, o = 0;
  cin >> n;
  vector<ll> a(n), b(n), c(n), bc(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  for(int i = 0; i < n; i++)
    cin >> b.at(i);
  for(int i = 0; i < n; i++)
    cin >> c.at(i);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  for(int i = n - 1; i >= 0; i--) {
    bc.at(i) = distance(upper_bound(c.begin(), c.end(), b.at(i)), c.end());
    if(i != n - 1)
      bc.at(i) += bc.at(i + 1);
  }
  for(int i = 0; i < n; i++)
    o += *(bc.begin() +
           distance(b.begin(), upper_bound(b.begin(), b.end(), a.at(i))));
  cout << o << endl;
}

Measured memory_bytes: 3328
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
//ll mod=1000000007;
ll mod=998244353;
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}
int main() {
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    if(s=="SUN")cout<<7;
    else if(s=="MON")cout<<6;
    else if(s=="TUE")cout<<5;
    else if(s=="WED")cout<<4;
    else if(s=="THU")cout<<3;
    else if(s=="FRI")cout<<2;
    else cout<<1;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {

	string a;
	string b;
	int kari;

	cin >> kari;

	for (int o = 0; o < kari; o++) {
		int c[80] = {0};
		int d[80] = {0};
		int e[81] = {0};
		int counter = 0;

		cin >> a;
		cin >> b;
	
		if (a.size() > 80 || b.size() > 80) {
			cout << "overflow" << endl;
			continue;
		} else {
			for (int i = a.size() - 1; i >= 0; i--) {
				c[a.size() - 1 - i] = a[i] - '0';
			}

			for (int i = b.size() - 1; i >= 0; i--) {
				d[b.size() - 1 - i] = b[i] - '0';
			}

			for (int j = 0; j < 80; j++) {
				e[j] += c[j] + d[j];
				if (e[j] >= 10) {
					e[j+1] = e[j] / 10;
					e[j] = e[j] % 10;
				} 
			}
		}

		if (e[80] > 0) {
			cout << "overflow" << endl;
		} else {
			for (int k = 79; k >= 0; k--) {
				if (e[k] != 0) {
					counter = k;
					break;
				}
			}
			for (int k = counter; k >= 0; k--) {
				cout << e[k];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ull N, M;
	cin >> N >> M;

	vector<ll> x(N, 0);
	vector<ll> y(N, 0);
	vector<ll> z(N, 0);
	for (int i = 0; i < N; ++i){
		cin >> x[i] >> y[i] >> z[i];
	}

	ll max = 0;
	for (int ii = 0; ii < 8; ++ii){
		ll xsign = 2 * ( ii & 1) - 1;
		ll ysign = 2 * ( (ii>>1) & 1) - 1;
		ll zsign = 2 * ( (ii>>2) & 1) - 1;
		vector<ll> tmp(N, 0);
		for (int ii = 0; ii < N; ++ii){
			tmp[ii] = xsign * x[ii] + ysign * y[ii] + zsign * z[ii];
		}
		//ソートして大きい方からM個選んで和をとる
		sort(tmp.rbegin(), tmp.rend());
		ll sum = 0;
		for (int ii = 0; ii < M; ++ii){
			sum += tmp[ii];
		}
		if (max < sum){
			max = sum;
		}
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N=int(input()) 
Wlist=list(map(int, input().split())) 


ans=10001
for i in range(1,N):
    S1=0
    S2=0
    sa=0
    # S1を求める
    for j in range(i):
        S1 = S1 + Wlist[j]
    # S2を求める
    S2=sum(Wlist)-S1

    # 絶対値を求める
    sa = abs(S2-S1)

    # 最小値を更新
    if sa < ans:
        ans = sa

print(ans)

Measured memory_bytes: 3064
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

a,b = map(int, input().split())

print(lcm(a,b))


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
    double a, b, c, d, e, f;
    while(cin >> a) {
        cin >> b >> c >> d >> e >> f;
        double x = (c * e - b * f) / (a * e - b * d);
        double y = (-c * d + a * f) / (a * e - b * d);
        if (abs(x) < 1e-3) x = 0.0;
        if (abs(y) < 1e-3) y = 0.0;
        cout << fixed << setprecision(3) << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 1284
import sys
r,g,b = map(int,input().split())
if r < 0 or g < 0 or b < 0 or r > 9 or g > 9 or b > 9:
    sys.exit()

if (r*100 + g*10 + b) % 4 == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9100
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include<map>
#include <queue>
using namespace std;
const int MAX = 3e5 + 20;
typedef long long ll;
struct ppp{
    int val, id;
    bool operator < (ppp a) const {
        return val > a.val;
    }
};
ppp hang[MAX], lie[MAX];
map <int,int> pic[MAX];
int main()
{
    int h, w, m;
    cin >> h >> w >> m;
    for (int i = 1; i <= m;i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        pic[x][y] = 1;
        hang[x].val++, lie[y].val++;
    }
    for (int i = 1; i <= max(h, w);i++)
        hang[i].id = i, lie[i].id = i;
    sort(hang + 1, hang + 1 + h);
    sort(lie + 1, lie + 1 + w);
    int ans = hang[1].val + lie[1].val - 1;
    {
        for (int i = 1; i <= h;i++)
        {
            if (i != 1 and hang[i].val != hang[i-1].val)
                break;
            for (int j = 1; j <= w;j++)
            {
                if (j!=1 and lie[j].val != lie[j-1].val)
                    break;
                if(pic[hang[i].id].count(lie[j].id) == 0)
                {
                    ans++;
                    cout << ans << endl;
                    return 0;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 36548
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}

int main()
{
	str s;
	str t;
	cin >> s >> t;
	t.pop_back();
	if (s == t)
		cout << "Yes" << endl;
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll ac=0;
ll ad=0;
ll bc=0;
ll bd=0;
a--;
ac=a/c;
ad=a/d;
bc=b/c;
bd=b/d;
ll acd=0;
ll bcd=0;
ll q=__gcd(c,d);
q=c*d/q;
acd=a/(q);
bcd=b/(q);
cout<<(b+bcd-bc-bd)-(a+acd-ac-ad)<<endl;}


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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert

void solve(){
    ll n,m;
    cin>>n>>m;
    ll ans = n*(n-1)/2;
    ans += m*(m-1)/2;
    cout << ans ;
}

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

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

int main(){
  int N;
  cin >> N;
  int A;
  A = N%10;
  if(A==3){
    cout << "bon"<<endl;
  }else if(A == 0||A == 1|| A==6||A==8){
    cout << "pon" << endl;
  }else{
    cout <<"hon" << endl;
  }
}


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

// const int mxN = 1e9 + 7;
const int M = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % M;
		b = (b * b) % M;
		e >>= 1; // e/=2;
	}
	return res;
}

string s[6];

int main()
{
	fast;
	int h, w, k, ans = 0;
	cin >> h >> w >> k;
	FOR(h)
	cin >> s[i];
	FOR(1 << h)
	{
		FOR(j, 1 << w)
		{
			int black = 0;
			FOR(i2, h)
			{
				FOR(j2, w)
				{
					// if current column, row matches with the bitmask
					if (!(i & (1 << i2)) && !(j & (1 << j2)) && s[i2][j2] == '#')
						black++;
				}
			}
			if (black == k)
				ans++;
		}
	}
	cout << ans;
}

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

int main() {
    long n,d; cin >> n >> d;
    long ans = 0;
    for(int i=0; i<n; i++){
        long x,y; cin >> x >> y;
        if(sqrt(x*x + y*y) <= d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, m, x[100010], y[100010], rx[100010], ry[100010], ans, yy;

int main() {
	cin >> n >> m;
	for (int i = 1;i <= n;i++) {
		cin >> x[i];
		rx[i] = rx[i - 1] + x[i];
	}
	for (int i = 1;i <= m;i++) {
		cin >> y[i];
		ry[i] = ry[i - 1] + y[i];
	}
	for (int i = 1;i <= m - 1;i++) {
		yy = (yy + (ry[m] - ry[i] - ry[m - i]) + MOD * (ll)1e7) % MOD;
	}
	for (int i = 1;i <= n - 1;i++) {
		ans = ans + (((rx[n] - rx[i] - rx[n - i] + MOD * (ll)1e7)) % MOD*yy) % MOD;
		ans %= MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = (1 << 30) - 1;
const ll INF_64 = (1LL << 62) - 1;
const int MOD = 1e9 + 7;

ull next_subset(ull s){
	ull tem = s + (s & -s);
	ull btm = (~tem & s) / (s & -s) >> 1;
	return btm | tem;
}


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

	int n,a[3],b,c,d,m; cin>>a[0]>>a[1]>>a[2];
	m = INF_32;
	rep(i,3)rep(j,3)rep(k,3){
		if(i == j || j == k || k == i) continue;
		m = min(m,abs(a[j]-a[i]) + abs(a[k]-a[j]));
	}
	cout<<m<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

#define MAXN 100010
bitset<MAXN> ac;
int32_t main(){
	ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	map<int, int> pn;
	int r1=0, r2=0;
	for(int i=0; i<m; ++i){
		int x;
		string st;
		cin >> x >> st;
		if(st=="WA" and not ac[x]) ++pn[x];
		if(st=="AC" and not ac[x]) ++r1, r2+=pn[x], ac[x] = true;
	}
	cout << r1 << " " <<  r2 << endl;
}


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

const int N = 205;

struct Point {
	int x; int y; int type;
	bool operator < (const Point &other) const {
		return x < other.x;
	}
} a[N];

int n;
int res;

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

	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i].x >> a[i].y, a[i].type = 0;
	for (int i = 1; i <= n; ++i) cin >> a[i + n].x >> a[i + n].y, a[i + n].type = 1;

	sort(a + 1, a + n + n + 1);

	multiset<int> s;
	for (int i = 1; i <= n + n; ++i) {
		if (a[i].type == 0) {
			s.insert(a[i].y);
		} else {
			multiset<int>::iterator it = s.lower_bound(a[i].y);
			if (it == s.begin()) continue;

			--it;
			assert(*it < a[i].y);
			s.erase(it);
			++res;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
s=raw_input().strip()
pile=[s[0]]
n=len(s)
ans=0
for i in xrange(1,n):
	if pile:
		x=pile.pop()
		if s[i]!=x:
			ans=ans+2
		else:
			pile.append(x)
			pile.append(s[i])
	else:
		pile.append(s[i])
print ans

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

int main(){
	int a , b , c;
	double m;
	cin>>a>>b;
	c = (a + b) / 2;
	m = (a + b) / 2.0 - c;
	if(m >= 0.5) cout<<(a + b) / 2.0 - m + 1<<endl;
	else cout<<(a + b)/2.0 - m<<endl;
	
	return 0;
	}

Measured memory_bytes: 256
#include "stdio.h"
int main()
{
    int n;
    scanf("%d",&n);
    int t;
    scanf("%d",&t);
    int array[n];
    int count=0;
    int min=1000000;
    for (int i = 0; i < n; i++)
    {
        int j,k;
        scanf("%d %d",&j,&k);
        if(k<=t){
            array[i]=j;
        }else{
            array[i]=10000000;
        }
        if(array[i]<min){
            min=array[i];
            count=j;
        }
    }

    if (count==0)
    {
        printf("TLE\n");
    }else{
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
int main(){
	int n,a,b;
	cin>>n;
	vector<int> an(n);
	rep(i,n){
		cin>>an.at(i);
	}
	sort(an.begin(),an.end());
	a=an.at((n/2)-1);
	b=an.at((n/2));
	cout<<(b-a)<<endl;
	return 0;
}	

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;
const LL INF = 0x3f3f3f3f3f3f3f3f;

int n, a[25];
unordered_map<LL, LL> dp[25][25];

LL gen_ans(int l, int r, LL cl, LL cr)
{
	if(r - l == 1) return cl * a[l] + cr * a[r];
	if(dp[l][r].find(cl << 20 | cr) != dp[l][r].end()) return dp[l][r][cl << 20 | cr];
	LL ans = INF;
	for(int i = l + 1; i <= r - 1; i ++)
	ans = min(ans, gen_ans(l, i, cl, cl + cr) + gen_ans(i, r, cl + cr, cr) - a[i] * (cl + cr));
	dp[l][r][cl << 20 | cr] = ans;
	return ans;
}

int main()
{
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	
	printf("%lld\n", gen_ans(0, n - 1, 1, 1));
	return 0;
}

Measured memory_bytes: 12824
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

template<ll mod>
class Fp {
public:
	ll val;

private:
	inline void calc_mod(ll& v) {
		if (v >= mod)v -= mod;
	}
public:
	Fp() { val = 0; }
	Fp(ll v) :val(v%mod) {
		if (val < 0)val += mod;
	}

	Fp operator+=(const Fp &in) {
		val += in.val;
		calc_mod(val);
		return *this;
	}

	Fp operator+(const Fp &in) const {
		return Fp(*this) += in;
	}

	Fp &operator-=(const Fp &in) {
		val -= in.val;
		calc_mod(val);
		if (val < 0)val += mod;
		return *this;
	}

	Fp operator-(const Fp &in) const {
		return Fp(*this) -= in;
	}

	Fp& operator*=(const Fp& in) {
		val = val * in.val % mod;
		return *this;
	}

	Fp operator*(const Fp &in) const {
		return Fp(*this) *= in;
	}

	Fp& operator/=(const Fp& in) {
		*this *= modpow(in, mod - 2);
		return *this;
	}

	Fp operator/(const Fp& in) const {
		return Fp(*this) /= in;
	}

	bool operator==(const Fp&in)const {
		return val == in.val;
	}

	bool operator!=(const Fp&in)const {
		return val != in.val;
	}

	friend Fp modpow(const Fp& in, ll n) {
		if (n == 0)return 1;
		if (n & 1) {
			return in * modpow(in*in, n / 2);
		}
		else {
			return modpow(in*in, n / 2);
		}
	}
};
using modll = Fp<mod>;

class Factorial {
public:
	vector<modll> fact, finv;
	Factorial(ll n) :fact(n + 1, modll(1)), finv(n + 1, modll(1)) {
		for (int i = 2; i <= n; i++) {
			modll tmp(i);
			fact[i] = fact[i - 1] * tmp;
			finv[i] = finv[i - 1] / tmp;
		}
	}

	modll com(const ll& n, const ll& k) {
		if (n < k || n < 0 || k < 0)return modll(0);
		return fact[n] * finv[k] * finv[n - k];
	}
};


int main() {
	modll ans = 0;
	modll dp[102][4][4][4];
	cin >> N;
	for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 4; k++) {
			for (int l = 0; l < 4; l++) {
				if (j == 0 && k == 1 && l == 2) continue;
				if (j == 1 && k == 0 && l == 2) continue;
				if (j == 0 && k == 2 && l == 1) continue;
				dp[3][j][k][l] = 1;
			}
		}
	}
	for (int n = 0; n < N; n++) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {
					for (int l = 0; l < 4; l++) {
						if (i == 0 && j == 1 && l == 2)continue;
						if (i == 0 && k == 1 && l == 2) continue;
						if (j == 0 && k == 1 && l == 2) continue;
						if (j == 1 && k == 0 && l == 2) continue;
						if (j == 0 && k == 2 && l == 1) continue;
						dp[n + 1][j][k][l] += dp[n][i][j][k];
					}
				}
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				ans += dp[N][i][j][k];
			}
		}
	}
	cout << ans.val << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using namespace std;
int a,b,c,d,k,awal,tot;
int main(){
	cin>>a>>b>>c>>d>>k;
	tot = c*60+d-a*60-b;
	tot-=k;
	cout<<tot<<endl;


}

Measured memory_bytes: 3636
k = int(input())
if k==1 or k==7:
  print(1)
elif k%2==0:
  print(-1)
else:
  cnt = 1
  pre = 7
  while(True):
    surp = (pre*10+7)%k
    cnt += 1
    if surp==0:
      break
    if cnt>1000000:
      cnt = -1
      break
    pre = surp
  print(cnt)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    int d[50];
    cin >> n;
    for(int i=0;i<n;++i) cin >> d[i];
    int sum=0;
    for(int i=0;i<n;++i) {
        for(int j=0;j<n;++j) {
            if(i<j) sum+=d[i]*d[j];
        }
    }
    cout << sum << endl;
}



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

int toint(char a){
  if('a'<=a && a<='z'){
    return a-'a';
  }else{
    return a-'A'+26;
  }
}

char tochar(int n){
  if(0<=n && n<=25){
    return 'a'+n;
  }else{
    return 'A'+n-26;
  }
}

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) break;

    vector<int> key(n);
    string str;
    for(int i=0; i<n; i++){
      cin >> key[i];
    }
    cin >> str;

    for(unsigned int i=0; i<str.length(); i++){
      str[i] = tochar( (toint(str[i]) +52 -key[i%key.size()])%52 );
    }
    cout << str << endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    set<string> st;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        st.insert(s);
    }
    if (st.size() == 3) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;


int main(){
	lint n,a,b;
	cin >> n >> a >> b;
	lint c = a + b;
	cout << n/c*a + min(n%c,a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int k;
	cin >> k >> s;
	if(s.size() <= k){
		cout << s;
		return 0;
	}
	cout << s.substr(0,k) << "...";
	return 0;
}





Measured memory_bytes: 3632
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))

    out.println(
      get[String].map {
        case 'g' => 1
        case 'p' => -1
      }.sum / 2
    )

    out.flush()
  }
}

Measured memory_bytes: 29284
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <cstdio>

using namespace std;

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

  std::vector<long long> A(N);
  std::map<int, int> mp;

  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    mp[A[i]]++;
  }
  std::sort(A.begin(), A.end());

  int ans = 0;
  vector<bool> table(1000006, false);
  for (int i = 0; i < N; i++) {
    if (!table[A[i]] && mp[A[i]] == 1) {
      ans++;
    }
    if (table[A[i]]) {
      continue;
    }
    for (int j = A[i]; j <= 1000000; j += A[i]) {
      table[j] = true;
    }
  }
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 14252