akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

const int MOD = 998244353;
class mint {
    ll x;
public:
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};

const int MAX = 510000;
mint fac[MAX], finv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * mint(i);
        finv[i] = finv[i-1] * mint(i).inv();
    }
}

mint COM (int n, int k) {
    if (n < k) return mint(0);
    if (n < 0 || k < 0) return mint(0);
    // o(k)
    // if (k < MAX) {
    //     mint ret(1);
    //     Rep (i, k) {
    //         ret *= mint(n-i);
    //         ret /= mint(k-i);
    //     }
    //     return ret;
    // }

    return fac[n] * finv[k] * finv[n-k];
}



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

    ll N, M, K;
    cin >> N >> M >> K;

    COMinit();

    // vector<vector<mint>> dp(N+1, vector<mint>(K+1, 0));
    // dp[0][0] = 1;
    // dp[1][0] = M;
    // for (ll i = 1; i < N; i++) {
    //     Rep (j, K+1) {
    //         dp[i+1][j] += dp[i][j] * (M-1);
    //         if (j+1 <= K) dp[i+1][j+1] += dp[i][j];
    //     }
    // }

    mint ans(0);
    Rep (i, K+1) {
        ans += COM(N-1, i) * M * mint(M-1).pow(N-1-i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 11588
use proconio::{fastout, input};

use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        k: usize,
        s: Chars,
    }
    if s.len() <= k {
        println!("{}", s.iter().collect::<String>());
    } else {
        println!("{}...", s.iter().take(k).collect::<String>());
    }
}


Measured memory_bytes: 2128
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

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

  int res = min(k,n)*x + max(n-k,0)*y;
  cout<<res<<endl;

  return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  vector<ll> a(n);
  vector<vector<pll>> xy(n);
  rep(i,n){
    cin>>a[i];
    xy[i].resize(a[i]);
    rep(j,a[i]){
      cin>>xy[i][j].first>>xy[i][j].second;
      xy[i][j].first--;
    }
  }

  ll ans = 0;
  for(int bit=0;bit<(1<<n);++bit){
    bitset<16> b(bit);
    bool ok=true;
    set<ll> x;
    rep(i,n)if(b[i])x.emplace(i);
    for(auto idx:x){
      for(auto elm:xy[idx]){
        if(elm.second==0&&x.find(elm.first)!=x.end())ok=false;
        if(elm.second==1&&x.find(elm.first)==x.end())ok=false;
      }
    }
    if(ok)chmax(ans,ll(x.size()));
  }
  cout<<(ans)<<endl;

}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;

int AC[maxn];
int penal[maxn];


int main()
{
    MEM(AC,0);
    MEM(penal,0);
    int N,M;

    cin >> N >> M;

    _rep(i,1,M){
        int q;string s;
        cin >> q >> s;
        if(s == "AC"){
            if(!AC[q]) AC[q] = 1;
        }
        else{
            if(!AC[q]) penal[q]++;
        }
    }
    LL acs = 0;
    LL was = 0;

    _rep(i,1,N){
        acs += AC[i];
        if(AC[i])
            was += penal[i];
    }
    printf("%d %d\n",acs,was);



    return 0;
}


Measured memory_bytes: 1024
import sys

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

if A[0] != 0:
    print (-1)
    sys.exit()

A.reverse()

ans = 0

for i in range(N):

    if i == 0:
        ans += A[i]

    else:

        if A[i-1] - 1 > A[i]:
            print (-1)
            sys.exit()

        elif A[i-1] -1 == A[i]:
            pass

        else:
            ans += A[i]

print (ans)


Measured memory_bytes: 61912
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

inline vector<ll> divisor(ll n){
	vector<ll> res;
	for(ll i = 1; i*i <= n; i++){
		if(n % i == 0){
      res.push_back(i);
      if(i != n/i) res.push_back(n/i);
		}
	}
  sort(all(res));
	return res;
}

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll n; cin >> n;
  ll ans = 0;
  auto res = divisor(n);
  for(auto x : res){
    if(x == 1) continue;
    if(n/x == n%(x-1)) ans += x-1;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



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

	ll x;
	cin >> x;
	if (x < 600)
	{
		cout << 8 << endl;
	}
	else if (x < 800)
	{
		cout << 7 << endl;
	}
	else if (x < 1000)
	{
		cout << 6 << endl;
	}
	else if (x < 1200)
	{
		cout << 5 << endl;
	}
	else if (x < 1400)
	{
		cout << 4 << endl;
	}
	else if (x < 1600)
	{
		cout << 3 << endl;
	}
	else if (x < 1800)
	{
		cout << 2 << endl;
	}
	else if (x < 2000)
	{
		cout << 1 << endl;
	}

	return 0;
}

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

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int> > C(H, vector<int>(W, 0));
	char* s = new char[7];
	int black = 0;
	for (int i = 0; i < H; i++) {
		cin >> s;
		char* p = s;
		for (int j = 0; j < W; j++) {
			if (*p == '.') {
				C[i][j] = 0;
			}
			else {
				C[i][j] = 1;
				black++;
			}
			p++;
		}
	}
	int cs = 0;
	for (int bH = 0; bH < (1 << H); ++bH) {
		for (int bW = 0; bW < (1 << W); ++bW) {			// 1 << N = 2^N で、bは0から2^Nまで回る。
			int count = 0;
			for (int iH = 0; iH < H; ++iH) {
				if (!(bH & (1 << iH))) {
					for (int iW = 0; iW < W; ++iW) {
						if (!(bW & (1 << iW))) {
							count += C[iH][iW];
						}
					}
				}
			}
//			cout << bH << " " << bW << " " << count << endl;
			if (count == K) {
				cs++;
			}
		}
	}
	cout << cs << endl;
	return(0);
}


Measured memory_bytes: 3612
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.PriorityQueue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val A = new Array[Int](N)

  for(i <- 0 until N)
    A(i) = in.next().toInt

  val b = A.sorted

  /*  降順  */
  val pq = new PriorityQueue[Int]


  var now = b(0)
  var cnt = 1
  var num = 0
  for(i <- 1 until N) {
    if(now != b(i)) {
      pq.enqueue(-cnt)
      now = b(i)
      cnt = 1
      num += 1
    }
    else {
      cnt += 1
    }
  }
  num += 1
  pq.enqueue(-cnt)

  var ans = 0
  while(num > K) {
    val now = -pq.dequeue
    ans += now
    num -= 1
  }
  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 54708
import java.util.*;
class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int A = sc.nextInt();
        int D[] =  {
            A / 1000,
            (A / 100) % 10,
            (A / 10) % 10,
            A % 10,
        };
        String res = "";
        for(int i = 0; i < 8; i++){
            int c = D[0];
            for(int j = 0; j < 3; j++){
                if((1 & (i >> j)) == 1){
                    c += D[j+1];
                }
                else{
                    c -= D[j+1];
                }
            }
            if(c==7){
                StringBuffer s = new StringBuffer();
                s.append(D[0]);
                for(int j = 0;j < 3; j++){
                    if((1 & (i >> j)) == 1){
                        s.append("+");
                    }
                    else{
                        s.append("-");
                    }
                    s.append(D[j+1]);
                }
                s.append("=7");
                res = s.toString();
            }
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 35700
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

typedef struct {
	int l, r;
} range;

class SegmentTree {
private:
	vector<ll> d;
	int size;

public:
	SegmentTree(int num, ll inidata) {
		size = IniSize(num);
		d.resize(size);
		fill(d.begin(), d.end(), inidata);
	}

	int IniSize(int num) {
		// 要素数 num が収まるセグ木のサイズを返す
		int n = 1;
		while (n < num)
			n <<= 1;
		return (n << 1) - 1;
	}

	int Size() {
		return size;
	}

	void Update(int pos, int n) {
		// 位置 pos(0-index) の値を n で更新する

		int i = pos + (d.size() >> 1);
		d[i] = n;
		while (i > 0) {
			i = (i - 1) >> 1;
			d[i] = max(d[(i << 1) + 1], d[(i << 1) + 2]);
		}
		return;
	}

	ll Query(const range tag) {
		// tag で指定した範囲に対して検索を行う
		// tag = [a, b)
		return Query(0, tag, { 0, (Size() >> 1) + 1 });
	}

	ll Query(int pos, const range tag, range x) {
		// tag で指定した範囲に対して検索を行う
		// tag = [a, b)

		if (tag.r <= x.l || x.r <= tag.l)
			return 0; // ***注意***
		if (tag.l <= x.l && x.r <= tag.r)
			return d[pos];
		ll a, b, ans;
		a = Query((pos << 1) + 1, tag, { x.l, (x.l + x.r + 1) >> 1 });
		b = Query((pos << 1) + 2, tag, { (x.l + x.r + 1) >> 1, x.r });
		ans = max(a, b);
		return ans;
	}
};

class BIT {
	vector<int> d;
	int num;

public:
	BIT(int n) {
		num = n;
		d.resize(num + 1);
		fill(d.begin(), d.end(), 0);
	}

	void add(int p, int x) {
		while (p <= num) {
			d[p] += x;
			p += p & -p;
		}
		return;
	}

	int sum(int p) {
		int ans = 0;
		while (p) {
			ans += d[p];
			p -= p & -p;
		}
		return ans;
	}
};

int main(void) {
	int num, i, k;
	cin >> num >> k;
	vector<int> d(num);
	SegmentTree sg(300005, 0);
	rep(i, num)
		cin >> d[i];
	rep(i, num) {
		int ma = sg.Query({ max(0, d[i] - k), min(300001, d[i] + k + 1) });
		sg.Update(d[i], ma + 1);
	}
	cout << sg.Query({0, 300001}) << "\n";
	return 0;
}

Measured memory_bytes: 12780
class Node:
    def __init__(self,id):
        self.id = id
        self.child = []
        self.parent = -1
        self.depth = 0
        self.type = "root"    

n = int(input())
T = [Node(i) for i in range(n)]
for ni in range(n):
    id,  k, *c = [int(i) for i in input().split()]
    T[id].child = c 

#teach parent to each child
for ni in range(n):
    for c in T[ni].child:
        T[c].parent = ni

#teach depth
for ni in range(n):
    i = ni
    cnt = 0
    while T[i].parent != -1:
        i = T[i].parent
        cnt += 1
    T[ni].depth = cnt

#teach node type
for ni in range(n):
    if T[ni].parent == -1:
        T[ni].type = "root"
    elif T[ni].child == []:
        T[ni].type = "leaf"
    else:
        T[ni].type = "internal node"

for ni in range(n):
    print("node "+str(T[ni].id)+": parent = "+str(T[ni].parent)+\
    ", depth = "+str(T[ni].depth)+", "+T[ni].type+", ",end="")
    print(T[ni].child)


Measured memory_bytes: 43984
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
    int H, W;
    int h, w;
    cin >> H >> W;
    cin >> h >> w;
    int ans = H * W;
    ans = ans - (h * W + w * H) + (h * w); 
    cout << ans << "\n";
}

Measured memory_bytes: 256
import sys

mod = 10**9+7
MAX = 10**5*3

facts = [1 for i in range(MAX)]
invs = [1 for i in range(MAX)]

def inv(x):
	return pow(x,mod-2,mod)
 
for i in range(1,MAX):
		facts[i] = (facts[i-1] * i)% mod
		invs[i] = inv(facts[i])

def nCr(n,r):
	return facts[n]*invs[r] * invs[n-r] % mod

n, k = [int(x) for x in sys.stdin.readline().split()]
xs = sorted([int(x) for x in sys.stdin.readline().split()],reverse=True)
ans = 0
i = 0
while n - i - 1 >= k-1:
    ncr = nCr(n - i - 1, k-1)
    ans = (ans + (xs[i] * ncr))
    ans = (ans - (xs[- i - 1] * ncr))
    i+=1
print(ans % mod)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 505;
int A[MAX_N];
int B[MAX_N];

int need(int N, int g) {
  REP(i, N) B[i] = A[i] % g;
  sort(B, B+N);
  int sumB = accumulate(B, B+N, 0);
  int M = N - sumB / g;
  return accumulate(B, B+M, 0);
}

int main2() {
  int N = nextInt();
  int K = nextInt();

  REP(i, N) A[i] = nextInt();
  int S = accumulate(A, A+N, 0);

  int ans = 0;
  for (int g = 1; g <= S; g++) {
    if (S % g == 0) {
      if (need(N, g) <= K)
        ans = g;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll n;
    cin >> n;
    vector<pair<ll,ll>> vec(n);
    rep(i,n){
        ll x, l;
        cin >> x >> l;
        vec.at(i) = make_pair(x,l);
    }

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

    vector<pair<ll,ll>> vec2(n);

    rep(i,n){
        vec2.at(i).first = vec.at(i).first + vec.at(i).second;
        vec2.at(i).second = vec.at(i).first - vec.at(i).second;
    }

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

    ll ans = 0;
    ll tmp = 0;
    rep(i,n){
        if(i == 0){
            ans++;
            tmp = vec2.at(i).first;
            continue;
        }
        if(tmp <= vec2.at(i).second){
            tmp = vec2.at(i).first;
            ans++;
        }
    }

    cout << ans << endl;
    
    
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

#define INF ((i64)(1e18))
#define MOD ((i64)(1e9+7))
#define REP(i, n) for(i64 i = 0; i < (n); i++)
#define RREP(i, n) for(i64 i = (n)-1; i >= 0; i--)
#define RANGE(i, a, b) for(i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for(i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

int main() {
  i64 n;
  cin >> n;
  RANGE(i, 1, n+1) {
    i64 ans = 0;
    RANGE(x, 1, 99) {
      RANGE(y, x, 99) {
        RANGE(z, y, 99) {
          if (x*x+y*y+z*z+x*y+y*z+z*x == i) {
            if (x == y && y == z) ans++;
            else if (x == y || y == z) ans += 3;
            else ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/29  Problem: 080_arc_b / Link: https://arc080.contest.atcoder.jp/tasks/arc080_b ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL H, W, N;
inline void next(int &y, int &x) {
	if (y % 2 == 0) {
		if (x == W - 1) { y++; }
		else { x++; }
	}
	else { // % 2 ==1
		if (x == 0) { y++; }
		else { x--; }
	}
}

void go(VVI &masu, VI &a) {
	int y = 0, x = 0, id = 0;
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			while (a[id] == 0)id++;
			masu[y][x] = id + 1;
			a[id]--;
			next(y, x);
		}
	}
}


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

	cin >> H >> W >> N;
	VI a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	VVI masu(H, VI(W, 0));

	go(masu, a);

	FOR(i, 0, H) {
		FOR(j, 0, W) {
			cout << masu[i][j] << (j != W - 1 ? ' ' : '\n');
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    deque<string> dq;
    rep(i, n) {
        string a;
        cin >> a;
        if (i % 2 == 0) dq.push_back(a);
        else dq.push_front(a);
    }
    if (n % 2 == 1) reverse(ALL(dq));
    rep(i, n) {
        string s = dq.front();
        cout << s << " ";
        dq.pop_front();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 16000
<?php

$line = fgets(STDIN);
$data = explode(" ", rtrim($line));
//call($data[0]);


    $i = 1;

$n = $data[0];

    while(1) {
        $x = $i;
        if ($x % 3 == 0) {
            printf(" %d", $i);
        } elseif ($x % 10 == 3) {
            printf(" %d", $i);
        } else {
            while ($x) {
                $x /= 10;
                if ($x % 10 == 3) {
                    printf(" %d", $i);
                    break;
                }
            }
        }
        if ( ++$i <= $n ) {
            ;
        } else {
            break;
        };
    }
    echo PHP_EOL;

Measured memory_bytes: 15408
yes="Yes"
no="No"
n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)>1:exit(print(no))
if a==[a[0]]*n:
  if a[0]==n-1:print(yes)
  elif 2*a[0]<=n:print(yes)
  else:print(no)
else:
  mi=a.count(min(a))
  ma=n-mi
  if mi<max(a) and 2*(max(a)-mi)<=ma:print(yes)
  else:print(no)


Measured memory_bytes: 20784
/* Generated by powerful Codeforces Tool
 * Author: rockphy
 * Time: 2020-06-11 22:35:14
**/
#include  <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int sum=0;
    for(int i=1; i<6; ++i){
        int tmp; cin >> tmp;
        sum+=tmp;
    }
    cout << 15-sum << '\n';
}

Measured memory_bytes: 3652
import java.util.Scanner;

// https://atcoder.jp/contests/abc145/tasks/abc145_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		double[] arrayX = new double[N];
		double[] arrayY = new double[N];
		for(int i=0;i<N;i++) {
			arrayX[i] = sc.nextDouble();
			arrayY[i] = sc.nextDouble();
		}
		sc.close();


//		int combination = 1;
//		for(int i=1;i<=N;i++) {
//			combination=combination*i;
//		}

		double d = 0.0;

		for(int i=0;i<N;i++) {
			for(int j=i+1;j<N;j++) {
				d = d + Math.sqrt(Math.pow(arrayX[i] - arrayX[j],2) + Math.pow(arrayY[i] - arrayY[j],2));
			}
		}
		System.out.println(2*d/N);




	}
}


Measured memory_bytes: 25172
#include<stdio.h>

int n, A[100000];                  /*??°??????????´??????????*/

int binarySearch(int k)            /*?????°??? k ??¨??????????????????*/
{
   int left = 0;
   int right = n;
   int mid;

   while (left<right){
      mid = (left+right)/2;
      if (A[mid]==k)               /*key ?????????*/
         return mid;                  /*??????(key)???????????????*/
      else if (k<A[mid])         /*?????????????´¢*/
         right = mid;               /*left mid mid ??¨????????????????¶???±*/
      else                         /*?????????????´¢*/
         left = mid+1;                /*else if ((key)>A[mid]) ?????¨??????????????¢?´¢??¨????§?*/
   }
   return 0;
}

int main()
{
   int i, q, key, sum=0;

   scanf("%d", &n);
   for (i=0; i<n; i++)
      scanf("%d", &A[i]);

   scanf("%d", &q);
   for (i=0; i<q; i++){
      scanf("%d", &key);
      if (binarySearch(key))        /*????????¢?´¢??¢??°??? key ????????¨?????????*/
         sum++;
   }

   printf("%d\n", sum);

   return 0;
}

Measured memory_bytes: 2068
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
 
import java.util.*;
import java.lang.*;
import java.io.*;

@SuppressWarnings("unchecked")
public class Main implements Runnable {

  static BufferedReader in;
  static PrintWriter out;
 
  public static void main(String[] args) {
      new Thread(null, new Main(), "whatever", 1<<29).start();
  }
 
  public void run() {
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out, false);
 
    try
    {
      // in = new BufferedReader(new FileReader("class_treasurer.txt"));
      // out = new PrintWriter("output.txt");

      int t,x1,a,b;
      String str;
      String[] token;

      str=in.readLine().trim();
      token=str.split(" ");
      a=Integer.parseInt(token[0]);
      b=Integer.parseInt(token[1]);

      out.println(Math.max(a-2*b, 0));

      out.flush();
      out.close();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 24660
from math import floor
from heapq import heappush, heappop
n, m = map(int, input().split())
a = []
for i in map(int, input().split()):
    heappush(a, -i)
dis = lambda x,y: x // 2**y

for _ in range(m):
    heappush(a, -dis(-heappop(a), 1))
print(-sum(a))


Measured memory_bytes: 64112
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;
//abc178b

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({b*d,b*c,a*c,a*d})<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3652
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
ans = 1
M = 10**9+7
s = [0,0,0]
for i,num in enumerate(a):
    if num not in s:
        ans = 0
        break
    ans *= sum(item==num for item in s)
    ans %= M
    s[s.index(num)] += 1
print(ans)

Measured memory_bytes: 85200
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)

using namespace std;

typedef long long ll;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int solve(vector<int> v, int depth) {
	int n = v.size();
	int acc = accumulate(ALL(v), 0);

	// printf("n:%d, acc:%d\n", n, acc);

	REP(i, depth) {
		// printf("i:%d, n:%d, acc:%d\n", i, n, acc);
		if(n >= 3) {
			acc += 2;
			n -= 2;
			continue;
		}

		if(n == 2) {
			acc++;
			n--;
			continue;
		}
	}

	return acc;
}

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	vector<char> s(n);
	getchar();
	for(auto&& e : s) {
		e = getchar();
	}

	vector<int> v;
	int cnt = 0;
	REP(i, n - 1) {
		if(s[i] == s[i + 1]) {
			cnt++;
		} else {
			v.push_back(cnt);
			cnt = 0;
		}
	}
	v.push_back(cnt);

	// REP(i, v.size()) { printf("%d ", v[i]); }

	printf("%d\n", solve(v, k));
	return 0;
}

Measured memory_bytes: 1272
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 n, d;
  scanf ("%" SCNi32 "%" SCNi32, &n, &d);
  i32 ans = (n + 2 * d + 1 - 1) / (2 * d + 1);
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}

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

long long inf = 10000000007;

int main(){
  int a,b,q;
  cin >> a >> b >> q;
  vector<long long> s(a+2);
  s[0] = 0;
  s[a+1] = inf;
  for(int i = 0;i < a;i++){
    cin >> s[i+1];
  }
  vector<long long> t(b+2);
  t[0] = 0;
  t[b+1] = inf;
  for(int i = 0;i < b;i++){
    cin >> t[i+1];
  }
  while(q--){
    long long x;
    cin >> x;

    int la = 0,ra = a+1;
    while(ra - la > 1){
      int ca = (ra+la)/2;
      if(x < s[ca])ra = ca;
      else la = ca;
    }
    int lb = 0,rb = b+1;
    while(rb - lb > 1){
      int cb = (rb+lb)/2;
      if(x < t[cb])rb = cb;
      else lb = cb;
    }
    long long ret = 20000000007;
    if(s[la] != 0 && t[lb] != 0)ret = min(ret, max(x - s[la],x - t[lb]));
    if(s[ra] != inf && t[rb] != inf)ret = min(ret, max(s[ra] - x,t[rb] - x));
    if(s[la] != 0 && t[rb] != inf)ret = min(ret, x - s[la] + t[rb] - s[la]);
    if(s[ra] != inf && t[lb] != 0)ret = min(ret, x - t[lb] + s[ra] - t[lb]);
    if(s[ra] != inf && t[lb] != 0)ret = min(ret, s[ra] - x + s[ra] - t[lb]);
    if(s[la] != 0 && t[rb] != inf)ret = min(ret, t[rb] - x + t[rb] - s[la]);
    cout << ret << endl;
  }
    
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;
int N,M;
pair<int,int> p[100];
signed main(){
	int i,j,k;
	cin>>N>>M;
	for(i=0;i<N;i++)
		cin>>p[i].first>>p[i].second;
	int u=p[0].first;
	vector<int> ve[4],wa[4];
	for(i=0;i<N;i++)
		ve[p[i].first-u].push_back(p[i].second);
	for(i=0;i<4;i++){
		sort(begin(ve[i]),end(ve[i]),greater<int>());
		int v=0;
		wa[i].push_back(0);
		for(int x:ve[i]){
			v+=x;
			wa[i].push_back(v);
		}
	}
	int ans=0;
	for(i=0;i<wa[0].size();i++)
		for(j=0;j<wa[1].size();j++)
			for(k=0;k<wa[2].size();k++){
				int x=i*u+j*(u+1)+k*(u+2);
				if(x<=M)
					ans=max(ans,wa[0][i]+wa[1][j]+wa[2][k]+wa[3][min((int)wa[3].size()-1,(M-x)/(u+3))]);
			}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	ans := make(map[string]struct{})
	for i := 0; i < n; i++ {
		ans[Scanner()] = struct{}{}
	}
	fmt.Println(len(ans))
}


Measured memory_bytes: 13936
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x, y, z;
  cin >> x >> y >>z;
  cout << z << endl;
  cout << x << endl;
  cout << y << endl;
}


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

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int A, B;
    cin>>A>>B;

    if( (A % 3 == 0) or (B % 3 == 0) or ((A + B) % 3 == 0) )
        cout<<"Possible\n";
    else
        cout<<"Impossible\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

bool check(string s) {
    for (int i = 1; i < (int)s.size(); i++) {
        if (s[i] != s[0]) return false;
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int ans = INF;
    for (char c = 'a'; c <= 'z'; c++) {
        string t = s;
        int cnt = 0;
        while (!check(t)) {
            for (int i = 0; i < (int)t.size() - 1; i++) {
                if (t[i + 1] == c) t[i] = c;
            }
            cnt++;
            t.pop_back();
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f, maxn=200007, mod=1e9+7;

int a[maxn];
long long h[maxn];
int n,ans;
int main(){
	h[0]=1;
	for(int i=1;i<=31;i++)h[i]=h[i-1]<<1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int k=30;k>=1;k--){
		for(int i=1,j=n;i<j;i++){
			if(a[i]!=inf){
				while(j>i&&(a[j]==inf||a[i]+a[j]>h[k]))j--;
//				cout<<a[i]<<' '<<a[j]<<' '<<h[k]<<endl;
				if(j>i&&a[j]!=inf&&a[i]+a[j]==h[k])ans++,a[i]=a[j]=inf;
			}
		}
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){

	int i,N,a[100],flag=0;

	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}

	for(i=0;i<N;i++){
		 
		if(a[i]%2==0){
			if(a[i]%3!=0 && a[i]%5!=0)flag=1;
		}
	}
	if(flag==0)printf("APPROVED");
	else printf("DENIED");

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
int main(){
    char **c;
    char **cc;
    int h,w;
    scanf("%d %d",&h,&w);
    c=calloc(h,sizeof(char*));
    cc=calloc(2*h,sizeof(char*));
    for(int i=0;i<h;i++){
        c[i]=calloc(w,sizeof(char));
    }
    for(int i=0;i<2*h;i++){
        cc[i]=calloc(w,sizeof(char));
    }
    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            cc[i][j]='.';
        }
    }
    for(int i=0;i<h;i++){
        scanf("%s",c[i]);
    }
    for(int j=0;j<w;j++){
        int k=0;
        for(int i=0;i<h;i++){
            for(int l=0;l<2;l++){
                if(c[i][j]=='.') cc[k][j]=cc[k+1][j]='.';
                if(c[i][j]=='*') cc[k][j]=cc[k+1][j]='*';
            }
            k+=2;
        }
    }
    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            printf("%c",cc[i][j]);
        }
        printf("\n");
    }

    for(int i=0;i<h;i++){
        scanf("%s",c[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1632
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int[] a = new int[n];
                int[] b = new int[n];
                for(int i = 0 ; i < n ; i++){
                        a[i] = sc.nextInt();
                        b[i] = sc.nextInt();
                }
                sc.close();
                Arrays.sort(a);
                Arrays.sort(b);
                double owata = 0;
                double yokun = 0;
                if(n % 2 == 0){
                        owata = a[n / 2 - 1] + a[n / 2];
                        owata /= 2.0;
                        yokun = b[n / 2 - 1] + b[n / 2];
                        yokun /= 2.0;
                        yokun -= owata;
                        System.out.println((int)(yokun * 2) + 1);
                }else{
                        System.out.println(b[n / 2] - a[n / 2] + 1);
                }

        }
}//AC出たら泣いて喜ぶよ

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

int main() {
  int n;
  string s,t;
  cin >> n >> s >> t;
  vector<char> ans(2*n);
  rep(i, n){
    ans.at(2*i) = s.at(i);
    ans.at(2*i+1) = t.at(i);
  }
  rep(i, 2*n)
    cout << ans.at(i);
  cout << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

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

    FOR(i,max(x-k+1, -1000000), min(x+k, 1000000)) {
        cout<<i<<(i != x+k ? " " : "");
    }
    nextline;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define INF 2000000

int n,p[301],m[301][301];

void matrixChainOrder(){
  int i,j,k,l,q;
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++)
    for(i=1;i<=n;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=fmin(m[i][j],q);
      }
    }
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d %d",&p[i-1],&p[i]);
  matrixChainOrder();
  printf("%d\n",m[1][n]);
  return 0;
}

Measured memory_bytes: 716
using System;
using System.Linq;
using System.Collections.Generic;

namespace _0298
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] y = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int> time = new List<int>();
            for (int i = 0; i < x[0]; i++)
            {
                time.Add(x[i * 2 + 1] * 60 + x[i * 2 + 2]);
            }
            for (int i = 0; i < y[0]; i++)
            {
                int a = y[i * 2 + 1] * 60 + y[i * 2 + 2];
                if (!time.Contains(a)) time.Add(a);
            }
            int[] ret = time.ToArray();
            Array.Sort(ret);
            Console.Write(ret[0] / 60 + ":");
            if (ret[0] % 60 < 10) Console.Write("0");
            Console.Write(ret[0] % 60);
            for (int i = 1; i < ret.Count(); i++)
            {
                Console.Write(" ");
                Console.Write(ret[i] / 60 + ":");
                if (ret[i] % 60 < 10) Console.Write("0");
                Console.Write(ret[i] % 60);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 10112
#include <iostream>
#include <vector>
#include <queue>

struct QueueType
{
  unsigned t;
  unsigned a;
  
  QueueType(unsigned t, unsigned a) : t(t), a(a) {}
  
  bool operator<(const QueueType &qt) const
  {
    return (a == qt.a) ? t < qt.t : a < qt.a;
  }
};

int main()
{
  unsigned K, T;
  std::cin >> K >> T;
  
  std::priority_queue<QueueType> pq;
  for(unsigned t=0; t<T; ++t)
  {
    unsigned a;
    std::cin >> a;
    
    pq.emplace(t, a);
  }
  
  unsigned t = -1;
  unsigned c = 0;
  while(!pq.empty())
  {
    QueueType qt = pq.top(); pq.pop();
    
    if(qt.t == t)
    {
      if(pq.size() > 0)
      {
        QueueType qt2 = pq.top(); pq.pop();
        t = qt2.t;
        if(qt2.a > 1)
        {
          pq.emplace(qt2.t, qt2.a - 1);
        }
        pq.emplace(qt.t, qt.a);
      }
      else
      {
        ++c;
        if(qt.a > 1)
        {
          pq.emplace(qt.t, qt.a - 1);
        }
      }
    }
    else
    {
      t = qt.t;
      if(qt.a > 1)
      {
        pq.emplace(qt.t, qt.a - 1);
      }
    }
  }
  
  std::cout << c << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int dp[2][10001][2];

int main(){
  int N;
  while(~scanf("%d",&N)){
    vector<int> costs;
    for(int i = 0; i < N - 1; i++){
      int cost;
      scanf("%d",&cost);
      costs.push_back(cost);
    }

    memset(dp,0x3f,sizeof(dp));
    dp[0][0][0] = 0;
    for(int pos = 0; pos < N; pos++){
      for(int num_of_zero = pos; num_of_zero >= 0; num_of_zero--){
        dp[(pos+1) % 2][num_of_zero+1][0]
          = min(dp[pos % 2][num_of_zero][0],dp[pos % 2][num_of_zero][1] + costs[pos]);
        dp[(pos+1) % 2][num_of_zero][1]
          = min(dp[pos % 2][num_of_zero][1],dp[pos % 2][num_of_zero][0] + costs[pos]);
      }
      memset(dp[pos % 2],0x3f,sizeof(dp[pos % 2]));
    }
    printf("%d\n",dp[N % 2][N / 2][0]);
    break;
  }
}

Measured memory_bytes: 1472
#include<stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	int i,min,max,a[10000];
	long sum=0;
	for(i=1;i<=n;i++){
	scanf("%d",&a[i]);
	sum += a[i];
	}
	min = max = a[1];
	for(i=1;i<=n;i++){
	if(a[i] < min) min = a[i];
	if(a[i] > max) max = a[i];
	}	
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

using namespace std;
signed main(){
  string s;
  cin>>s;
  int ans=700;
  rep(i,s.size()){
    if(s[i]=='o')ans+=100;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;

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

    map<string, int> ma;
    int now = 0;
    for (int i = 0; i < n; i++) {
        string s;
        int t;
        cin >> s >> t;
        now += t;
        ma[s] = now;
    }
    string x;
    cin >> x;

    cout << now - ma[x] << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;

	cin >> a >> b >> c;

	int saidai = max(a, max(b, c));

	int goukei = a + b + c;
	if (saidai * 3 % 2 == goukei % 2) {
		cout << (3 * saidai - goukei) / 2 << endl;
	}
	else
	{
		cout << (3 * saidai + 3 - goukei) / 2 << endl;
	}

}
	

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
	int n,a,b,c,d,f=1;
	while(~scanf("%d",&n)){
		f=1;
		a=n/1000;
		b=(n-a*1000)/100;
		c=(n-a*1000-b*100)/10;
		d=n-a*1000-b*100-c*10;
		if(a==b&&b==c&&c==d||a==b&&b==c||b==c&&c==d){
			printf("Yes\n");
			f=0;
		}
		if(f==1)
			printf("No\n");
	}
}

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

t=x=y=0

for _ in range(N):
    ti,xi,yi = map(int,input().split())
    T = ti-t
    X = xi-x
    Y = yi-y
    if ((T%2==0 and (X+Y)%2==0) or (T%2==1 and (X+Y)%2==1)) and T >= abs(X+Y):
        t=ti
        x=xi
        y=yi
    else:
        print('No')
        break
else:print('Yes')

Measured memory_bytes: 9052