akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var s = Sarray()[0];
            var hs = new HashSet<long>();
            var preA = s;
            hs.Add(s);
            for (var i = 2; ; ++i)
            {
                var ai = preA % 2 == 0 ? preA / 2 : 3 * preA + 1;
                if(hs.Contains(ai))
                {
                    WriteLine(i);
                    return;
                }
                hs.Add(ai);
                preA = ai;
            }
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> vx(n), vy(n);
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    vx[i] = x + y;
    vy[i] = x - y;
  }

  ll vx_max = *max_element(vx.begin(), vx.end());
  ll vx_min = *min_element(vx.begin(), vx.end());
  ll vy_max = *max_element(vy.begin(), vy.end());
  ll vy_min = *min_element(vy.begin(), vy.end());

  cout << max(vx_max - vx_min, vy_max - vy_min) << endl;
}

Measured memory_bytes: 6368
from collections import Counter

h, w = map(int, input().split())
a = Counter(''.join(input() for _ in range(h)))

center = h * w % 2
side = (h // 2) * (w % 2) + (w // 2) * (h % 2)

if sum(a[i] % 2 for i in a) != center:
    print('No')
    exit()
a = {i: a[i] - (a[i] % 2) for i in a}
print('Yes' if sum(a[i] % 4 == 2 for i in a) <= side else 'No')


Measured memory_bytes: 9484
import math

(a,b,C) = [int(i) for i in input().split()]

c = math.sqrt(a ** 2 + b ** 2 - (2 * a * b) * math.cos(C * math.pi / 180))
h = float(b * math.sin(C * math.pi / 180))
s = float(a * h / 2)
l = float(a + b + c)

print(s)
print(l)
print(h)

Measured memory_bytes: 6872
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
 
    string n; cin>>n;

    if(n.back()=='3'){
        cout << "bon" << ln;
    }else if(n.back()=='0' || n.back()=='1' || n.back()=='6' || n.back()=='8'){
        cout << "pon" << ln;
    }else{
        cout << "hon" << ln;
    }

    return 0;
}

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

using namespace std;

#define int long long
int A,B,C,D;

int Calc(int x){
	int s = (A + x - 1) / x;
	int t = B / x;
	//cout << x << " " << t - s + 1 << endl;
	return t - s + 1;
}
signed main(){
	cin >> A >> B >> C >> D;
	cout << (B - A + 1) - Calc(C) - Calc(D) + Calc(C * D / __gcd(C,D));
	return 0;
}

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

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

  int n, a[3];
  cin >> n >> a[0] >> a[1] >> a[2];

  vector<string> q(n);
  for (auto& e: q) cin >> e;

  vector<char> result;

  for (int i = 0; i < n; ++i) {
    string s = q[i];

    int x = s[0] - 'A';
    int y = s[1] - 'A';
    if (!a[x] && !a[y]) {
      result.clear();
      break;
    }

    if (a[x] > a[y]) {
      --a[x]; ++a[y];
      result.push_back(s[1]);
      continue;
    }

    if (a[x] < a[y]) {
      ++a[x]; --a[y];
      result.push_back(s[0]);
      continue;
    }

    if (i + 1 < n && q[i + 1].find(s[0]) != string::npos) {
      ++a[x]; --a[y];
      result.push_back(s[0]);
      continue;
    }

    --a[x]; ++a[y];
    result.push_back(s[1]);
  }

  if (result.empty()) {
    cout << "No\n";
    return 0;
  }

  cout << "Yes\n";
  for (char c: result)
    cout << c << '\n';
}

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

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

ans = num2alpha(n)

print(ans.lower())

Measured memory_bytes: 61828
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);

    auto x = new int[](n);
    auto y = new int[](n);
    auto h = new int[](n);

    int hm;

    foreach (i ; 0 .. n) {
        scan(x[i], y[i], h[i]);
        hm = max(hm, h[i]);
    }

    int calcH(int cx, int cy, int x, int y, int h) {
        return max(h - abs(x - cx) - abs(y - cy), 0);
    }

    foreach (cx ; 0 .. 100 + 1) {
        foreach (cy ; 0 .. 100 + 1) {
            foreach (hh ; hm .. hm + 201) {
                bool ok = true;
                foreach (i ; 0 .. n) {
                    if (calcH(cx, cy, x[i], y[i], hh) != h[i]) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    writeln(cx, " ", cy, " ", hh);
                    return;
                }
            }
        }
    }
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO                        \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 1000001
#define MOD 1000000007
#define PI 3.14159265358979323846
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
#define Rep(i, a, b) for (int i = a; i < b; ++i)
typedef long long ll;
typedef pair<int, int> pr_int;


int main()
{
	//freopen("input.txt", "r", stdin);
	int h, n;
	cin >> h >> n;
	ll a, s = 0;
	Rep(i, 0, n) {
		cin >> a;
		s += a;
	}
	if (s >= h)
		cout << "Yes";
	else
		cout << "No";


	return 0;
}



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

int A, B, C, D;

int main() {
    cin >> A >> B >> C >> D;

    cout << min(A, B) + min(C, D) << endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;

	vector<int> A(N), B(N);
	rep(i, 0, N)cin >> A[i] >> B[i];

	sort(all(A));
	sort(all(B));

	if (SZ(A) % 2 == 1)
	{
		int l = A[N / 2], r = B[N / 2];
		cout << r - l + 1 << endl;
	}
	else
	{
		int l = A[N / 2 - 1] + A[N / 2], r = B[N / 2 - 1] + B[N / 2];
		cout << r - l + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 6364
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		int x[], y[], z[];
		int count;

		while (true) {
			n  =sc.nextInt();
			m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}

			x = new int[m];
			y = new int[m];
			z = new int[m];
			for (int i = 0; i < m; i++) {
				String s = sc.next();
				if (s.equals("xy")) {
					x[i] = sc.nextInt();
					y[i] = sc.nextInt();
				} else if (s.equals("xz")) {
					x[i] = sc.nextInt();
					z[i] = sc.nextInt();
				} else if (s.equals("yz")) {
					y[i] = sc.nextInt();
					z[i] = sc.nextInt();
				}
			}

			count = 0;
			TreeSet<Integer> ts = new TreeSet<Integer>();
			for (int i = 0; i < m ;i++) {
				ts.clear();
				for (int j = i + 1; j < m; j++) {
					if (x[i] == 0) {
						if (x[j] != 0 && (y[i] == y[j] || z[i] == z[j])) {
							ts.add(x[j]);
						}
					} else if (y[i] == 0) {
						if (y[j] != 0 && (x[i] == x[j] || z[i] == z[j])) {
							ts.add(y[j]);
						}
					} else {
						if (z[j] != 0 && (x[i] == x[j] || y[i] == y[j])) {
							ts.add(z[j]);
						}
					}
				}
				count += n - ts.size();
			}
			
			System.out.println(n * n * n - count);
		}
	}
}

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

using namespace std;

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

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, s.size() - 8) << endl;
}



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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;
    ll money = 1000, kabu = 0;
    bool buy = true;
    rep(i, n) {
        bool plus = false;
        if (buy) {
            ll cur = ll_inf;
            while (i < n && a[i] <= cur) {
                cur = a[i];
                i++;
                plus = true;
            }
            if (i == n) {
                break;
            }
            kabu += money / cur;
            money -= (money / cur) * cur;
            buy = false;
        } else {
            ll cur = 0;
            while (i < n && a[i] >= cur) {
                cur = a[i];
                i++;
                plus = true;
            }
            money += kabu * cur;
            kabu = 0;
            buy = true;
        }
        if (plus) i--;
    }
    cout << money << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;
string out(int x) {
	string res = to_string(x);
	while (res.size() < 2)res = "0" + res;
	return res;
}
string output(int sum) {
	string ans;
	ans += out(sum / 3600);
	ans += ":";
	sum %= 3600;
	ans += out(sum / 60);
	ans += ":";
	sum %= 60;
	ans += out(sum);
	return ans;
}
signed main() {
	int t, h, s;
	while (cin >> t >> h >> s, t != -1) {
		int sum = 120*60;
		sum -= 60 * 60 * t + 60 * h + s;
		cout << output(sum) << endl;
		cout << output(sum * 3) << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    let c = read::<i64>();
    let ans = vec![
        (a - b).abs() + (b - c).abs(),
        (a - c).abs() + (c - b).abs(),
        (b - a).abs() + (a - c).abs(),
        (b - c).abs() + (c - a).abs(),
        (c - a).abs() + (a - b).abs(),
        (c - b).abs() + (b - a).abs(),
    ]
    .iter()
    .cloned()
    .min()
    .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const int MOD = 1e9 + 7;

map<string, int> m;

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string(s);
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    int ans = 0;
    for (auto it : m) {
        ans += it.se * (it.se - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
n = int(input())
lst = list(map(int, input().split()))

count1 = {}
count2 = {}

for i in range(n):
    if i%2==0:
        if lst[i] in count1:
            count1[lst[i]] += 1
        else:
            count1[lst[i]] = 1
    else:
        if lst[i] in count2:
            count2[lst[i]] += 1
        else:
            count2[lst[i]] = 1

sorted1 = sorted(count1.items(), key=lambda x:x[1], reverse=True)
sorted2 = sorted(count2.items(), key=lambda x:x[1], reverse=True)

sorted1.append((-1,0))
sorted2.append((-1,0))

if sorted1[0][0]!=sorted2[0][0]:
    print(n-sorted1[0][1]-sorted2[0][1])
else:
    a = n-sorted1[0][1]-sorted2[1][1]
    b = n-sorted1[1][1]-sorted2[0][1]
    print(min(a,b))


Measured memory_bytes: 20724
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	int l, r;
	cin >> l >> r;
	int m = 2019;
	int x = l % m;
	int y = r % m;

	if (l + (m - x) <= r)
	{
		cout << 0 << en;
	}
	else
	{
		int ans = 1e9;
		zip(i, l, r + 1)
		{
			zip(j, i + 1, r + 1)
			{
				int p = (i * j) % m;
				ans = min(ans, p);
			}
		}
		cout << ans << en;
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define test int t; cin>>t;
#define MOD 998244353LL
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt() { ll x; cin>>x; return x; }

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS

    ll n = nxt();
    ll ans = 0;
    for(ll i = 1; i<=n; i++){
        if(n%i == 0){
            ans+=(n/i)-1;
        }
        else ans+=n/i;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>

int main(void) {
   int N;
   int L;
   int a;
   int b;
   scanf("%d %d", &N, &L);

   a = N + L - 1;
   
   if(a <= 0) {
      b = a;
   }
   else if(L >= 0) {
      b = L;
   }
   else {
      b = 0;
   }

   int c = (a + L) * (a - L + 1) / 2 - b;

   printf("%d\n", c);
}


Measured memory_bytes: 1684
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
l = inp.shift().split(' ')
H = l[0] * 1
W = l[1] * 1
K = l[2] * 1
o = []
idx = 1
r = 0
for (i=0; i<H; i++) {
    a = []
    o[i] = []
    for (j=0; j<W; j++) {
        if (inp[i][j] == '#') {
            a.push(j)
        }
    }
    if (a.length == 0) {
        if (r) {
            o[i] = r
        } else {
            o[i] = 'e'
        }
    } else {
        j = 0
        while(true) {
            k = a.shift()
            if (k === undefined) break;
            while(j <= k) {
                o[i][j] = idx
                j++
            }
            idx++
        }
        while(j<W) {
            o[i][j] = idx-1
            j++
        }
        r = o[i]
    }
}

if (o[0] == 'e') {
    j = 1
    while(o[j] == 'e') j++
    r = o[j]
    j--
    while(j >= 0) {
        o[j--] = r
    }
}
console.log(o.map(a => a.join(" ")).join('\n'))


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a; cin >> a;
	long long int happiness = 0, x = 0, y = 0, z = 0;
	if (a / 500 > 0)
	{
		happiness = 1000 * (a / 500);
	}
	x = a % 500;
	if (x / 5 > 0)
	{
		happiness = happiness + (5 * (x / 5));
	}
	cout << happiness << endl;
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

int N;
cin >> N;
	string S;
	cin >> S;
	int cnt = 0,ans=0;
	REP(i, S.size()) {
		if (S[i] == 'R')cnt++;
		else ans++;
	}
	if (cnt > ans) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}



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

int main(){
  char str[205];
  scanf("%s", str);
  int n = strlen(str);
  for(int i = n-2; i; i-=2){
    if(strncmp(str, str+i/2, i/2)==0){
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 105
using namespace std;
int n,in[M];
int work() {
    REP(i,1,n) if (in[i]!=0) {
        int j = i;
        while (j+1<=n && in[j+1]!=0) j++;

        int res = *min_element(in+i, in+j+1);
        REP(k,i,j) in[k] -= res;
        return res;
    }
    return 0;
}
int main()
{
    while (~scanf("%d", &n)) {
        int ans = 0;
        REP(i,1,n) scanf("%d", &in[i]);
        while (1) {
            int x = work();
            if (!x) break;
            ans += x;
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


int main()
{
	
	int N;
	string s;
	cin >> N>>s ;
	
	int count=1;
	for (int i = 0; i < N - 1; i++)
	{
		if (s[i] != s[i + 1])
			count++;
	}
	cout << count << endl;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long n, m; cin >> n >> m;
	int sn = sqrtl(n);
	auto calc = [&](long long x, long long y) {
		long long ret = 0;
		while (x) {
			ret += x % y;
			x /= y;
		}
		return ret;
	};
	for (int b = 2; 1LL * b * b <= n; b++) {
		if (calc(n, b) == m) {
			return cout << b << '\n', 0;
		}
	}
	for (int i = sn; i > 0; i--) {
		if ((n - m) % i != 0) continue;
		if (i > m) continue;
		long long x = (n - m) / i + 1;
		if (x > 1 && calc(n, x) == m) {
			return cout << x << '\n', 0;
		}
	}
	if (n == m) {
		return cout << n + 1 << '\n', 0;
	}
	cout << -1 << '\n';
	return 0;
}

Measured memory_bytes: 384
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int A[200005],B[200005];
int32_t main()
{
    speed
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
        cin>>A[i];
    int wsk=0,suma=0;
    int csum=0;
    for(int i=1;i<=m;i++)
    {
        cin>>B[i];
        csum+=B[i];
        if(csum<=k)
        {
            suma=csum;
            wsk=i;
        }
    }
    int wynik=wsk;
    int aktual=wynik;
    for(int i=1;i<=n;i++)
    {
        suma+=A[i];
        aktual++;
        while(wsk>0&&suma>k)
        {
            suma-=B[wsk];
            wsk--;
            aktual--;
        }
        if(suma<=k)
            wynik=max(wynik,aktual);
    }
    cout<<wynik;
    return 0;
}


Measured memory_bytes: 6788
n, m = map(int, input().split())
edges = []
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((a, b, -c))

init_v = 0
INF = float('inf')
dist = [INF]*n
dist[init_v] = 0
for i in range(n):
    for v, v2, c in edges:
        if dist[v2] <= dist[v]+c:
            continue
        dist[v2] = dist[v]+c

negative = [0]*n
for i in range(n):
    for v, v2, c in edges:
        if dist[v2] <= dist[v]+c:
            continue
        dist[v2] = dist[v]+c
        negative[v2] = 1

if negative[-1]:
    print('inf')
else:
    print(-dist[-1])

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

int main() {
  int n,m;
  long long int p;
  cin>>n;
  map<long long int,long long int> vec;
  map<long long int,long long int> vecb;
  for(int i=0;i<n;i++){
    cin>>p;
    if(vec[p]==0){
      vec[p]=1;
    }
    else{
      vec.at(p)++;
    }
  }
  cin>>m;
  vector<long long int> vect(m);  
  for(int i=0;i<m;i++){
    cin>>p;
    vect.at(i)=p;
    if(vecb[p]==0){
      vecb[p]=1;
    }
    else{
      vecb.at(p)++;
    }
  }
  for(int i=0;i<m;i++){
    if(vec[vect.at(i)]<vecb[vect.at(i)]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define vpi vector<pair<int,int> > 
#define vpll vector<pair<lli,lli> > 
#define vvi vector<vector<int> >
#define vvll vector<vector<lli> >
#define vvpi vector< vector<pair<int,int> >
#define maxn 100005
#define mod 1000000007
#define inf 10000000000000000


int main()
{
    fastio;
    int n;
    cin>>n;
    lli a[n];
    lli ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i>0)
        {
            if(a[i-1]>a[i])
            ans+=a[i-1]-a[i],a[i]=a[i-1];
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 5212
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
  printf((a==b)?"Yes":"No");
    return 0;
}

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

template <typename T> T sq(T a) { return a * a; }

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	vector<pair<pair<int, int>, int>> circles(N);
	for (auto& it : circles) {
		cin >> it.first.first >> it.first.second >> it.second;
	}

	double mi = 0;
	double ma = 1e7;
	for (int z = 0; z < 200; z++) {
		double md = (mi + ma) / 2;
		bool good = false;
		auto checkPt = [&](double x, double y) { 
			int cnt = 0;
			for (auto it : circles) {
				cnt += hypot(x - it.first.first, y - it.first.second) * it.second <= md;
			}
			if (cnt >= K) good = true;
		};

		for (int i = 0; i < N; i++) {
			checkPt(circles[i].first.first, circles[i].first.second);
		}
		for (int i = 0; i < N; i++) {
			for (int j = i+1; j < N; j++) {
				double x1, y1, x2, y2;
				tie(x1, y1) = circles[i].first, tie(x2, y2) = circles[j].first;
				double r1 = md / circles[i].second, r2 = md / circles[j].second;
				double d = hypot(x1 - x2, y1 - y2);
				if (r1 + r2 + d < 2 * max({r1, r2, d})) {
					continue;
				}
				double parallel = (sq(d) + sq(r1) - sq(r2)) / 2 / d;
				double perp = sqrt(max(0., sq(r1) - sq(parallel)));
				perp = max(0., perp - 1e-8);
				double xmid = x1 + (x2 - x1) / d * parallel;
				double ymid = y1 + (y2 - y1) / d * parallel;
				double xa = xmid + (y2 - y1) / d * perp, ya = ymid - (x2 - x1) / d * perp;
				checkPt(xa, ya);
				double xb = xmid - (y2 - y1) / d * perp, yb = ymid + (x2 - x1) / d * perp;
				checkPt(xb, yb);
			}
		}
		if (good) {
			ma = md;
		} else {
			mi = md;
		}
	}
	cout << fixed << setprecision(10) << ma << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int n, m, x, y;
vector<int> graph[100010];
int memo[100010];


int rec(int i) {
    if (memo[i] > 0)
        return memo[i];
    int ans = 0;
    for (int j: graph[i])
        chmax(ans, rec(j) + 1);
    memo[i] = ans;
    return ans;
}

int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> x >> y;
        graph[--y].push_back(--x);
    }
    int ans = 0;
    rep(i, n) {
        chmax(ans, rec(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    double  a,b;
    cin >> a >> b;
    cout << ceil((b-1)/(a-1)) << "\n";

}



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

int main(){
    int a,b;
    cin>>a>>b;
    vector<int> v={0,13,1,2,3,4,5,6,7,8,9,10,11,12};
    cout<<(v[a]>v[b]?"Alice":v[a]<v[b]?"Bob":"Draw")<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [s for s in input()]
lis = [str(i)+str(j)+str(k) for i in range(10) for j in range(10) for k in range(10)]
ans = 0
from collections import defaultdict
d = defaultdict(list)
for i,s in enumerate(S):
    d[s].append(i)

for s in lis:
    if d[s[0]]:
        i = min(d[s[0]])
        if d[s[1]]:
            for j in d[s[1]]:
                if j > i:
                    if d[s[2]]:
                        if max(d[s[2]]) > j:
                            ans += 1
                            break
                    break
        else:continue
    else:continue
                            
print(ans)

Measured memory_bytes: 5028
n,p = map(int, input().split())
s = list(map(int, input().strip()))

count = 0

if(p == 2 or p == 5): #10と互いに素ではない場合
    co = 0
    for i in range(n): #1の位から順に数を追加していく
        ne = int(s[n-i-1]) % p
        if(ne == 0):
            co += 1
        count += co
    print(count)
else:
    sta = [0]*p
    sta[0] += 1
    d = 1
    co = 0
    for i in range(n):
        ne = int(s[n-i-1]) * d % p
        co += ne
        co %= p
        sta[co] += 1
        d *= 10
        d %= p
    for i in range(p):
        count += sta[i] * (sta[i]-1) // 2
    print(count)




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

int main() {
    string s;
    int height, width;

    cin >> height;
    cin >> width;
    cout << string(width+2, '#') << endl;
    for(int i=0; i < height; i++) {
        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    cout << string(width+2, '#') << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k ==x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

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

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int h,w,n;
	while(cin >> h >> w >> n){
		vector<P> ab(n);
		REP(i,n) cin >> ab[i].F >> ab[i].S;
		set<P> s;
		set<P> ps;
		REP(i,n) ps.insert(ab[i]);
		vector<LL> ans(10,0);
		REP(i,n){
			REP(mx, 3){
				REP(my, 3){
					int x = max(1,ab[i].F-mx);
					int y = max(1,ab[i].S-my);
					if(x+2 > h or y+2 > w) continue;
					if(!s.count(P(x,y))){
						DEBUG(x); DEBUG(y);
						s.emplace(x,y);
						int num = 0;
						REP(i,3){
							REP(j,3){
								num += ps.count(P(x+i,y+j));
							}
						}
						DEBUG(num);
						ans[num]++;
					}
				}
			}
		}
		DEBUG(SZ(s));
		ans[0] = LL(h-2)*(w-2)-accumulate(ALL(ans),0LL);
		REP(i,10) cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 47872
#include<stdio.h>

int main(){
  int n,i,j,l,k,p[102],m[102][102],kouho;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=100000000;
      for(k=i;k<=j-1;k++){
	kouho=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j]>kouho)m[i][j]=kouho;
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



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

int main(){
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    int ans = INT_MAX;
    int s_size = s.size();
    int t_size = t.size();

    for(int i = 0; i < s_size - t_size+1; i++){
        cnt = 0;
        int tmp = i;
        for(int j = 0; j < t_size; j++){
            if(s.at(tmp) != t.at(j)){
                cnt++;
                // cout << s.at(tmp) << " " << t.at(j) << " " << cnt << endl;
            }else{
                // cout << s.at(tmp) << " " << t.at(j) << " " << cnt << endl;
            }
            tmp++;
        }
        if(cnt < ans){
            ans = cnt;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>

using namespace std;

const long long N = 2e5 + 10;
const long long mod = 1e9 + 7;

long long ans[N];
long long fact[N];
long long dp1[N];
long long dp2[N];
long long n, b, w;

long long power(long long a, long long b) 
{
	if (b == 0)
	{
		return 1;
	}
	long long ans = power(a, b / 2);
	ans = ans * ans;
	ans = ans % mod;
	if (b % 2)
	{
		ans = ans * a;
	}
	ans = ans % mod;
	return ans;
}

void pre() 
{
	fact[0] = 1;
	for (long long i = 1; i < N - 5; i++) 
	{
		fact[i] = 1ll * fact[i - 1] * i % mod;
	}
	return;
}

long long choose(long long x, long long y) 
{
	if (x > y)
		return 0;
	long long ans = fact[y] * 1ll;
	ans = (ans * power(fact[x], mod - 2)) % mod * power(fact[y - x], mod - 2);
	ans = ans % mod;
	return ans;
}


int main() 
{
	pre();
	cin >> b >> w;
	n = b + w;
	for (long long i = 1; i <= n; i++)
	{
		dp2[i] = (1ll * dp2[i - 1] + 1ll * (choose(w - 1, i - 1)) * power(power(2, i), mod - 2) % mod) % mod;
	}
	for (long long i = 1; i <= n; i++) 
	{
		dp1[i] = (1ll * dp1[i - 1] + 1ll * (choose(b - 1, i - 1)) * power(power(2, i), mod - 2) % mod) % mod;
	}
	for (long long i = 1; i <= n; i++)
	{
		ans[i] = (dp2[i - 1] + 1ll * ((1 - dp1[i - 1] - dp2[i - 1]) % mod + mod) % mod  * power(2, mod - 2) % mod) % mod;
	}
	for (long long i = 1; i <= n; i++) 
	{
		cout << ans[i] << endl;
	}
}




Measured memory_bytes: 8448
//Colorful Creatures

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    sort(range(a));
    int c=0,ans=0;
    rep(i,0,n-1){
        c+=a[i];
        if(c*2>=a[i+1])ans++;
        else ans=0;
    }
    cout<<ans+1<<nnn;
    return 0;
}

Measured memory_bytes: 4024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n;
long long a[311111];

int main(){
  ios_base::sync_with_stdio(false);
  
  long long ans = 0;

  cin >> n;
  for(int i=0;i<3*n;i++){
    cin >> a[i];
  }

  sort(a, a+n*3);

  for(int i=0;i<n*2;i+=2){
    ans += a[i+n];
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Sumitrust_2019
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int x = ReadInt();
            int cnt = x / 100;
            int remain = x % 100;
            if (remain <= cnt * 5) WriteLine(1);
            else WriteLine(0);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

int main(){
	IOS;
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n ; ++i){
		cin >> a[i];
	}
	int dp[n];

	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	for(int i=2;i<n ; ++i){
		dp[i] = 1e9;
		for(int j = i-2 ; j<i ; ++j){
			dp[i] = min(dp[i],dp[j] + abs(a[j]-a[i]));
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline long IN(void)
{
  long x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline long Abs(const long x){return x<0?-x:x;}
int main(void)
{
  long X=IN(),K=IN(),D=IN(),quotient=Abs(X)/D;
  X=Abs(X);if(quotient>=K){X-=K*D;return OUT(X),0;}else X-=quotient*D;
  K-=quotient;return (K&1)?OUT(Abs(X-D)):OUT(X),0;
}

Measured memory_bytes: 1528
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int a,b,c; cin >> a >> b >> c;
	if(a+b+c >= 22) puts("bust");
	else puts("win");
}

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

using ll=long long;

int main() {
  int N,T; cin >>N >>T;
  vector<int> t(N);
  rep(i,0,N) cin >>t[i];
  ll ans=0;
  rep(i,0,N-1) ans+=min(t[i+1]-t[i],T);
  cout <<ans+T <<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main()
{
    int A, B, C;
    int K;
    std::cin >> A >> B >> C;
    std::cin >> K;
    int time = 0;
    while(B <= A && time < K){
        B = B*2;
        time++;
    }

    while(C <= B && time < K){
        C = C*2;
        time++;
    }

    if(C>B && B>A){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    //int end;
    //std::cin >> end;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>

int main() {
	int H;
	int W;
	int h;
	int w;
	
	scanf("%d%d%d%d", &H,&W,&h,&w);
	
	printf("%d", H*W - H * w - h * W + h * w);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(void){

  int n,m;

  cin >> n;

  vector<int>s(n),l(n),p(n);

  for(int i=0;i<n;i++){
    cin >> s[i] >> l[i] >> p[i];
  }

  cin >> m;
  vector<int>w(m);

  for(int i=0;i<m;i++)cin >> w[i];

  int dp[400];
  fill(dp,dp+400,-1);
  dp[0]=0;

  for(int i=1;i<400;i++){
    for(int j=0;j<n;j++){
      for(int k=s[j];k<=l[j];k++){
	if(i-k>=0)dp[i]=max(dp[i],dp[i-k]+p[j]);
      }
    }
  }
  
  for(int i=0;i<m;i++){
    if(dp[w[i]]<0){
      cout << -1 << endl;
      return 0;
    }
  }

  for(int i=0;i<m;i++)
    cout << dp[w[i]] << endl;

  return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner scanner = new Scanner(System.in);
    String strings = scanner.next();
    int sumOfNotMatch = 0;
    if (strings.length() % 2 == 1) {
      // 奇数パターン
      for (int i = 0; i <= strings.length() / 2; i++) {
        if (!strings.substring(strings.length() / 2 - i, strings.length() / 2 - i + 1)
            .equals(strings.substring(strings.length() / 2 + i, strings.length() / 2 + i + 1))) {
          sumOfNotMatch++;
        }
      }
    } else {
      // 偶数パターン
      for (int i = 0; i < strings.length() / 2; i++) {
        if (!strings.substring(strings.length() / 2 - i - 1, strings.length() / 2 - i)
            .equals(strings.substring(strings.length() / 2 + i, strings.length() / 2 + i + 1))) {
          sumOfNotMatch++;
        }
      }
    }
    System.out.println(sumOfNotMatch);
  }

}


Measured memory_bytes: 21844