akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 1e5 + 5;

ll n, m, k;
ll fenw[100];

void Solve(){
    cin >> n >> k >> m;
    for(int i = 1; i <= n; i++){
        if(i <= k) cout << m << " "; else{
            if(m > 1e5){
                cout << m - 1 << " ";
            } else{
                cout << m + 1 << " ";
            }

        }
    }


}

int main(){
    Speed;
    int query = 1;
//    cin >> query;
    while(query--) Solve();
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC168_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            // 時針の長さを入力
            double a = int.Parse(input[0]);

            // 分針の長さを入力
            double b = int.Parse(input[1]);

            // 時を入力
            double h = int.Parse(input[2]);

            // 分を入力
            double m = int.Parse(input[3]);

            double angleA = 0;
            double angleB = 0;

            // 時針の角度を計算(720分=12時間で一周、1分で0.5度)
            if (h == 0 ||
                h == 12)
            {
                angleA = m * 0.5;
            }
            else
            {
                angleA = (h * 60 * 0.5) + (m * 0.5);
            }

            // 分針の角度を計算(60分で一周、1分で6度)
            angleB = m * 6;

            // 角度の差(絶対値)を取得
            double angle = Math.Abs(angleA - angleB);

            if (angle > 120)
            {
                angle = 360 - angle;
            }

            // 時針と分針の直線距離を計算(余弦定理)
            double c = Math.Sqrt((a * a) + (b * b) - 2 * a * b * Math.Cos(angle * Math.PI / 180));
            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 27864
#include <iostream>
#include <string>

using namespace std;
int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(u == s) a --;
    if(u == t) b --;
    cout << a << " "<<b<< endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int temp;
		int ans = 1;
		for (int i = 2; i * i <= X; i++) {
			temp = i;
			while (temp * i <= X) {
				temp *= i;
			}
			if (temp > ans) {
				ans = temp;
			}
		}
		System.out.println(ans);
	}
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i <= (n); i++)
#define range(x) (x).begin(), (x).end()
typedef long long LL;

int n, m;
vector<int> adj[200005];

int main(){
    cin >> n >> m;
    int x, y;
    rep (i, m){
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int cnt;
    Rep (i, n){
        cnt=0;
        rep (j, adj[i].size()){
            if (adj[i][j]==1) cnt++;
            if (adj[i][j]==n) cnt++;
        }
        if (cnt==2) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

vvi g;
vi f;
int res = 1e9;

void dfs0(int v, int p) {
  int c = 0, s = 0;
  for (int nv : g[v]) {
    if (nv == p) continue;
    dfs0(nv, v);
    s += f[nv];
    c += f[nv] == 0;
  }
  f[v] = s + max(0, c - 1);
}

void dfs1(int v, int p, int fup) {
  int c = p != -1 && fup == 0, s = fup;
  for (int nv : g[v]) {
    if (nv == p) continue;
    s += f[nv];
    c += f[nv] == 0;
  }
  res = min(res, 1 + s + max(0, c - 1));
  for (int nv : g[v]) {
    if (nv == p) continue;
    s -= f[nv];
    c -= f[nv] == 0;
    dfs1(nv, v, s + max(0, c - 1));
    s += f[nv];
    c += f[nv] == 0;
  }
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  g.resize(n);
  f.assign(n, 0);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs0(0, -1);
  dfs1(0, -1, 0);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 13824
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
//namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i,N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
    ll K;
    ll N;
    cin>>N>>K;
    vector<ll> h(N);
    FOR(i,N) { cin >> h[i]; }
    vector<ll> a(N,-2);
    function<ll(ll,ll)> f = [&](ll i,ll pre) -> ll {
        if(i==N-1)
            return abs(h[i]-h[pre]);
        if(i>N-1)
            return -1;
        if(a[i]!=-2){
            return a[i] + abs(h[i] - h[pre]);
        }
        ll ret,ret2;
        ret = f(i + 1, i);
        for(ll ii = 2; ii <= K;++ii){
            if(ii+i>N-1)
                break;
            ret2 = f(i+ii, i);
            if(ret > ret2 && ret2 != -1)
                ret = ret2;
        }
        a[i] = ret;
        if(ret == -1)
            return -1;
        return ret + abs(h[i] - h[pre]);
    };
    cout << f(0, 0)<<endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0; i != N; ++i)
#define co(o) cout << o << endl;
using namespace std;
typedef long int li;
typedef long long ll;


int main(void){
    ll a,b,c;
    cin >> a >> b >> c;
    if((4*a*b)<(c-a-b)*(c-a-b) && (c-a-b)>0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1e9+7;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int printintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}
//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int experiment(){
    int ans;ans=0;
    int N;
    cin>>N;
    pair<int,int> AB[N];
    FOR(i, 0, N){
        cin>>AB[i].second>>AB[i].first;
    }
    sort(AB, AB+N);

    FOR(i, 0, N){
        cerr<<AB[i].first<<" "<<AB[i].second<<endl;
    }
    
    ll partlysum=0;
    bool answer=true;
    FOR(i, 0, N){
        partlysum+=AB[i].second;
        if(partlysum>AB[i].first)answer=false;
    }
    
    if(answer)OutputAndReturn0("Yes")
    else OutputAndReturn0("No")
    
    OutputAndReturn0(ans);
    return 0;
}
signed main(){
    assert(1);
    experiment();
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	int N, H;
	cin >> N >> H;
	int a[100000] = {};
	int b[100000] = {};
	rep(i, N) {
		cin >> a[i] >> b[i];
	}

	sort(a, a + N);
	sort(b, b + N);

	int saidai = a[N - 1];

	int kaisuu = 0;
	rep(i, N) {
		if (b[N - i - 1] > saidai) {
			kaisuu++;
			H -= b[N - i - 1];
			if (H <= 0) break;
		}
	}
	
	if (H > 0) {
		kaisuu += H / saidai;
		if (H % saidai) kaisuu++;
	}
	co(kaisuu);
	Would you please return 0;
}

Measured memory_bytes: 1024
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val As = List.fill(N)(in.nextInt).sorted
  val dividable = new Array[Boolean](1_000_001)

  def count(l: List[Int], c: Int): Int = l match {
    case Nil => c
    case x :: xs =>
      if (dividable(x)) count(xs, c)
      else {
        (x to 1_000_000 by x).foreach {i => dividable(i) = true}
        count(xs, c + (if (xs.headOption == Some(x)) 0 else 1))
      }
  }

  println(count(As, 0))
}


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

int main(void){
    string s;
    cin>>s;
    int n = s.size();
    for(int i=(n-1)/2;i>0;i--){
        if (s.substr(0,i)==s.substr(i,i)){
            cout<<i*2;
            exit(0);
        }
    }    
}


Measured memory_bytes: 3604
"""
def func(n, t, v):
    t = [0] + t + [t[-1]]
    print("t:{}".format(t))
    v = [0] + v + [0]

    limit = [0 for _ in range(t[-1] + 1)]
    for i in reversed(range(len(t) - 1)):
        for j in range(t[i] - t[i-1]):
            limit[t[i] - j] = min(v[i + 1] + j, v[i])

    print(limit)
    print([[i, limit[i]] for i in range(len(limit))])
    # print(list(range(len(limit))))
    dist = 0
    prev = 0
    for i in range(1, len(limit)):
        next = min(prev + 1, limit[i])
        dist += (next + prev) / 2
        print("i:{} add:{} dist:{}".format(i, (next + prev) / 2, dist))
        prev = next
    return str(dist)
"""
def func(n, t, v):
    t = [0] + t + [t[-1]]
    v = [0] + v + [0]
    for i in range(len(t)):
        t[i] *= 2
    for i in range(len(v)):
        v[i] *= 2
    # print("t:{}".format(t))

    limit = [0 for _ in range(t[-1] + 1)]
    for i in reversed(range(len(t) - 1)):
        for j in range(t[i] - t[i-1]+1):
            limit[t[i] - j] = min(limit[t[i]] + j, v[i])

    # print(limit)
    # print([[i, limit[i]] for i in range(len(limit))])
    # print(list(range(len(limit))))
    dist = 0
    prev = 0
    for i in range(1, len(limit)):
        next = min(prev + 1, limit[i])
        dist += (next + prev) / 2
        # print("i:{} add:{} dist:{}".format(i, (next + prev) / 2, dist))
        prev = next
    return str(dist/4)

# print(510*510/2)
n = int(input())
t = [int(i) for i in input().split()]
for i in range(1, len(t)):
    t[i] += t[i-1]
v = [int(i) for i in input().split()]
print(func(n, t, v))
# print("print(func({}, {}, {}))".format(n, t, v))
"""
print("2100 vs " + func(1, [100], [30]) + "\n")
print("2632 vs " + func(2, [60, 110], [34, 38]) + "\n")
print("76 vs " + func(3, [12, 26, 28], [6, 2, 7]) + "\n")
print("20.25 vs " + func(1, [9], [10]) + "\n")
print(
    "20291 vs " + func(10, [64, 119, 146, 181, 257, 376, 383, 401, 450, 550], [29, 19, 31, 39, 27, 48, 41, 87, 55, 70]))
"""


Measured memory_bytes: 3504
s=input()
list_s = [s[i] for i in range (len(s))]
flag = True
for i in range(len(s)):
  if flag:
    if i%2==0:
      if list_s[i]=="L":
        flag = False
    else:
      if list_s[i]=="R":
        flag = False
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
S = input()
b = []
for i in range(len(S) - 1):
    if S[i:i + 2] == "01" or S[i:i + 2] == "10":
        b.append(len(S) - (i + 1) if i < len(S) // 2 else i + 1)

print(min(b) if len(b) != 0 else len(S))


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 131072
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int inf = 2147483647;

int n, dat[2*MAX];
void init(int m){
	n = 1;
	while(n < m)n *= 2;
	for(int i = 0;i < 2*n;i++)dat[i] = inf;
}

void change(int x, int y){
	x += n-1;
	dat[x] = y;
	while(x > 0){
		x = (x-1)/2;
		dat[x] = min(dat[x*2+1], dat[x*2+2]);
	}
}

int query(int a, int b, int k, int l, int r){
	if(b <= l || r <= a)return inf;
	if(a <= l && r <= b)return dat[k];
	int vl = query(a, b, 2*k+1, l, (l+r)/2);
	int vr = query(a, b, 2*k+2, (l+r)/2, r);
	return min(vl, vr);
}

int main(){
	int m, q, c, x, y;
	scanf("%d%d", &m, &q);
	init(m);
	while(q--){
		scanf("%d%d%d", &c, &x, &y);
		if(!c)change(x, y);
		else printf("%d\n", query(x, y+1, 0, 0, n));
	}
	return 0;
}

Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  string s; cin >> s;
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

main = do
  [s] <- getString
  let s0 = filter (== '0') s
  let s1 = filter (== '1') s
  print $ (minimum [length s0, length s1]) * 2


Measured memory_bytes: 7988
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int main(){
	long N,P;
    cin>>N; cin>>P;
    long zantei = 1;
    long temp;
    if(N == 1){
        zantei = P;
    }else if(P == 1 || N > 39){

    }else{
        for(long i=2;i<=P;i++){
            temp = pow(i,N);

            if(temp > P){break;}
            if(P % temp == 0){
                zantei = i;
            }
        }
    }

    cout<<zantei<<endl;
	
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

signed main(){
	int n; cin >> n;
	string s; cin >> s;
	int q; cin >> q;
	vector<set<int> > SET(26, set<int> {INF});
	for(int i = 0; i < n; i++) SET[s[i] - 'a'].insert(i);
	/*for(int i = 0; i < q; i++){
		int type; cin >> type;
		if(type == 1){
			int l; cin >> l; char c; cin >> c; --l;
			if(s[l] != c){
			  SET[s[l] - 'a'].erase(i);
			  SET[c - 'a'].insert(i);
			  s[l] = c;
			}
		}
		if(type == 2){
			int l, r; cin >> l >> r; --l;
			int c = 0;
			for(int j = 0; j < 26; j++){
				if(SET[j].empty()) continue;
				if(*SET[j].lower_bound(l) < *SET[j].lower_bound(r)) c++;
			}
			cout << c << endl;
		}
	}*/
    for(int i = 0; i < q; i++){
    int t; cin >> t;
    if(t == 1){
      int l; char c; cin >> l >> c; --l;
      if(s[l] != c){
        SET[s[l] - 'a'].erase(l);
        SET[c - 'a'].insert(l);
        s[l] = c;
      }
    }
    if(t == 2){
      int l, r; cin >> l >> r; --l;
      int ans = 0;
      for(int c = 0; c < 26; c++){
        if(SET[c].empty()) continue;
        if(*SET[c].lower_bound(l) < *SET[c].lower_bound(r)) ans++;
      }
      cout << ans << '\n';
    }
  }
}


Measured memory_bytes: 24196
fun main(args: Array<String>) {
    (readLine()!![0] + 1).let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

using namespace std;

int main() {
	long long a, b, c;
	cin >> a >> b >> c;

	long long r = c - (a + b);
	long long l = 4 * a * b;

	if (r > 0 && l < r * r) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 100000

using namespace std;
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int main () {
    int N, M;
	cin >> N >> M;
	vector<ll> x(N), y(N), z(N);
	rep(i,N) cin >> x[i] >> y[i] >> z[i];
	ll rot[8][3] = { {1,1,1}, {1,1,-1}, {1,-1,1}, {1,-1,-1}, {-1,1,1}, {-1,1,-1}, {-1,-1,1}, {-1,-1,-1}};
	ll ans = 0;
	rep(r, 8) {
		vector<ll> v(N);
		rep (i,N) {
			v[i] = x[i] * rot[r][0] + y[i] * rot[r][1] + z[i] * rot[r][2];
		}
		sort(v.rbegin(), v.rend());
		ll cur = 0;
		rep(i,M) {
			cur += v[i];
		}
		ans = max(ans, cur);
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int x, y, z, k; cin >> x >> y >> z >> k;
  vector<long long> a(x), b(y), c(z);
  REP(i, x) cin >> a[i];
  sort(ALL(a), greater<long long>());
  REP(i, y) cin >> b[i];
  sort(ALL(b), greater<long long>());
  REP(i, z) cin >> c[i];
  sort(ALL(c), greater<long long>());
  priority_queue<tuple<long long, int, int, int> > que;
  que.emplace(make_tuple(a.front() + b.front() + c.front(), 0, 0, 0));
  vector<vector<vector<bool> > > used(x, vector<vector<bool> >(y, vector<bool>(z, false)));
  used[0][0][0] = true;
  while (k--) {
    auto t = que.top(); que.pop();
    cout << get<0>(t) << '\n';
    if (get<1>(t) + 1 < x && !used[get<1>(t) + 1][get<2>(t)][get<3>(t)]) {
      used[get<1>(t) + 1][get<2>(t)][get<3>(t)] = true;
      que.emplace(make_tuple(get<0>(t) - a[get<1>(t)] + a[get<1>(t) + 1], get<1>(t) + 1, get<2>(t), get<3>(t)));
    }
    if (get<2>(t) + 1 < y && !used[get<1>(t)][get<2>(t) + 1][get<3>(t)]) {
      used[get<1>(t)][get<2>(t) + 1][get<3>(t)] = true;
      que.emplace(make_tuple(get<0>(t) - b[get<2>(t)] + b[get<2>(t) + 1], get<1>(t), get<2>(t) + 1, get<3>(t)));
    }
    if (get<3>(t) + 1 < z && !used[get<1>(t)][get<2>(t)][get<3>(t) + 1]) {
      used[get<1>(t)][get<2>(t)][get<3>(t) + 1] = true;
      que.emplace(make_tuple(get<0>(t) - c[get<3>(t)] + c[get<3>(t) + 1], get<1>(t), get<2>(t), get<3>(t) + 1));
    }
  }
  return 0;
}


Measured memory_bytes: 180480
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))

    if n % 2 != 0:
        for i in range(n):
            if i == 0:
                if A[i] != 0:
                    print(0)
                    break
            else:
                if i % 2 != 0:
                    if A[i] - A[i - 1] != 2:
                        print(0)
                        break
                else:
                    if A[i] != A[i - 1]:
                        print(0)
                        break
        else:
            res = pow(2, n // 2, mod)
            print(res)
    else:
        for i in range(n):
            if i == 0:
                if A[i] != 1:
                    print(0)
                    break
            else:
                if i % 2 == 0:
                    if A[i] - A[i - 1] != 2:
                        print(0)
                        break
                else:
                    if A[i] != A[i - 1]:
                        print(0)
                        break
        else:
            res = pow(2, n // 2, mod)
            print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 52844
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


x, n = inpl()
p = set(inpl())
dif = 0

while True:
    if x - dif not in p:
        print(x - dif)
        exit()
    if x + dif not in p:
        print(x + dif)
        exit()
    dif += 1


Measured memory_bytes: 69020
#include <bits/stdc++.h>
// #pragma GCC optimize("O3")
// #pragma GCC target("avx")
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

int n, a[MAX_N];

bool possible(int cri)
{
    vector<int> id, val;
    int prv = 0;
    rep(i,n){
        if(a[i] <= prv){
            int num = id.end() - upper_bound(all(id),a[i]);
            rep(j,num){
                id.pop_back(), val.pop_back();
            }
            int ind = lower_bound(all(id),a[i]) - id.begin();
            if(ind == len(id)){
                id.pb(a[i]), val.pb(1);
                prv = a[i];
                continue;
            }
            while(true){
                // id[ind] が今見ている桁
                int ima = id[ind];
                if(val[ind] < cri-1){
                    val[ind]++;
                    break;
                }
                id.pop_back(), val.pop_back();
                if(ind == 0){
                    if(ima == 1) return false;
                    id.pb(ima-1), val.pb(1);
                    break;
                }
                if(id[ind-1] < ima-1){
                    id.pb(ima-1), val.pb(1);
                    break;
                }
                ind--;
            }
        }
        prv = a[i];
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int prv = -1;
    rep(i,n){
        cin >> a[i];
        if(prv >= a[i]){
            prv = INF;
        }else{
            prv = a[i];
        }
    }
    if(prv != INF){
        cout << "1\n";
        return 0;
    }
    int l = 1, r = n;
    while(r-l>1){
        int mid = (l+r)/2;
        if(possible(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  	int ara[n*2];
  	for(int i=0; i<n*2; i++){
      cin>>ara[i];
  	}
    sort(ara, ara+2*n);
    int sum = 0;
    for(int i=0; i<2*n; i+=2){
      sum += ara[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define ll long long

#define MOD 1000000007
typedef pair<int, int> pii;
// typedef vector<int> vi;
// typedef vector<pii> vpi;
// typedef vector<vi> vvi;
// typedef long long i64;
// typedef vector<i64> vi64;
// typedef vector<vi64> vvi64;
// typedef pair<i64, i64> pi64;
// typedef double ld;
typedef  long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
// ui64 mx=1000*1000*1000+3;
// ui64 dp[mx];
ui64 dp[3003][3003];
ui64 arr[3003];

int main()
{
ui64 n,sum=0;
cin>>n;
forn(i,n)
{
cin>>arr[i];
sum+=arr[i];
}
forn(d,n)
{
for(int i=0,j=d;i<n-d;i++,j++)
	{
		if(i==j){
			dp[i][j]=arr[i];
			continue;}
			if(i>j)
			{
				break;
			}
			if(j<i+2)
			dp[i][j]=max(arr[i],arr[j]);
else
{
	dp[i][j]=max(arr[j]+min(dp[i][j-2],dp[i+1][j-1]),arr[i]+min(dp[i+2][j],dp[i+1][j-1]));
}

	}
}

cout<<2*dp[0][n-1]-sum;

return 0;
}


Measured memory_bytes: 70016
#include <algorithm>
#include <iostream>

using namespace std;

int N, M;
pair<int,int> PD[10010];

int main() {
  while (cin >> N >> M && N) {
    int d, p;
    for (int i=0; i<N; ++i) {
      cin >> d >> p;
      PD[i] = make_pair(p, d);
      // PD[i].first ?????? i ?????±??????
      // PD[i].second ?????? i ?????????
    }
    // PD?????§??????????????´???
    sort(PD, PD+N, greater<pair<int,int> >());
    int e = 0;
    for (int i=0; i<N; i++) {
      if (M == 0) {
        e += PD[i].first*PD[i].second;
      } else if (M < PD[i].second) {
        e += PD[i].first*(PD[i].second-M);
        M = 0;
      } else {
        M -= PD[i].second;
      }
    }
    cout << e << endl;
  }
  return 0;
}

Measured memory_bytes: 3164
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n,r;cin>>n>>r;
	int ans=0;
	if(n<10)
	ans=100*(10-n);
	cout<<ans+r<<endl;
}

int32_t main()
{
	
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

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

using ll = long long;

int main() {
   ll x;
   cin >> x;
   ll y = 0;
   for (int i = 0;  ; i++) {
      y += i;
      if (y >= x) {
         cout << i << endl;
         return 0;
      }
   }

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],c[200010],ans;
bool b[200010];
inline int read()
{
	int num=0,flag=1;
	char c=getchar();
	for (;c<'0'||c>'9';c=getchar())
	if (c=='-') flag=-1;
	for (;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main()
{
	n=read();
	for (int i=1;i<=n;++i)
	{
		a[i]=read();
		b[a[i]]=true;
		c[a[i]]++;
		if (b[a[i]-1]) c[a[i]]=c[a[i]-1]+1;
		ans=max(ans,c[a[i]]);
	}
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 2048
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n,i;
    cin>>n>>i;
    cout<<n-i+1<<endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[10^^5*2+1] M;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(int[]);

    foreach_reverse (ii, a; as) {
        auto i = ii.to!int + 1;
        int cnt;
        for (int j = i; j <= N; j += i) cnt = (cnt + M[j]) % 2;
        if (a != cnt) M[i] = 1;
    }

    int[] rr;
    foreach (i, m; M[1..$]) if (m) rr ~= i.to!int + 1;
    writeln(rr.length);
    writeln(rr.to!(string[]).join(" ")); 
}

Measured memory_bytes: 12696
#include<stdio.h>
#define N 1000

int main(void){
  int i,j,k,num;
  int paper[10][10];
  int x[N]={0},y[N]={0},depth[N]={0};
  int whiteCount=0,maxDepth=0;
  char kamma;

  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      paper[i][j]=0;
    }
  }
  for(k=0;((scanf("%d%c%d%c%d",&x[k],&kamma,&y[k],&kamma,&depth[k]))==5);k++){}
  num=k;
  for(k=0;k<num;k++){
    if(depth[k]==1){
      for(i=0;i<10;i++){
        for(j=0;j<10;j++){
          if(((i-x[k])*(i-x[k])+
                (j-y[k])*(j-y[k]))<=1){
            paper[i][j]++;
          }
        }
      }
    }
    if(depth[k]==2){
      for(i=0;i<10;i++){
        for(j=0;j<10;j++){
          if(((i-x[k])*(i-x[k])+
                (j-y[k])*(j-y[k]))<=2){
            paper[i][j]++;
          }
        }
      }
    }
    if(depth[k]==3){
      for(i=0;i<10;i++){
        for(j=0;j<10;j++){
          if(((i-x[k])*(i-x[k])+
                (j-y[k])*(j-y[k]))<=4){
            paper[i][j]++;
          }
        }
      }
    }
  }
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      if(paper[i][j]==0)  whiteCount++;
      else if(paper[i][j]>maxDepth) maxDepth=paper[i][j];
    }
  }
  printf("%d\n%d\n",whiteCount,maxDepth);
  return 0;
}

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

void show(vector<int> a){
	for (int i = 0; i != a.size(); i++){
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
	return;
}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i != n; i++)	cin >> a[i];
	show(a);
	int key, j;
	for (int i = 1; i != n; i++){
		key = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > key){
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = key;
		show(a);
	}
}


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

void calc(double x1,double  y1,double  x2,double y2,double x3,double y3){
  double px = ((y1-y3)*(y1*y1 - y2*y2 + x1*x1 - x2*x2) - (y1-y2)*(y1*y1-y3*y3+x1*x1-x3*x3))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
  double py = ((x1-x3)*(x1*x1 - x2*x2 + y1*y1 - y2*y2) - (x1-x2)*(x1*x1-x3*x3+y1*y1-y3*y3))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));

  double r = sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));
  printf("%.3f %.3f %.3f\n",px, py, r);
  return;
}

int main(){
  char tmp[32];
  double x1,x2,x3,y1,y2,y3;
  int i,n;
  fgets(tmp, 32, stdin);
  sscanf(tmp, "%d", &n);
  for(i=0;i<n;i++){
	fgets(tmp,32,stdin);
	sscanf(tmp, "%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
	calc(x1, y1, x2, y2, x3, y3);
  }
  return 0;
}

Measured memory_bytes: 668
void main() {
	auto ip = readAs!(ulong[]), X = ip[0], Y = ip[1];
	auto tmp = X;
	ulong count;
	while(X <= Y) {
		X *= 2;
		count++;
	}
	count.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int INF = 0x3f3f3f3f;

inline int read () {
	register int s = 0, w = 1;
	register char ch = getchar ();
	while (! isdigit (ch)) {if (ch == '-') w = -1; ch = getchar ();}
	while (isdigit (ch)) {s = (s << 3) + (s << 1) + (ch ^ 48); ch = getchar ();}
	return s * w;
}
const int N=1e6+10;
ll a[N],b[N];

int main() {
	IOS;
	//freopen("D:\\in.txt","r",stdin);
	//freopen("D:\\out2.txt","w",stdout);
	ll n,k;
	cin>>n>>k;
	ll sum=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]/=2;
		sum=sum/__gcd(sum,a[i])*a[i];
	}
	for(int i=1;i<=n;i++){
		if(sum/a[i]%2==0){
			cout<<0<<endl;
			return 0;
		}
	}
	cout<<(k+sum)/(sum*2)<<endl;
	return 0;
}


Measured memory_bytes: 4352
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ball = new long[n];
        long[] ruisekiball = new long[n];
        int ans = 1;
        int ite = n-1;
        for (int i = 0; i < n; i++) {
            ball[i] = sc.nextInt();
        }
        Arrays.sort(ball);
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                ruisekiball[i] = ball[i];
            }else{
                ruisekiball[i] = ruisekiball[i-1] + ball[i];
                // i made no wa
            }
        }
        while (true) {
            ite--;
            if (ruisekiball[ite] * 2 >= ball[ite+1]) {
                ans++;
            }else{
                break;
            }
            if (ite == 0) {
                break;
            }
        }

        System.out.println(ans);

        sc.close();
    }
}





Measured memory_bytes: 64824
q = int(input())
a = [0] * (10 ** 5)
for i in range(1, 10 ** 5, 2):
    if (i + 1) // 2 % 2 == 0:
        pass
    else:
        for j in range(2, int((i)**(1 / 2)) + 1):
            if i % j == 0:
                break
        else:
            k = (i + 1) // 2
            for j in range(2, int((k)**(1 / 2)) + 1):
                if k % j == 0:
                    break
            else:
                a[i] = 1

for i in range(1, 10 ** 5):
    a[i] = a[i - 1] + a[i]
a[1] = 0
a[2] = 0

for i in range(q):
    l, r = map(int, input().split())
    print(a[r] - a[l - 1])


Measured memory_bytes: 12312
#include<iostream>
using namespace std;;
#include <unordered_map>  
int main(){
long long n;
cin >>n;
 unordered_map<long long, long long> mp;
long long count=0,check=0;
for(long long i=0;i<n;i++){
long long s;
cin >> s;
    auto itr = mp.find(s); 
    if( itr != mp.end() ) {
mp[s]++;
if(mp[s]>=s){
mp[s]-=s;
count-=s;
}
    } else {
if(s!=1){
        mp[s]=1;
}
else if(check==0){
check=1;
count--;
}
    }
count++;

}
cout <<count;
return 0;
}

Measured memory_bytes: 4260
N=int(input())

get_dict={}
for i in range(N):
  s=input()
  if s in get_dict.keys():
    get_dict[s]+=1
  else:
    get_dict[s]=1
    
M=int(input())
lose_dict={}
for i in range(M):
  s=input()
  if s in lose_dict.keys():
    lose_dict[s]+=1
  else:
    lose_dict[s]=1

ind=list(set(list(get_dict.keys())+list(lose_dict.keys())))
ans=0
for s in ind:
  try:
    a=get_dict[s]
  except:
    a=0
  try:
    b=lose_dict[s]
  except:
    b=0
  ans=max(ans, a-b)
  
print(ans)



Measured memory_bytes: 3064
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
result=0
for i in range(n):
  a=list(map(int,input().split()))
  cnt=c
  for j in range(m):
    cnt+=a[j]*b[j]
  if cnt>0:
    result+=1
print(result)

Measured memory_bytes: 3060
n,q=map(int,input().split())

class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)

bit=BIT(n+1)

for i in range(q):
   com,x,y=map(int,input().split())
   if com==0:
      bit.add(x,y)
   else:
      s = bit.get(x-1,y)
      print(s)


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

const int p[] = {1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999};

int main() {
	int n;
	cin >> n;
	for (int i = 0; ; ++ i) {
		if (p[i] >= n) {cout << p[i];return 0;}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

int main()
{
    int N, K;
    cin >> N >> K;
    VD p(N);
    map<int, int> A;
    double mx=0;
    VD kitai(N);
    rep(i,N){
        cin >> p[i];
        mx=max(mx,p[i]);
    }
    rep(i,mx+1){
        for(int j=1; j<=i; j++){
            A[i]+=j;
        }
    }
    rep(i,N){
        kitai[i]=A[p.at(i)]/p[i];
    }
    VD s(N+1, 0);
    rep(i,N){
        s[i+1]=s[i]+kitai[i];
    }
    double ans=0.0;
    for(int i=0; i<=N-K; i++){
        ans=max(ans,s.at(i+K)-s.at(i));
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int i=1;
while(true){
int x=scan.nextInt();
if(x==0){break;}
else{
System.out.println("Case" + " " + i + ":" + " " + x );
i=i+1;
}}}}

Measured memory_bytes: 42280
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int count[200000]={0};
vector<int>a;
int k,n,kind=0;
int main(){
    cin>>n>>k;
    a.resize(n);
    vector<int>count(n);
    rep(i,n){cin>>a.at(i);if(count.at(a.at(i)-1)==0)kind++;count[a.at(i)-1]++;}
    sort(count.begin(),count.end());
    int fix = kind - k;
    if(fix<=0){cout<<0<<endl;return 0;}
    else{
        k=0,n=0;
        while(fix--){
            while(count.at(n)==0)n++;
            k+=count.at(n++);
        }
    }
   cout<<k<<endl;
    return 0;
}




Measured memory_bytes: 1792
// ref: https://drken1215.hatenablog.com/entry/2019/04/14/222900

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, K; cin >> N >> K;
    string s; cin >> s;
    
    vector<int> vCL; // continuous length
    if(s[0]=='0'){ vCL.push_back(0); } // while the head is '0'.
    for(int i=0; i<N; ++i){
        int len=1;
        while(i<N-1 && s[i]==s[i+1]){ ++len; ++i; }
        vCL.push_back(len);
    }
    if(s.back()=='0'){ vCL.push_back(0); } // while the tail is '0'.
    
    vector<int> vCSum(vCL.size()+1, 0); // cumulative sum
    for(int i=0; i<(int)vCL.size(); ++i){ vCSum[i+1] = vCSum[i] + vCL[i]; }
    
    int maxLen;
    for(int begin=0; begin<(int)vCSum.size(); begin+=2){
        int end = begin + 2*K+1; end=min(end, (int)vCSum.size()-1);
        maxLen = max(maxLen, vCSum[end] - vCSum[begin]);
    }
    cout << maxLen << endl;
    
    return 0;
}

Measured memory_bytes: 1272