akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        string S = NextString();
        int[] dp = Enumerable.Repeat(0, S.Length).ToArray();
        dp[0] = 1;
        bool f = false;
        for (int i = 0; i < S.Length - 1; i++)
        {
            //違うなら2個とってok
            if (f || S[i] != S[i + 1])
            {
                f = false;
                dp[i + 1] = Math.Max(dp[i + 1], dp[i] + 1);
                continue;
            }
            //自分から2個先は基本ok
            if (i + 2 < S.Length)
            {
                dp[i + 2] = Math.Max(dp[i + 2], dp[i] + 1);
                f = true;
                i++;
            }
        }
        if (1 < S.Length)
            Console.WriteLine(Math.Max(dp[S.Length - 1], dp[S.Length - 2]));
        else
            Console.WriteLine(1);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 15328
#include <iostream>
#include <stack>

using namespace std;

#define PAIR pair<int, int>

int main() {
	int w, h;
	while (cin >> w >> h, w != 0 && h != 0) {
		bool field[52][52] = {{false}};

		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				cin >> field[i][j];
			}
		}

		stack<PAIR> st;
		int island = 0;
		int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
		int dy[] = { -1, -1, 0, 1, 1, 1, 0, -1};

		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (field[i][j]) {
					st.push(PAIR(i, j));
					while (!st.empty()) {
						int x = st.top().first;
						int y = st.top().second;
						st.pop();
						field[x][y] = false;
						for (int k = 0; k < 8; k++) {
							int nextX = x + dx[k];
							int nextY = y + dy[k];
							if (field[nextX][nextY]) {
								st.push(PAIR(nextX, nextY));
							}
						}
					}
					island++;
				}
			}
		}
		cout << island << endl;
	}
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    cout << *max_element(ALL(A)) - *min_element(ALL(A)) << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(all(a));

    cout << abs(a[0] - a[n - 1]) << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

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


Measured memory_bytes: 256
//B - Multiple of 9
#include<bits/stdc++.h>
using namespace std;
int read(){
	int x;scanf("%d",&x);return x;
}
char ch[2001020];
int ans = 0;
int main()
{
	cin>>ch;
	int L = strlen(ch);
	for(int i = 0;i < L;i++) {
		ans += (int)(ch[i]-'0');
		ans %= 9;
	}
	if(ans) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

#define pii pair<int,int> 
#define piii pair<int,pair<int,int> >
#define ff first
#define ss second
#define pb push_back

int main(){
	// freopen("input.txt","r",stdin);
	string s;
	cin>>s;
	s.pb('T');
	int x,y;
	cin>>x>>y;
	int cnt = 0,cnt2 = 0;
	vector<int> v1;
	vector<int> v2;

	for(int i = 0;i < s.length();i++){
		if(s[i] == 'F') cnt ++;
		else{
		if(cnt2 == 0){
			v1.pb(cnt);
		}
		else v2.pb(cnt);
		cnt = 0;
		cnt2 = 1 - cnt2;
		}
	}


	// for(int i = 0;i < v2.size();i++){
	// 	cout<<v2[i]<<" ";
	// }
	// cout<<endl;


	int dp[16005];
	fill(dp,dp+16005,0);
	dp[v1[0] + 8000] = 1;
	vector<int> v;
	for(int i = 1;i <v1.size();i++){
		for(int j = 0;j < 16005;j++){
			if(dp[j]){
				dp[j] = 0;
				v.pb(j+v1[i]);
				v.pb(j-v1[i]);
			}
		}
		for(int j = 0;j < v.size();j++){
			// cout<<i<<" "<<v[j]<<endl;
			dp[v[j]] = 1;
		}
		v.clear();
	}


	int dp2[16005];
	fill(dp2,dp2+16005,0);
	dp2[8000] = 1;
	for(int i = 0;i <v2.size();i++){
		for(int j = 0;j < 16005;j++){
			if(dp2[j]){
				dp2[j] = 0;
				v.pb(j+v2[i]);
				v.pb(j-v2[i]);
			}
		}
		for(int j = 0;j < v.size();j++){
			dp2[v[j]] = 1;
		}
		v.clear();
	}

	if(dp[8000+x] == 1 && dp2[8000+y]) cout<<"Yes\n";
	else cout<<"No\n";

	return 0;
}

Measured memory_bytes: 512
table = [[ 0 for i in range(13)] for j in range(4)]

n = int(input())

i = 0 
while i < n:
    s,num = input().split()
    num = int(num)
    
    if   s == "S":
        table[0][num-1] = 1
    elif s == "H":
        table[1][num-1] = 1
    elif s == "C":
        table[2][num-1] = 1
    else:    # D 
        table[3][num-1] = 1

    i += 1

for i,elem_i in enumerate(table):
    for j,elem_j in enumerate(elem_i):
        if elem_j ==1:
            continue

        if i == 0:
            s_str='S'
        elif i == 1:
            s_str='H'
        elif i == 2:
            s_str='C'
        else:
            s_str='D'
        print (s_str + " " + str(j+1))


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

using namespace std;

using ll = long long;

constexpr ll INF = 1e18;

struct Dinic {
    using T = ll;

    struct Edge {
        int to;
        T cap;
        int rev;  //行き先、容量、逆辺
        Edge(int to, T cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    vector< vector<Edge> > G;
    vector<int> level, iter;

private:
    void bfs(int s) {
        fill(level.begin(), level.end(), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while (!que.empty()) {
            int v = que.front();
            que.pop();
            for (const Edge& e : G[v]) {
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    T dfs(int v, int t, T f) {
        if (v == t) return f;
        for (int& i = iter[v]; i < G[v].size(); ++i) {
            Edge& e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                T d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    Dinic(int V) : G(V), level(V, -1), iter(V, 0) {}

    void add_edge(int from, int to, T cap) {
        G[from].emplace_back(to, cap, G[to].size());
        G[to].emplace_back(from, 0, G[from].size() - 1);
    }

    T max_flow(int s, int t) {
        T flow = 0;
        while (true) {
            bfs(s);
            if (level[t] < 0) return flow;
            fill(iter.begin(), iter.end(), 0);
            T f;
            while ((f = dfs(s, t, INF)) > 0) {
                flow += f;
            }
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    Dinic dinic(n + 2);
 
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        if (a >= 0) {
            ans += a;
            dinic.add_edge(0, i + 1, a);
        } else {
            dinic.add_edge(i + 1, n + 1, -a);
        }
    }
 
    for (int i = 1; i <= n; i++) {
        for (int j = i * 2; j <= n; j += i) {
            dinic.add_edge(j, i, INF);
        }
    }
    
    ans -= dinic.max_flow(0, n + 1);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rrep(i, b, a) for(int (i) = (b); (i) > (a); (i)--)
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, pair<int, int>> iii;


int arr[2005];

int main() {
	FASTIO;

	int n, k; cin >> n >> k;
	rep(i, 0, n) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	int ans = 0;
	rep(i, 0, k) ans += arr[i];
	cout << ans;
	return 0;
}




Measured memory_bytes: 3536
#include<bits/stdc++.h>
#define m7 1000000007
using namespace std;
int dp[1 << 22 + 1][21], allmask, X[21][21];
int n;
 
int solve(int mask,int pre_man) {
	if (mask == allmask) 
		return 1;
	if (pre_man == n || mask > allmask)
		return 0;
	if (dp[mask][pre_man] != -1) return dp[mask][pre_man];
	
	dp[mask][pre_man] = 0;
	
	for (int i = 0; i < n; i++) {
		if (X[pre_man][i] && !(mask & (1<<i)) ) {
			dp[mask][pre_man] = (dp[mask][pre_man] + solve( mask | (1 << i) ,pre_man + 1) ) % m7;
		}
	}
	//cout << mask << ' ' << pre_man <<' '<< dp[mask][pre_man] << endl;
	return dp[mask][pre_man];
}
int main()
{
	memset(dp, -1, sizeof dp);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			cin >> X[i][j];
	}
	allmask = (1 << n) - 1;
	cout<<solve(0, 0);
 
	
 
	return 0;
}

Measured memory_bytes: 688384
#include <iostream>
#include <deque>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

struct edge{
  llint to, cost;
  edge(){}
  edge(llint a, llint b){
    to = a, cost = b;
  }
};

llint n, m;
llint u[100005], v[100005], s[100005];
vector<edge> G[100005];
bool used[100005];
P val[100005];

void dfs(int v, int p, llint c)
{
  used[v] = true;
  if(p != -1) val[v] = P(-val[p].first, c-val[p].second);
  for(int i = 0; i < G[v].size(); i++){
    if(G[v][i].to == p) continue;
    if(used[G[v][i].to]) continue;
    dfs(G[v][i].to, v, G[v][i].cost);
  }
}

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

	cin >> n >> m;
  for(int i = 1; i <= m; i++){
    cin >> u[i] >> v[i] >> s[i];
    G[u[i]].push_back(edge(v[i], s[i]));
    G[v[i]].push_back(edge(u[i], s[i]));
  }

  val[1] = P(1, 0);
  dfs(1, -1, 0);

  //for(int i = 1; i <= n; i++) cout << val[i].first << " " << val[i].second << endl;

  llint lb = 1, ub = inf;
  for(int i = 1; i <= n; i++){
    if(val[i].first < 0) ub = min(ub, val[i].second-1);
    else lb = max(lb, 1-val[i].second);
  }
  for(int i = 1; i <= m; i++){
    llint bunsi = s[i] - (val[u[i]].second + val[v[i]].second);
    llint bunbo = val[u[i]].first + val[v[i]].first;
    if(bunbo == 0){
      if(bunsi != 0){
        cout << 0 << endl;
        return 0;
      }
    }
    else{
      if(abs(bunsi) % abs(bunbo)){
        cout << 0 << endl;
        return 0;
      }
      llint x = bunsi/bunbo;
      lb = max(lb, x);
      ub = min(ub, x);
    }
    //cout << lb <<  " " << ub << endl;

  }
  cout << max(ub-lb+1, 0LL) << endl;
  return 0;
}


Measured memory_bytes: 16512
import math

class Point:
	zero = None
	def __init__(self, x, y):
		self.x = x
		self.y = y
	def __str__(self):
		return f"{self.x} {self.y}"
	def distance(self, point):
		if(point == 0):
			return math.sqrt(self.x**2 + self.y**2)
		dx = self.x - point.x
		dy = self.y - point.y
		return math.hypot(dx, dy)

def main():
	n, d = map(int, input().split())
	c = 0
	for _ in range(n):
		x, y = map(int, input().split())
		p = Point(x, y)
		if(p.distance(0) <= d):
			c += 1
	print(c)

main()

Measured memory_bytes: 9132
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;




signed main() {
    ll n;
    cin >> n;
    
    vll p(n);
    ll not10 = 101;
    ll n10c = 0;
    
    ll sum = 0;
    
    rep(i, n) {
        cin >> p[i];
        sum += p[i];
        
        if (p[i] % 10 != 0) {
            not10 = min (p[i], not10);
            n10c ++;
        }
    }
    
    if (sum % 10 == 0 && n10c != 0) {
        sum -= not10;
    }
    
    if (sum % 10 == 0) sum = 0;
    
    

    mes(sum);
    
    
    
}


Measured memory_bytes: 3600
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=200000+10;

char s[N];

int main() {
    scanf("%s",s+1); int n=strlen(s+1),ans=n;
    for (re int i=1,top=0;i<=n;++i) {
        if (s[i]=='S') ++top;
        else if (top) ans-=2,--top;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int keta(int n);
int main(void){
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF){
        printf("%d\n",keta(a+b));
    }
    return 0;
}

int keta(int n){
    int s=0,k=1;
    while(n/k>0){
        s++;
        k*=10;
    }
    return s;
}

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

const double EPS = 1e-8;
const double INF = 1e12;

//point
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}
// line
struct L : public vector<P> {
	L(const P& a, const P& b) {
		push_back(a); push_back(b);
	}
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;								  // a--c--b on line
}

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

P projection(const L &l, const P &p) {
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}
P reflection(const L &l, const P &p) {
	return p + (double)2 * (projection(l, p) - p);
}
double distanceLP(const L &l, const P &p) {
	return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
	return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
	if (intersectLS(l, s)) return 0;
	return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
	const P r = projection(s, p);
	if (intersectSP(s, r)) return abs(r - p);
	return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
	if (intersectSS(s, t)) return 0;
		return min({distanceSP(s, t[0]), distanceSP(s, t[1]), distanceSP(t, s[0]), distanceSP(t, s[1])});
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	L li(P{x1, y1}, P{x2, y2});
	int q;
	cin >> q;
	for(int i=0; i<q; ++i) {
		double x, y;
		cin >> x >> y;
		P p(x, y);
		P ans = projection(li, p);
		cout << fixed << setprecision(15) << ans.real() + 0 << " " << ans.imag() + 0 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3352
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=0

l=[A[0]]
for i in range(len(A)-1):
    l.append(l[-1]+A[i+1])
    if (l[-1]-l[-2])>2*l[-2]:
        ans=0
    else:
        ans+=1

print(ans+1)



Measured memory_bytes: 14276
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 1000000000
#define MOD 1000000007
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
using ll = long long;
using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
pair<int,int> bag[249];
map<ll,ll> cnt;
ll ans=0;
int main()
{
 //freopen("in.txt", "r", stdin);
 //freopen("out.txt", "w", stdout);
  ll n,V;
  cin >> n >> V;
  for(int i=0;i<n;i++)
  {
        cin >> bag[i].first >> bag[i].second;
  }
  cnt[0]=0;
  for(int i=0;i<n;i++)
        if(bag[i].first<=V)
  {
        for(map<ll,ll>::reverse_iterator it=cnt.rbegin();it!=cnt.rend();it++)
        {
        ll v;
        ll w;
        v=it->first+bag[i].first;
        w=it->second+bag[i].second;
        if(v>V)
        continue;
        cnt[v]=max(cnt[v],w);
        ans=max(ans,w);
        }
        ll record=0;
        for(map<ll,ll>::iterator it =cnt.begin();it!=cnt.end();)
        {
        if(it->first&&it->second<=record)
        cnt.erase(it++);
        else
        {
        record =it->second;
        it++;
        }
        }
        ans=max(ans,record);
  }
  cout << ans<<endl;
 //fclose(stdin);
 //fclose(stdout);
 return 0;
}


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

int main() {
  int l, r, d;
  cin >> l >> r >> d;

  int ans = 0;
  for (int i = l; i <= r; ++i) {
    if (i % d == 0) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3620
def insertionSort(A, n, g):
    cnt_local = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            j = j - g
            cnt_local += 1
        A[j+g] = v
    return cnt_local

cnt_all = 0
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))

G = [int((3**i-1)/2)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
m = len(G)
for i in range(m):
    cnt_all += insertionSort(A, n, G[i])

print(m)
print(*G)
print(cnt_all)
print(*A, sep='\n')



Measured memory_bytes: 53284
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

// DEBUG TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
  *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}

void solve()
{ 
  int n;
  cin>>n;
  vector<int> inp(n);
  for (auto &x:inp) cin>>x;
  sort(rall(inp));
  
  int sum = inp[0];
  int used = 2;

  for (int i=1;i<n && used < n;i++){
    sum+=2*inp[i];
    used+=2;
    if (used == n+1) sum-=inp[i];
  }
  
  cout<<sum<<endl;
}


/*
  5 4 3 2 1

  5

  4 5 -> 4
  4 5 3 -> 7





*/
signed main(){
  int t = 1;
  // cin>>t;
  while (t--)
  solve();
}
// Check MOD values plox :(


Measured memory_bytes: 4836
/*
 * main.cpp
 *
 *  Created on: 2020/04/07
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

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

	int m_len = (int)S.size() - 2;
	int len = (int)S.size();

	char first = S.at(0);
	char tale = S.at(len-1);

	printf("%c%d%c", first, m_len, tale);

	return 0;
}




Measured memory_bytes: 256
/*
17D8101013F 森田　匡博
JOI0654.cpp 2019/10/31
ID:key4 使用言語:C++
*/

#include <iostream>
#include <cmath>
#include <string>

int main()
{
  int mb = 0; //マルバツ
  long long int N;
  std::cin >> N;

  std::string str;
  std::cin >> str;

  //std::cout << str[1];

  for(int i = 0; i < N; i++) {
    if(i != N - 1) {
      char s1 = str[i];
      char s2 = str[i+1];
      if((s1 == 'O' && s2 == 'X') || (s1 == 'X' && s2 == 'O')) {
	mb++;
	i += 1;
      }
    }
  }

  std::cout << mb << "\n";

  return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
typedef pair<pair<int,int>,pair<int,int>> PP;
#define rep(i,N) for(int i=0;i<N;i++)

int main(){
    int n,m;
    cin>>n>>m;
    int a[n],b[n];
    vector<P>p(n);
    priority_queue<int> pq;
    rep(i,n){
        cin>>a[i]>>b[i];
//        p[i]=make_pair(a[i],b[i]);
        p[i] = make_pair(a[i],b[i]);
    }
    sort(p.begin(),p.end());
    int now = 1;
    ll ans=0;
    int c = 0;
    for(int i=1;i<=m;i++){
//        cout<<i<<endl;
        while(i==p[c].first){
            pq.push(p[c].second);
            c++;
            //p.erase(p.begin());
            //if(p.empty())break;
        }
        if(pq.empty())continue;
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}

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

int main(){
    int n;
    cin >> n;

    map<long long int, int> number;
    vector<long long int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(number.find(a[i]) == number.end()) number[a[i]] = 1;
        else number[a[i]] += 1;
    }

    long long int ans = 0;
    for(auto num : number){
        ans += num.first * num.second;
    }

    int q;
    cin >> q;

    for(int i=0; i<q; i++){
        long long int b, c;
        cin >> b >> c;
        
        if(number.find(b) == number.end()){
            cout << ans << endl;
            continue;
        }

        if(number.find(c) == number.end()) number[c] = number[b];
        else number[c] += number[b];
        ans += (c - b) * number[b];

        number.erase(b);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 7852
#include<set>
#include<map>
#include<cmath>
#include<deque>
#include<stack>
#include<ctime>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<iostream>
#include<algorithm>
#define LL long long
#define ULL unsigned long long
using namespace std;
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 50
#define INF 0x3f3f3f3f
int a[MAXN+5];
int main(){
	int n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			ans+=a[i]*a[j];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
dp = [[0]*3 for _ in range(n+1)]
for i in range(n):
  dp[i+1][0] = max(dp[i][1],dp[i][2])+l[i][0]
  dp[i+1][1] = max(dp[i][0],dp[i][2])+l[i][1]
  dp[i+1][2] = max(dp[i][0],dp[i][1])+l[i][2]
print(max(dp[n]))

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

int func(int A, int B, int C) {
    if (A%2 == 1 || B%2 == 1 || C%2 == 1) {
        return 0;
    }
    if (A == B && A == C) {
        return -1;
    }
    
    return func((B+C)/2, (C+A)/2, (A+B)/2) + 1;
}

int main() {
    // input
    int A, B, C;
    cin >> A >> B >> C;
    
    int ans = func(A, B, C);
    cout << ans << "\n";
    return 0;
}


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

using namespace std;
const int N = 200000 + 10;
typedef long long ll;
vector<int> path[N];
int vis[N];
int n;
struct node
{
    int x, id;
    node(){};
    node(int __x, int __id)
    {
        x = __x;
        id = __id;
    }
};
void bfs()
{
    queue<node> q;
    memset(vis, 0,sizeof(vis));
    q.push(node(1, 1)), q.push(node(n, 2));
    while(!q.empty())
    {
        node in = q.front();
        q.pop();
        for(int i = 0; i<path[in.x].size(); i++)
        {
            int y = path[in.x][i];
            if(!vis[y])
            {
                vis[y] = in.id;
                q.push(node(y, in.id));
            }
        }
    }
}
int main()
{

    scanf("%d", &n);
    for(int i = 0; i<n-1; i++)
    {
        int u, v;
        scanf("%d%d", &u,&v);
        path[u].push_back(v);
        path[v].push_back(u);
    }
    bfs();
    int one = 0, two = 0;
    for(int i = 1; i<=n; i++)
    {
        if(vis[i] == 1)
            one ++;
        if(vis[i] == 2)
            two ++;
    }
    if(one > two)
    {
        printf("Fennec\n");
    }
    else printf("Snuke\n");
    return 0;
}


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

map<int,int> m;
map<int,int> mp;

int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		int A;
		cin >> A;
		A--;
		if(m.find(A)!=m.end())m[A]++;
		else m.insert(make_pair(A,1));
	}
	
	for(auto it=m.begin();it!=m.end();it++){
		int B=it->second;
		if(mp.find(B)!=mp.end())mp[B]++;
		else mp.insert(make_pair(B,1));
	}
	
	vector<pair<int,int>> mpmp;
	for(auto it=mp.begin();it!=mp.end();it++){
		mpmp.push_back(*it);
	}
	int M=mpmp.size();
	
	for(int K=1;K<=N;K++){
		int ok=0,ng=N/K+1;
		while(abs(ok-ng)>1){
			int mid=(ok+ng)/2;
			long long tmp=0;
			for(int i=0;i<M;i++){
				int C=mpmp[i].first,D=mpmp[i].second;
				tmp+=min(mid,C)*D;
			}
			if(tmp>=(long long)mid*K)ok=mid;
			else ng=mid;
		}
		printf("%d\n",ok);
	}
	
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int d, g;
    cin >> d >> g;
    vector< P > v(d);
    for( int i = 0; i < d; ++i ) {
        cin >> v[i].F >> v[i].S;

    }

    int res = INF;
    for( int i = 0; i < (1 << d); ++i ) {
        int mxp = -1;
        int mxnum;
        int bi = 0;
        int tmp = i;
        int point = 0;
        int cnt = 0;
        for( int j = 0; j < d; ++j ) {
            if( tmp & 1 ) {
                point += 100 * (j + 1) * v[j].F + v[j].S;
                cnt += v[j].F;

            } else {
                mxp = 100 * (j + 1);
                mxnum = j;

            }
            tmp >>= 1;
        }
        if( point >= g ) {
            res = min(res, cnt);

        } else {
            if( point + mxp * v[mxnum].F < g ) {
                continue;

            }
            point = g - point;
            cnt += point / mxp;
            if( point % mxp != 0 ) {
                ++cnt;

            }
            res = min(res, cnt);

        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
void dfs(int,int);
int w,h,mat[50][50],flagb,flagw,cnt;
int main(){
  int i,j,bcnt,wcnt;
  string data[50];
  while(1){
    bcnt=0;
    wcnt=0;
    cin >> w >> h;
    if(w==0&&h==0) break;
    for(i=0;i<h;i++){
      cin >> data[i];
    }  
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(data[i][j]=='B') mat[i][j]=1;
        else if(data[i][j]=='W') mat[i][j]=2;
        else mat[i][j]=0;
      }
    }
   
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cnt=0;
	flagb=0;
	flagw=0;
        if(mat[i][j]==0){
	  dfs(i,j);
	  if(flagb==1&&flagw==1){
	    bcnt+=0;
	    wcnt+=0;
	  }
	  else if(flagb==1){
	    bcnt+=cnt;
	  }
          else if(flagw==1){
	    wcnt+=cnt;
	  }
	}
      }
    }
    cout << bcnt << ' ' << wcnt << endl;
  }
  return 0;
}
void dfs(int i,int j){
  if(mat[i][j]==3) return ;
  if(mat[i][j]==1){
    flagb=1;
    return ;
  }
  if(mat[i][j]==2){
    flagw=1;
    return ;
  }
  if(mat[i][j]==0){
    cnt++;
  } 
  if(mat[i][j]==3) return ;
  mat[i][j]=3;
  if(j+1<w) dfs(i,j+1);
  if(0<=j-1) dfs(i,j-1);
  if(i+1<h) dfs(i+1,j);
  if(0<=i-1) dfs(i-1,j);
}
//1:B 2:W

Measured memory_bytes: 1336
N,M=map(int,input().split())
x=[]
for i in range(M):
  a,b=map(int,input().split())
  if a==1:
    x.append(b)
  if b==N:
    x.append(a)
l=len(x)
if len(set(x))==l:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

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

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

   s[3] = '8';
   cout << s << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;

int main()
{
	long long extra = 0;
	int n;
	long long sum = 0;
	long long totd = 0;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		long long c, d;

		scanf("%lld %lld", &c, &d);

		sum += c*d;

		totd += sum / 10;

		do
		{
			extra = sum / 10;

			sum %= 10;

			sum += extra;

			totd += sum / 10;
		} while (sum >= 10);

		totd += d;
	}

	printf("%lld\n", totd - 1);

 	return 0;
}


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

namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            Dice sai = new Dice();
            int[] quiz;
            var pips = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int num = int.Parse(Console.ReadLine());
            for (int i = 0; i < num; ++i)
            {
                quiz = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Console.WriteLine(sai.GetPip(pips, quiz));
            }
        }
    }
    internal class Dice
    {
        Random rnd = new Random();
        internal int GetPip(int[] pips, int[] q)
        {
            while (pips[1] != q[0] || pips[0] != q[1])
            {
                RandomShake(pips);
            }
            return pips[3];
        }

        private void GoNorth(int[] pips)
        {
            int tmp = pips[0];
            pips[0] = pips[1];
            pips[1] = pips[5];
            pips[5] = pips[4];
            pips[4] = tmp;

        }
        private void GoWest(int[] pips)
        {
            int tmp = pips[0];
            pips[0] = pips[2];
            pips[2] = pips[5];
            pips[5] = pips[3];
            pips[3] = tmp;
        }
        private void RandomShake(int[] pips)
        {
            if (rnd.Next(2) == 1)
            {
                GoNorth(pips);
            }
            else
            {
                GoWest(pips);
            }
        }
    }
}


Measured memory_bytes: 18420
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "deque"
#include "cmath"
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	int L[109];
	for (int i = 1; i <= N; i++) {
		cin >> L[i];
	}
	int cnt = 0;
	for (int i = 1; i <= N - 2; i++) {
		for (int j = i + 1; j <= N - 1; j++) {
			for (int k = j + 1; k <= N; k++) {
				if ((L[i] - L[j])*(L[j] - L[k])*(L[k] - L[i]) != 0
					&& abs(L[i] - L[j]) < L[k] && L[k] < L[i] + L[j]) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

struct mint
{
	ll x;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a)
	{
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a)
	{
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a)
	{
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const
	{
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const
	{
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const
	{
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const
	{
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const
	{
		return pow(mod - 2);
	}
	mint& operator/=(const mint a)
	{
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const
	{
		mint res(*this);
		return res /= a;
	}

};

int main()
{
	int n, k;
	cin >> n >> k;

	mint minv;
	for (int i = 0; i <= k; i++) minv += i;
	mint maxv;
	for (int i = n + 1; n + 1 - k < i; i--) maxv += i;
	mint ans = maxv - minv + 1;

	for (int i = k + 1; i <= n + 1; i++) {
		minv += i;
		maxv += n + 2 - i;
		ans += maxv - minv + 1;
	}
	cout << ans.x << endl;
}

Measured memory_bytes: 3648
//
// Created by hide on 2020/05/15.
//

//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define PRINT(message) cout<<message<<endl //10^5:配列の最大のrange(素数列挙などで使用)

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素
int D, G;
int answer = std::numeric_limits<int>::max();
vector<int> p, c;

unordered_map<int, int> mp;

int main(){
    ll A;
    double B;
    cin >> A >> B;
    ll ib = B*100+0.5;
    A *= ib;
    A/=100;
    PRINT(A);

}

Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=110;
struct edg{
	int to,next;
}e[2*N];
int n,size,dep[N],maxn,maxp,f[N],head[N];
int siz[N];
long long fin=1e18,ans;
void add(int x,int y)
{
	size++;e[size].to=y;e[size].next=head[x];head[x]=size; 
}
void dfs(int x,int fa)
{
	f[x]=fa;dep[x]=dep[fa]+1;if (dep[x]>=maxn) maxn=dep[x],maxp=x;
	for (int i=head[x];i;i=e[i].next)
	{
		int y=e[i].to;if (y==fa) continue;
		dfs(y,x);
	}
}
int dfss(int x,int fa)
{
	int son=0;dep[x]=dep[fa]+1;
	for (int i=head[x];i;i=e[i].next)
	{
		int y=e[i].to;if (dep[y]) continue;
		son++;
		siz[dep[x]+2]=max(siz[dep[x]+2],dfss(y,x));
	}
//	cout<<x<<" "<<dep[x]+1<<" "<<siz[dep[x]+1]<<" "<<son<<endl;
	return son;
}
int main()
{
	scanf("%d",&n);
	for (int x,y,i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	dfs(1,0);memset(dep,0,sizeof(dep));
	dfs(maxp,0);memset(dep,0,sizeof(dep));
	if (maxn&1)
	{
		for (int i=1;i<=maxn/2;i++) maxp=f[maxp];
		siz[2]=max(siz[2],dfss(maxp,0));
		siz[1]=1;
		ans=1;
		for (int i=1;i<=(maxn+1)/2;i++)
			ans*=siz[i];
		fin=ans;
		for (int i=head[maxp];i;i=e[i].next)
		{
			memset(siz,0,sizeof(siz));memset(dep,0,sizeof(dep));
			int fp=e[i].to;
			dep[maxp]=1;dep[fp]=1;
			siz[1]=2;
			siz[2]=max(siz[2],dfss(maxp,0));
			siz[2]=max(siz[2],dfss(fp,0));
			ans=1;
			for (int i=1;i<=(maxn+1)/2;i++)
				ans*=siz[i];
			fin=min(fin,ans);
		}
	}
	else
	{
	//	for (int i=1;i<=n;i++) cout<<f[i]<<" ";
		for (int i=1;i<maxn/2;i++) maxp=f[maxp];
	//	cout<<maxp<<endl; 
		dep[maxp]=1;dep[f[maxp]]=1;
		siz[1]=2;
		siz[2]=max(siz[2],dfss(maxp,0));
		siz[2]=max(siz[2],dfss(f[maxp],0));
		ans=1;
		for (int i=1;i<=(maxn+1)/2;i++)
			ans*=siz[i];
		fin=ans;
	}	
	printf("%d %lld",(maxn+1)/2,fin); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    string a, b;
    cin >> a >> b;
    a += b;
    int n = stoi(a);

    for (int i = 0; i <= 1000; i++) {
        if (n == i * i) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    a, b = map(int, raw_input().split())
    if b - a >= 2019:
        print 0
        return
    best = 2018
    for i in xrange(a, b):
        for j in xrange(i + 1, b + 1):
            best = min(best, i * j % 2019)
    print best


if __name__ == '__main__':
    main()


Measured memory_bytes: 29164
#include<iostream>

using namespace std;

int main(void){
  string s ,t,u;
  int a,b;
  int count=0;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(s == u){
    a--;
  }else if(t == u){
    b--;
  }
  
   cout<<a <<' ' << b;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int S,s,h,m;
  cin >> S ;
  h=S/3600;
  m=S%3600/60;
  s=S%3600%60;

  cout << h << ":" << m << ":" << s << endl;
	
  return 0;
  }

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	int n;
	cin >> n;
	
	int ok = 1;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if(a % 2 == 0) {
			if(a%3 && a%5) {
				ok = 0;
			}
			
			if(!ok) {
				cout << "DENIED" << endl;
				return;
			}
		}
	}
	
			cout << "APPROVED" << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
    int n,r=0;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    r+=a[n-1]+b[0];
    cout<<r<<endl;
  return 0;
}

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

typedef long long ll;

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

	int D;
	cin >> D;

	cout << "Christmas";

	for(int i = 25; i > D; i--) {
		cout << " Eve";
	}

	cout << endl;
}

Measured memory_bytes: 256
from itertools import accumulate

n,k = map(int, input().split())
mod = 10**9+7

a = [0] + list(accumulate([i for i in range(n+1)]))

ans = 0
for i in range(k,n+2):
    ans += (a[n+1]-a[n+1-i]) - (a[i]) + 1

print(ans%mod)


Measured memory_bytes: 87104
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main() {
    int H,W;
    cin >> H >> W;
    int a[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a[i][j];
        }
    }
    vector<pair<int, int>> ans(0);
    int cnt = 0;
    
    for(int i = 0; i < H * W - 1; i++){
        int I = i / W;
        int J = i % W;
        if(I % 2) J = W - i % W - 1;
        
        int I_next = (i+1) / W;
        int J_next = (i+1) % W;
        if(I_next % 2) J_next = W - (i+1) % W - 1;
        
        if(a[I][J] % 2){
            ans.push_back({I, J});
            ans.push_back({I_next, J_next});
            a[I_next][J_next]++;
            cnt++;
        }
    }
    cout << cnt << endl;
    for(int i = 0; i < cnt; i++){
        cout << ans.at(2*i).first+1 << " " << ans.at(2*i).second+1 << " ";
        cout << ans.at(2*i+1).first+1 << " " << ans.at(2*i+1).second+1 << endl;
    }
}

Measured memory_bytes: 5104
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using namespace std;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int a, b, c;

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

	cin >> a >> b >> c;
	if((b*10+c) % 4 == 0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
  return 0;
}


Measured memory_bytes: 256