akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 110;
string G[maxn];
int good[2][maxn], h,w;

int main()
{
    while (cin >> h >> w) {
        memset(good,0,sizeof(good));
        FOR(i,0,h)
            cin >> G[i];
        FOR(i,0,h) FOR(j,0,w) if (G[i][j] == '#')
            good[0][i] = good[1][j] = true;
        FOR(i,0,h) if (good[0][i]) {
            FOR(j,0,w) if (good[1][j]) {
                cout << G[i][j];                
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long int 
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i)) 
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'
 
 
 
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
 map<ll,ll>m;
ll ar[1000005];
int main()
{
	_fastio
	ll a;
	cin>>a;
	cout<<a+(a*a)+(a*a*a)<<en;
}

Measured memory_bytes: 3652
fn main() {
    let (n, a, b): (usize, usize, usize) = readln();
    let mut v: Vec<i64> = readln();
    v.sort_by_key(|x| -x);
    let x = v[a-1];
    let mut ave: f64 = 0.0;
    for i in 0..a {
        ave += v[i] as f64 / a as f64;
    }
    let k1 = v.iter().enumerate()
        .filter(|&(i, val)| val - x == 0)
        .map(|(i, val)| i)
        .min().unwrap();
    let k2 = v.iter().enumerate()
        .filter(|&(i, val)| val - x == 0)
        .map(|(i, val)| i)
        .max().unwrap();
    let from = max(a-1, k1);
    let to = if x == v[0] {
        min(b-1, k2)
    } else {
        from
    };
    let mut ans : u64 = 0;

    let mut dp = [[0 as u64; 55]; 55];
    dp[0][0] = 1;
    for i in 1..51 {
        dp[i][0] = 1;
        for j in 1..i+1 {
            dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
        }
    }

    for i in from..to+1 {
        let s = (k2 - k1 + 1) as usize;
        let t = (i - k1 + 1) as usize;
        ans += dp[s][t];
    }
    println!("{}", ave);
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n { vs.push(readln()); }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T> where T: FromLn {
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ans+=i*(n+1-i);
    }ll a,b;
    for(int i=1;i<n;i++)
    {
        cin>>a>>b;
        if(a>b)
        swap(a,b);
        ans-=a*(n+1-b);
    }
    cout<<ans;
    
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()



int main()
{
	int n;
	cin>>n;
	int odd=0;
	REP(i,n)
	{
		int t;
		cin>>t;
		if(t%2==1)odd++;
	}
	cout<<(odd%2==0?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
import copy

H, W, K = map(int, input().split())

c = []

for i in range(H):
    row = list(input())
    c.append(row)

count = 0
for i in range(2 ** len(c)):        
    tmp_c = [c[k] for k in range(len(c)) if ((i >> k) & 1)]
    for j in range(2 ** len(c[0])):
        tmp_tmp_c = copy.copy(tmp_c)
        for l in range(len(tmp_c)):
            tmp_tmp_c[l] = [tmp_c[l][k] for k in range(len(tmp_c[0])) if ((j >> k) & 1)]

        total_blacks = 0
        for i in range(len(tmp_tmp_c)):
            total_blacks += tmp_tmp_c[i].count('#')
        
        if total_blacks == K:
            count += 1

print(count)

Measured memory_bytes: 9276
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//modint
template<typename T> T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		T t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
template<typename T> T modpow(T x, int k) {
	if (k == 0)return 1;
	if (k % 2 == 0) return modpow(x * x, k / 2);
	else return x * modpow(x, k - 1);
}

template<int mod> class modint {
public:
	ll val;
	modint(ll a) {
		val = a % mod;
	}
	modint operator+(const modint& r) {
		return modint((this->val + r.val) % mod);
	}
	modint operator-(const modint& r) {
		return modint((this->val - r.val) % mod + ((this->val - r.val) % mod < 0) * mod);
	}
	modint operator*(const modint& r) {
		return modint((((this->val % mod) * (r.val % mod))) % mod);
	}
	modint operator/(const modint& r) {
		return modint(this->val * modinv<ll>(r.val, mod) % mod);
	}
	modint& operator+=(const modint& r) {
		*this = *this + r;
		return *this;
	}
	modint& operator-=(const modint& r) {
		*this = *this - r;
		return *this;
	}
	modint& operator*=(const modint& r) {
		*this = *this * r;
		return *this;
	}
	modint& operator/=(const modint& r) {
		*this = *this / r;
		return *this;
	}

};

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	vector<ll> B(62, 0);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 62; j++) {
			if (A[i] & (1LL << j))B[j]++;
		}
	}
	modint<MOD> ans = 0;
	for (int i = 0; i < 62; i++) {
		ans += modint<MOD>(B[i] * (N - B[i])) * modpow(modint<MOD>(2), i);
	}
	cout << ans.val << endl;
}

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

int main(){

    // 1. 入力情報.
    int A, B, C, K;
    scanf("%d %d %d %d", &A, &B, &C, &K);
    
    // 2. A < B < C と できるか.
    int ans = 0;
    while(A >= B) B <<= 1, ans++;
    while(B >= C) C <<= 1, ans++;
    
    // 3. 出力.
    printf("%s\n", (ans <= K) ? "Yes" : "No");
    return 0;
    
}

Measured memory_bytes: 3760
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };


ll N, K;
vector<ll> A;

ll floor(ll a, ll b) {
	if ((a >= 0 && b > 0) || (a <= 0 && b < 0))return abs(a) / abs(b);
	else {
		return -((abs(a)+ abs(b) - 1) / abs(b));
	}
}

ll ceil(ll a, ll b) {
	if ((a >= 0 && b > 0) || (a <= 0 && b < 0))return (abs(a) + abs(b) - 1) / abs(b);
	else {
		return (-abs(a)) / abs(b);
	}
}

ll num(ll X) {
	ll ans = 0;
	REP(i, 0, N) {
		if (A[i] < 0) {
			ll ind = N - distance(lower_bound(A.begin(), A.end(), ceil(X, A[i])), A.end());
			if (ind <= i) ind = i + 1;
			ans += max(0LL, N - ind);
		}
		else if (A[i] == 0) {
			if (X >= 0)ans += N - 1 - i;
		}
		else {
			ll ind = distance(A.begin(), upper_bound(A.begin(), A.end(), floor(X, A[i])));
			ans += max(0LL, ind - i - 1);
		}
	}
	return ans;
}

int main() {
	cin >> N >> K;
	A.resize(N);
	REP(i, 0, N) cin >> A[i];
	sort(A.begin(), A.end());

	ll l = (ll)-1e18 - 1;
	ll r = (ll)1e18 + 1;
	while (r - l > 1) {
		ll mid = l + (r - l) / 2;
		if (num(mid) >= K) r = mid;
		else l = mid;
	}
	PRI(r);

	return 0;
}

Measured memory_bytes: 4764
import math

N, M = map(int, input().split())

mod = int(1e9+7)

if abs(N-M) > 1:
  ans = 0
elif abs(N-M) == 1:
  ans = (math.factorial(N) % mod) * (math.factorial(M) % mod) % mod
else:
  ans = 2 * (math.factorial(N) % mod) * (math.factorial(M) % mod) % mod

print(ans)

Measured memory_bytes: 4092
#include <iostream>
using namespace std;
int main(void){
    int x ;
    int i = 1;
    int n = 10000;
    for(i=1 ; i<=n ; i++){
        cin >> x;
        if(x==0){
            break;
        }
    cout << "Case " << i  << ": " << x << endl;
    }
    
}


Measured memory_bytes: 3068
// Aizu Vol-1 0176: What Color?
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p;

typedef struct { char *a; int r, g, b; } T;
T color[8] = {
	{ "black",     0,   0,   0 },
	{ "blue",      0,   0, 255 },
	{ "lime",      0, 255,   0 },
	{ "aqua",      0, 255, 255 },
	{ "red",	 255,   0,   0 },
	{ "fuchsia", 255,   0, 255 },
	{ "yellow",  255, 255,   0 },
	{ "white",   255, 255, 255 },
};

int r, g, b;

void colorCode(void)
{
	if (*p <= '9') r = *p - '0';
	else r = (tolower(*p) - 'a') + 10;
	p++; r <<= 4;
	if (*p <= '9') r += *p - '0';
	else r += (tolower(*p) - 'a') + 10;
	p++;
	if (*p <= '9') g = *p - '0';
	else g = (tolower(*p) - 'a') + 10;
	p++; g <<= 4;
	if (*p <= '9') g += *p - '0';
	else g += (tolower(*p) - 'a') + 10;
	p++;
	if (*p <= '9') b = *p - '0';
	else b = (tolower(*p) - 'a') + 10;
	p++; b <<= 4;
	if (*p <= '9') b+= *p - '0';
	else b += (tolower(*p) - 'a') + 10;
}

int main()
{
	int i, d, k, min;
	T *t;

	while (1) {
		gets(p = buf);
		while (isspace(*p)) p++;
		if (*p == '0') break;
		if (*p == '#') p++;
		colorCode();
		min = 200000;			// > 3*256^2
		for (i = k = 0, t = color; i < 8; i++, t++) {
			d = (r - t->r)*(r - t->r) + (g - t->g)*(g - t->g) + (b - t->b)*(b - t->b);
			if (d < min) k = i, min = d;
		}
		puts(color[k].a);
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    ll ans = vec[0];
    int k = 0;
    if(n % 2 == 0){
    for(int i = 1; i < n/2; i++){
        ans += 2 * vec[i];
    }
    cout << ans;
    }
    else{
      for(int i = 1; i < n/2; i++){
        ans += 2 * vec[i];
    }
    cout << ans + vec[n/2];
    }  
    
}









Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = s; i <= (int)(e); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int W, H, N;
  cin >> W >> H >> N;
  vector<string> area(H, string(W, 'W'));
  rep(i, N)
  {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1)
    {
      rep(i_x, x) rep(i_y, H)
          area[i_y][i_x] = 'B';
    }
    else if (a == 2)
    {
      FOR(i_x, x, W - 1)
      rep(i_y, H)
          area[i_y][i_x] = 'B';
    }
    else if (a == 3)
    {
      rep(i_x, W) rep(i_y, y)
          area[i_y][i_x] = 'B';
    }
    else if (a == 4)
    {
      rep(i_x, W) FOR(i_y, y, H - 1)
          area[i_y][i_x] = 'B';
    }
  }
  //printVector(area);
  int ans = 0;
  rep(y, H) rep(x, W)
  {
    if (area[y][x] == 'W')
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
sx, sy, ex, ey = (int(n) for n in input().split(" "))
trial = int(input())
for _ in range(trial):
    x, y = (int(n) for n in input().split(" "))
    if sx == ex:
        print(-x, y)
    elif sy == ey:
        print(x, -y)
    else:
        grad = (ey - sy) / (ex - sx)
        y_seg = sy - (grad * sx)
        per_grad = -1 / grad
        per_y_seg = y - (per_grad * x)
        ans_x = (y_seg - per_y_seg) / (-1 * (grad - per_grad))
        ans_y = per_grad * ans_x + per_y_seg
        diff_x = ans_x - x
        diff_y = diff_x * per_grad
        print(ans_x + diff_x, ans_y + diff_y)



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


int main() {
    int a, b, h, m;
    double ang, c;
    cin >> a >> b >> h >> m;
    ang = abs((6 * m) - (30 * h + 0.5 * m));
    c = a * a + b * b - 2 * a * b * cos(ang / 180.0 * M_PI);
    printf("%.20lf\n",sqrt(c));
    return 0;
}

Measured memory_bytes: 4192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;


int main(){
    string s;
    cin>>s;
    int c=0;

    for(int i=0;i<s.size();i++){
        if(s[i]=='0') c++;
    }
    int n=s.size()-c;
    int m = min(c,n);
    cout<<m*2<<endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoder.A
{
    public class Program
    {
        public static string S { get; private set; }
        public static string T { get; private set; }
        public static int A { get; private set; }
        public static int B { get; private set; }
        public static string U { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetTexts().ToList();
            S = inputs[0];
            T = inputs[1];
            var xx = CR.GetIntegers().ToList();
            A = xx[0];
            B = xx[1];
            U = CR.Get();

            if (U == S)
            {
                return $"{A - 1} {B}";
            }

            return $"{A} {B - 1}";
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int data;
	scanf("%d",&data);
	for(int p=0;p<data;p++)
	{
		int num,st;
		scanf("%d%d",&num,&st);
		int ans=0;
		for(int i=0;i<=6;i++)
		{
			if(num%2==0)
			{
				if(st&(1<<i))ans+=(num-1)<<i;
				else ans+=num<<i;
			}
			else
			{
				if(st&(1<<i))ans+=num<<i;
				else ans+=(num-1)<<i;
			}
		}
		printf("%d\n",ans);
	}
}

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

int main()
{
    ll n,k,d; cin>>n>>k>>d;
    n=abs(n);
    ll x = min(k, n/d);
    k-=x;
    n-=x*d;
    if(jor(k)) cout<<n;
    else cout<<abs(n-d);
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;

map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

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

    map<ll, int> y;
    for (int i = 1; i <= N; i++) {
        map<ll, int> now = prime_factor(i);
        for (auto itr = now.begin(); itr != now.end();++itr)
            y[itr->first] += itr->second;
    }

    ll ans = 1;
    for (auto itr = y.begin(); itr != y.end(); ++itr) {
        ans *= (itr->second) + 1;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main(){
  int i,j,k;
  int N;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++)
    scanf("%d ",&A[i]);
  qsort(A,N, sizeof(int), compare_int);
  if(A[N/2]-A[N/2-1] >= 0)
  printf("%d\n",A[N/2]-A[N/2-1]);
  else
    puts("0");
  return 0;
}



Measured memory_bytes: 892
import itertools

N=int(input())
num=[3,5,7]
dig=10
p=[1]*dig
for i in range(dig-1):
    p[i+1]=p[i]*10
    
ans=0

def check(n):
    strn=str(n)
    for i in range(len(num)):
        if not (str(num[i]) in strn):
            return False
    return True
        
ans=0
flag=1
for d in range(3,dig):#桁数
    if flag==0:
        break
    for pro in itertools.product(num, repeat=d):
        temp=0
        for j in range(d):
            temp+=pro[-1-j]*p[j]
        if temp>N:
            flag=0
            break
        if check(temp):
            ans+=1
        
print(ans)
    
        
    




Measured memory_bytes: 42588
//ABC126 D.Even Relation
//ある条件を満たすようにグラフの頂点に色を塗る問題
//
//
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

struct edge {
    int to,cost;
};

vector<edge> G[100010];
int color[100010];

void dfs(int v, int p, int c) {
    color[v] = c;
    for(auto e : G[v]) {
        if(e.to == p) continue;
        if(e.cost%2 == 1) dfs(e.to, v,1-c);
        else dfs(e.to, v, c);
    }
}

int main()
{
int N;
cin >> N;
rep(i,N-1) {
    int u,v,w;
    cin >> u >> v >> w;
    --u;--v;
    G[u].push_back({v,w});
    G[v].push_back({u,w});
}

dfs(0, -1, 0);
rep(i,N) cout << color[i] << endl;

return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DEBUG(x)                   cout << '>' << #x << ':' << x << endl;
//log(n)*n*n
unordered_map<string,vector<int> > m;
bool check(int mid,string s,int n)
{
    if(mid>=n)
        return false;
    string s1="",s2="";
    for(int i=0; i<mid; i++)
    {
        s1+=s[i];
    }
    int temp=0;
    m[s1].push_back(mid-1);
    for(int i=mid; i<n; i++)
    {
        s1.erase(s1.begin());
        s1.push_back(s[i]);
        if(m[s1].size()!=0)
        {
            if(m[s1][0]<=(i-mid))
                return true;
        }
        else
            m[s1].push_back(i);
    }
    return false;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie();
    cout.tie();
    int n;
    string s;
    cin>>n;
    cin>>s;
    int len=s.size()/2;
    int last=0;
    int hi=len+2,lo=1,mid;
    while(hi-lo>5)
    {
        //m.clear();
        mid=(lo+hi)>>1;
        if(check(mid,s,n)==true)
        {
            lo=mid;
        }
        else
            hi=mid-1;

    }
    while(check(lo,s,n)==true)
        lo++;
    cout<<lo-1<<endl;
    return 0;
}


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


using namespace std;

int main(){
   long long n,m,x,sum=0;
  // vector<long long>a;
   cin>>n>>m;
   for(long long i=0;i<m;i++){
    cin>>x;
    sum=sum+x;;
   }
   if(sum>n)
    cout<<-1;
   else
    cout<<n-sum;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> m;
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    m[A] += B;
  }
  ll ans = 0;
  for (auto n : m) {
    ans += (ll)min(M, n.second) * n.first;
    M -= min(M, n.second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    map<string, int>m;
    rep(i, n){
        string a;
        cin >> a;
        m[a]++;
    }

    for (auto aa : m){
        if(aa.second==2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;    // printf("%d\n", N);
    return 0;
}

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

using namespace std;

int main(void){
  int N, D, X;
  cin >> N >> D >> X;
  int eaten = 0;
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    eaten += 1 + (D - 1) / A;
  }
  cout << X + eaten << endl;
}


Measured memory_bytes: 256
using System;

namespace kadai1._1
{
    class Program
    {
        static void Main(string[] args)
        {
                //Console.WriteLine("A,Bの値を入力してください。");
                string[] array = Console.ReadLine().Split(' ');
                int a = int.Parse(array[0]);
                int b = int.Parse(array[1]);
                int sum = 0;

                if (a < 3 || b > 20)
                {
                    Console.WriteLine("エラー");
                }

                else
                {
                    for (int i = 0; i < 2; i++)
                    {
                        if (a > b)
                        {
                            sum = sum + a;
                            a--;
                        }
                        else
                        {
                            sum = sum + b;
                            b--;
                        }
                    }

                    
                    Console.WriteLine(sum);
                   
                }
            }
        }
    }

Measured memory_bytes: 11092
from copy import copy
d = int(input())
c = [0] + list(map(int, input().split(' ')))

s = [[]] + [[0] + list(map(int, input().split(' '))) for _ in range(d)]

t = 0 # 算出結果

ca = [0] * (1 + 26) # 放置された不満の数々
cat = [] # 不満度の最適な算出のための一時配列
cat2 = []
dc = 0 # カレントな満足度
#dl = [] # 満足度のログ

for i in range(1, d + 1):
    cat = [0]
    for i2 in range(1, 27):
        cat2 = copy(ca)
        cat2[i2] = i
        cat.append(s[i][i2] + sum(c[i3] * (i - ca[i3]) for i3 in range(1, 27)))
    t = cat.index(max(cat))
    dc += s[i][t]
    ca[t] = i
    dc -= sum(c[i3] * (i - ca[i3]) for i3 in range(1, 27))
    print(t)

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

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

    static class APayment {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            if (n % 1000 == 0) {
                out.println("0");
            } else {
                int y = n % 1000;
                out.println(1000 - y);
            }
        }

    }
}



Measured memory_bytes: 35868
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

x = ns()
n = len(x)

ans = n
i = 0
cs = 0
while i < n:
    if x[i] == 'S':
        cs += 1
        i += 1
    else:
        ct = 0
        while i < n and x[i] == 'T':
            ct += 1
            i += 1
        ans -= min(cs, ct) * 2
        cs -= min(cs, ct)

print(ans)

Measured memory_bytes: 3500
#include <iostream>

using namespace std;

int main()
{
    string x,Sunny,Cloudy,Rainy;
    cin>>x;
    if(x=="Sunny")
    {
        cout<<"Cloudy";
    }
    else if(x=="Cloudy")
    {
        cout<<"Rainy";
    }
    else if(x=="Rainy")
    {
        cout<<"Sunny";
    }

    return 0;
}

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

int main() {
    string aa;
    long a=0;
    cin>>aa;
    int i=0;
    for(i=0;i<aa.length();i++)
    {
        a+=aa[i]-'0';
    }
    if(a%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	string s;
	cin >> s;
	int cnt[36] = {};
	for(auto c:s){
		cnt[c-'a']++;
		if(cnt[c-'a'] >= 2){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc063.contest.atcoder.jp/tasks/abc063_b

Measured memory_bytes: 3592
/*pata hai na?*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const ld pi=acos(-1);
const int inf=1e18,M=1e9+7;
const int N=110;

int dp[N][5][2];

string s;

int rec(int ind,int k,int tight)
{
    if(k<0)
        return 0;

    if(ind==0)
    {
        if(k==0)
            return 1;
        return 0;
    }

    if(dp[ind][k][tight]!=-1)
        return dp[ind][k][tight];

    int x=s[ind-1]-'0';
    int mx=(tight==1)?x:9;

    int res=0;
    int nt;

    for(int i=0;i<=mx;++i)
    {
        if(i==x)
            nt=tight;
        else
            nt=0;

        res+=rec(ind-1,k-(i!=0),nt);
    }

    return (dp[ind][k][tight]=res);
}

void solve()
{
    mem(dp,-1);

    int k;
    cin>>s>>k;

    int n=s.length();
    reverse(all(s));

    int ans=rec(n,k,1);
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 256
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)

hash = Hash.new(0)
sum = 0
ans = 0
a.each do |v|
  sum += v
  ans += hash[sum] if hash[sum] > 0
  ans += 1 if sum == 0
  hash[sum] += 1
end
puts ans


Measured memory_bytes: 31108
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X; cin >> N >> X;
    int m[110];
    rep(i, N) cin >> m[i];
    sort(m, m + N);
    rep(i, N) X -= m[i];
    cout << N + X / m[0] << endl;


    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;

     signed main(){
     int n,x,t;
     cin>>n>>x>>t;
     if(n%x==0)cout<<(n/x)*t<<endl;
     else cout<<(n/x+1)*t<<endl;
     

     }


 


 






    





      

        


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

	using namespace std;
	inline void FAST_IO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

	int main(){
		FAST_IO();

		int n,l;
		cin >> n >> l;
		vector<int> in(n);

		int sum = 0;
		for(int i = 0; i < n; ++i){
			in[i] = i+l;
			sum+=in[i];
		}

		int r = 0;
		for(int i = 0; i < n; ++i){
			if(abs(in[i]) < abs(in[r]))
				r = i;
		}
		
		cout << sum - in[r] << endl;

		

		return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007;
#define INF (1e9)
#define print(x) cout << x << endl;

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string s;
    cin >> s;
    s[3] = '8';
    print(s);
    return 0;
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    ll func(ll a,ll b,ll c)
    {
        return b/c-a/c+(a%c==0);
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll a,b,c,d;
            cin>>a>>b>>c>>d;
            ll lcm=c*d/__gcd(c,d);
            ll ans=func(a,b,c)+func(a,b,d)-func(a,b,lcm);
            ans=b-a+1-ans;
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
 
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }
 
 
const long long INF = 1LL<<60;
int N;
vector<long long> A;
 
long long solve() {
    vector<long long> left(N+1, 0), right(N+1, 0);
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            left[i+1] = left[i] + A[i];
            right[i+1] = right[i] + A[N-i-1];
        }
        else left[i+1] = left[i], right[i+1] = right[i];
    }
    vector<long long> dp(N+1, -INF);
    dp[0] = 0;
    for (int i = 2; i <= N; i += 2) {
        chmax(dp[i], dp[i-2] + A[i-1]);
        chmax(dp[i], left[i-2] + max(A[i-1], A[i-2]));
    }
 
    if (N % 2 == 0) return dp[N];
    long long res = -INF;
    for (int i = 0; i <= N; i += 2) {
        chmax(res, dp[i] + right[N-i-1]);
    }
 
    //COUT(left); COUT(right); COUT(dp);
 
    return res;
}
 
int main() {
    while (cin >> N) {
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        cout << solve() << endl;
    }
}
 
 
 
 

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

using namespace std;

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

  typedef pair<int, int> P;
  vector<P> a;
  for(int i=1;i<=n;i++){
    int num;
    cin >> num;
    a.push_back( P(num, i) );
  }

  for(int i=0;i<n;i++){
//    cout<<a[i].first<<' '<<a[i].second<<'|';
  }
//  cout<<endl;

  sort(a.begin(), a.end());

  for(int i=0;i<n;i++){
//    cout<<a[i].first<<' '<<a[i].second<<'|';
  }
//  cout<<endl;

  for(int i=0;i<n;i++){
    cout<<a[i].second<<' ';
  }
  cout<<endl;
}

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c;
    while(1<2){
    if(a>b)d=a,a=b,b=d;
    if(b>c)d=b,b=c,c=d;
    if(a<=b&&b<=c){
    cout<<a<<" "<<b<<" "<<c<<endl;
    break;
    }
    }
}


Measured memory_bytes: 3096
n = int(input())
L = [int(i) for i in input().split()]
breaknum = 0
target = 1

for i in range(n):
  if L[i] != target:
    breaknum += 1
  else:
    target += 1

if target != 1 and breaknum != 0:
  print(breaknum)
elif breaknum == n:
  print(-1)
else:
  print(0)

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

int h;
int data[11][5];
int cpdata[11][5];

void clear(){
	int i,j;
	for( i = 0; i < h; i++ ){
		for( j = 0; j < 5; j++ ){
			cpdata[i][j] = 0;
		}
	}
}
void copy(){
		int i,j;
	for( i = 0; i < h; i++ ){
		for( j = 0; j < 5; j++ ){
			cpdata[i][j] = data[i][j];
		}
	}
}
void dist(){
	int i,j;
	for( i = 0; i < h; i++ ){
		for( j = 0; j < 5; j++ ){
			data[i][j] = cpdata[i][j];
		}
	}
}

int main(){
	int i,j,k;
	
	while( cin >> h ){
		int ans = 0;
		bool eflag = true;
		
		if(!h)break;
		for( i = 0; i < h; i++ ){
			for( j = 0; j < 5; j++ ){
				cin >> data[i][j];
			}
		}
		
		while( eflag ){
			eflag = false;
			copy();
			//行h-1から処理をすると簡単
			//読み込みはdataから、書き込みはcpdataへ
			for( i = h-1; i >= 0; i-- ){
				for( j = 0; j < 5; j++ ){
					if( data[i][j] == 0 )
						continue;
					int l,r;
					for( k = j; k >= 0;k--){
						if( data[i][k] != data[i][j] )
							break;
					}
					l = k;
					for( k = j; k < 5;k++){
						if( data[i][k] != data[i][j] )
							break;
					}
					r = k;
					//消す
					if( r - l - 1 >= 3 ){
						ans += data[i][j];
						cpdata[i][j] = 0;
						eflag = true;
					}
				}
			}
			dist();
			clear();
			copy();
			//落とす
			for( i = h-1; i >= 0; i-- ){
				for( j = 0; j < 5; j++ ){
					for( k = i+1; k < h; k++ ){
						if( cpdata[k][j] != 0 )
							break;
					}
					if( k != i+1 ){
						cpdata[k-1][j] = cpdata[i][j];
						cpdata[i][j] = 0;
					}
				}
			}
			dist();
			clear();
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin >> N >> D;
  
  int ans;
  if(N%(2*D+1)==0){
    ans = N/(2*D+1);
  }else{
    ans = N/(2*D+1)+1;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl "\n"
const int N=5+1e5;
using namespace std;
ll a[N],n,k;
ll memo[N][102];
ll solve(int index,int s)
{
    ll &ret=memo[index][s];
    if(ret!=-1)
        return ret;
    if(index>=n-1)
      return ret=0;
    else
    {
        ret=(solve(index+1,0)+abs(index+1<n?(a[index+1]-a[index]):1e15));
        for(int i=2;i<=k;++i)
        ret=min(ret,solve(index+i,0)+abs(index+i<n?(a[index+i]-a[index]):(ll)1e15));
        return ret;
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>k;
    for(int i=0;i<n;++i)
        cin>>a[i];
        memset(memo,-1,sizeof memo);
       ll ans=solve(0,0);
        for(int i=1;i<k;++i)
        ans=min(ans,solve(0,i));
        cout<<ans;

}



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

#define ll long long
#define ld long double

#define pii pair<int, int>
#define pci pair<char, int>
#define pcc pair<char, char>

#define vi vector <int>
#define vll vector<long long>
#define vld vector<long double>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

#define vvi vector<vi>
#define vvll vector<vll>
#define vvld vector<vld>
#define vvb vector<vb>
#define vvc vector<vc>
#define vvs vector<vs>

#define vpii vector<pii>
#define vpci vector<pci>
#define vpcc vector<pcc>

#define all(v) (v).begin(), (v).end()
#define allrev(v) (v).rbegin(), (v).rend()
#define allcomp(v) (v).begin(), (v).end(), comp
#define allrevcomp(v) (v).rbegin(), (v).rend(), comp

const int MOD = 1e9 + 7;
const ld pi = 3.1415926535897932384626433832;

#define line cout<<"\n";
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

void solve(int test_case){

    int n, k;
    int sum = 0;
    cin >> n >> k;

    vi v(n);

    for(int i = 0; i < n; i++)
        cin >> v[i];

    sort(all(v));

    for(int i = 0; i < k; i++)
        sum += v[i];

    cout << sum;

}

int main(){
    fast
    int test = 1;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3656
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    D, X = map(int, input().split())
    ans = X
    for _ in range(N):
        ans += (D-1)//(int(input())) + 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d", &a,&b);
    if(1 <= a && a <= 9 && 1 <= b && b <= 9){
        printf("%d\n",a*b);
    }else{
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<P> path[805];
int t[805];
int d[805];
int dis[805];

void check(int a,int p){
	if(dis[a]!=-1 || d[a]==1)return;
	dis[a]=p;
	for(int i=0;i<path[a].size();i++){
		check(path[a][i].first,p+path[a][i].second);
	}
}

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	int sd=0,se=0;
	while(cin>>n){
		if(!n)break;
		for(i=0;i<n;i++)path[i].clear();
		memset(d,0,sizeof(d));
		for(i=0;i<n-1;i++){
			cin>>t[i];
			t[i]--;
		}
		sd=0;
		for(i=0;i<n-1;i++){
			cin>>a;
			path[i+1].push_back(make_pair(t[i],a));
			path[t[i]].push_back(make_pair(i+1,a));
			d[i+1]++,d[t[i]]++;
			sd+=a;
		}
		for(i=0;i<n;i++){
			if(d[i]==1)continue;
			for(j=0;j<path[i].size();j++){
				a=path[i][j].first;
				if(d[a]==1)continue;
				sd+=path[i][j].second;
			}
		}
		se=0;
		for(i=0;i<n;i++){
			if(d[i]==1)continue;
			memset(dis,-1,sizeof(dis));
			check(i,0);
			for(j=0;j<n;j++){
				if(se<dis[j])se=dis[j];
			}
		}
		cout<<sd-se<<endl;
	}
}



Measured memory_bytes: 3240
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std;
 
void primeno(ll n){
    ll ans=1,count=0;
    while(!(n%2)){
        n>>=1;
        count++;
    }
    if(count) ans=2;
    for(ll i=3;i<=sqrt(n);i+=2){
        count=0;
        while( n % i == 0){
            count++;
            n=n/i;
        }
        if(count) ans++;
    }
    if(n>2) ans++;
    cout<<ans;
}

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



int main() 
{ 
    ll a,b;
    cin>>a>>b;
    ll hcf=gcd(a,b);
    // cout<<hcf<<endl;
    primeno(hcf);
} 


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    int goodsNum, maxWeight;
    cin >> goodsNum >> maxWeight;

    int values[goodsNum];
    int weights[goodsNum];
    rep(i, goodsNum) {
        cin >> values[i] >> weights[i];
    }

    int table[goodsNum + 1][maxWeight + 1];
    rep(w, maxWeight + 1) {
        table[0][w] = 0;
    }
    rep(i, goodsNum) {
        rep(w, maxWeight + 1) {
            if (w >= weights[i]) {
                table[i+1][w] = std::max(table[i][w - weights[i]] + values[i], table[i][w]);
            } else {
                table[i+1][w] = table[i][w];
            }
        }
    }

    cout << table[goodsNum][maxWeight] << endl;
}


Measured memory_bytes: 7024