akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, t; cin >> n >> t;
    VI a(n), b(n);
    FOR(i, 0, n)cin >> a[i] >> b[i];

    auto dp = vec<int>(n + 1, t, 2);
    FOR(i, 0, n)FOR(j, 0, t) {
        FOR(k, 0, 2) {
            chmax(dp[i + 1][j][k], dp[i][j][k]);
            if (j + a[i] < t) {
                chmax(dp[i + 1][j + a[i]][k], dp[i][j][k] + b[i]);
            }
        }
        chmax(dp[i + 1][j][1], dp[i][j][0] + b[i]);
    }

    int ans = 0;
    FOR(j, 0, t)FOR(k, 0, 2)chmax(ans, dp[n][j][k]);
    cout << ans << "\n";
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	std::vector<std::vector<bool> > a;
	a.push_back({});
	for (int i = 0; i < n; i++) {
		if (s[i] == 'A') {
			a.back().push_back(true);
		} else if (i + 1 < n && s[i] == 'B' && s[i + 1] == 'C') {
			a.back().push_back(false);
			i++;
		} else {
			if (a.size() && a.back().size()) a.push_back({});
		}
	}
	if (a.size() && !a.back().size()) a.pop_back();
	long long res = 0;
	for (auto &i : a) {
		int cur = 0;
		for (auto j : i) {
			if (j) cur++;
			else res += cur;
		}
	}
	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 4888
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int n,m,a[100010],fa[100010];
int findfa(int x) {return fa[x]==x?x:fa[x]=findfa(fa[x]);}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d %d",&x,&y);
		int tx=findfa(x),ty=findfa(y);
		fa[tx]=ty;
	}
	int ans;
	for(int i=1;i<=n;i++) if(findfa(a[i])==findfa(i)) ans++;
	printf("%d",ans);
}

Measured memory_bytes: 1024
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  int t[100010],x[100010],y[100010];
  x[0]=0,y[0]=0,t[0]=0;
  for(int i=1; i<=n; i++){
    std::cin >> t[i] >> x[i] >> y[i] ;
  }
  bool f=true;
  for(int i=1; i<=n; i++){
    int tim=t[i]-t[i-1];
    int dist=abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);

    if( tim<dist || tim%2 != dist%2 ) f=false;
  }
  if(f) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> & vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

int main() {
	IOS;
	// cout << fixed << setprecision(20);
	// int a;cin >> a;
	// string s;cin>>s;
	Int n, k; cin >> n >> k;
	vector<int> a(n), b;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	Int cnt = 0, cnt2 = 0;
	Int ans = 0;
	for (int i = 0; i < n; i++) {
		int num = a[i];
		cnt = 0;
		cnt2 = 0;
		for (int j = i + 1; j < n; j++) {
			if (num > a[j])cnt++;
		}
		for (int k = 0; k < n; k++) {
			if (num > a[k])cnt2++;
		}
		//cout << num << " " << cnt << endl;
		Int dif = cnt2 - cnt;
		//cout << dif << endl;
		Int z = k % MOD;
		// ans += k *(k + 1) / 2 % MOD *cnt2 % MOD - dif * k % MOD;
		ans += k * (k - 1) / 2 % MOD * cnt2 % MOD + k * cnt % MOD;//AC
		//ans%=MOD;
	}

	cout << ans % MOD;

	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

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

ll f(ll h)
{
    if (h == 1) return 1;
    return 2*f(h/2) + 1;
}

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n, t;
    cin >> n >> t;

    vector<int> a(n), b(n, 2000000000);

    rep(i, n) {
        cin >> a[i];
    }

    b[0] = a[0];
    repi(i, 1, n) {
        b[i] = min(b[i-1], a[i]);
    }

    map<int, int> c;
    rep(i, n) {
        c[a[i] - b[i]]++;
    }

    cout << (--(c.end()))->second;







    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 5760
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 100010
#define M 2000100
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define FJ(i,a,b) for(int i=a;i<b;++i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define FD T&q=fd[rt],&ql=fd[rt<<1],&qr=fd[rt<<1|1]
#define MID int mid=((l+r)>>1)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define zero(x) (((x)>0?(x):-(x))<EPS)
#define PB push_back
#define SZ size
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define MP make_pair
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;
const int MOD=1000000007;
const double PI=acos(-1.0);
const double EPS=1e-8;
inline int II(){int n=0,ch=getchar();bool t=0;if(ch==-1)return 0;
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')t=1;
for(;ch>='0'&&ch<='9';n=n*10+ch-'0',ch=getchar());if(t)return -n;return n;}
inline void OO(int a){if(a<0){putchar('-');a=-a;}
if(a>=10)OO(a/10);putchar(a%10+'0');}
inline int sgn(double x){return(x>EPS)-(x<-EPS);}
struct edge{int v,w,nx;}E[M*2+N*2];int head[N],EN;
void init_edge(){EN=0;CL(head,-1);}
void add_edge(int u,int v,int w){
    E[EN]=(edge){v,w,head[u]};head[u]=EN++;
    E[EN]=(edge){u,w,head[v]};head[v]=EN++;
}
int n;
LL a[N],b[N];
LL ans=0,add=0;
int main(){
    //IN;
    SC(n);
    FF(i,1,n){
        scanf("%lld%lld",&a[i],&b[i]);
    }
    RR(i,n,1){
        if(a[i]){
            a[i]+=add;
            LL t=((a[i]-1)/b[i]+1)*b[i]-a[i];
            ans+=t;
            add+=t;
        }
    }
    printf("%lld\n",ans);
return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

N, Tl = map(int, input().split())
C, T = [], []
for _ in range(N):
    c, t = map(int, input().split())
    C.append(c)
    T.append(t)

ans = 10000
for i in range(N):
    if T[i] <= Tl:
        ans = min(ans, C[i])

if ans == 10000:
    print("TLE")
else:
    print(ans)


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    const int N_MAX = 1000;
    int N, M;
    ll x[N_MAX];
    ll y[N_MAX];
    ll z[N_MAX];
    cin >> N >> M;
    REP(i, N) cin >> x[i] >> y[i] >> z[i];
    ll result = LLONG_MIN;
    REP(s1, 2) {
        REP(s2, 2) {
            REP(s3, 2) {
                vector<ll> v;
                REP(i, N) {
                    ll w = 0;
                    s1 == 0 ? w += x[i] : w -= x[i]; 
                    s2 == 0 ? w += y[i] : w -= y[i]; 
                    s3 == 0 ? w += z[i] : w -= z[i]; 
                    v.push_back(w);
                }
                sort(v.begin(), v.end(), greater<ll>());
                ll acc = 0;
                REP(i, M) {
                    acc += v[i];
                }
                if (result < acc) {
                    result = acc;
                }
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();
    let d: i64 = input();

    let g = lcm(c, d);
    let l = b / c - (a - 1) / c;
    let m = b / d - (a - 1) / d;
    let n = b / g - (a - 1) / g;
    println!("{}", b - a + 1 - l - m + n);
}

fn lcm(n: i64, m: i64) -> i64 {
    n * m / gcd(n, m)
}

fn gcd(n: i64, m: i64) -> i64 {
    if m == 0 {
        n
    } else {
        gcd(m, n % m)
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,n,d;
cin>>n;
    int ans[10005]={0};
    for(a=1;a<101;a++){
        for(b=1;b<101;b++){
            for(c=1;c<101;c++){
                d=a*a+b*b+c*c+a*b+b*c+c*a;
                if(d>n)continue;
                ans[d]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
    cout<<ans[i]<<endl;}
    return 0;
}

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

int n, k;
ll ans;

int main() {
  cin >> n >> k;
  vector<ll> sumL(n+1, 0);
  vector<ll> sumR(n+1, n);
  rep (i, n) {
    sumL.at(i+1) = sumL.at(i) + i + 1;
  }
  for (int i = n - 1; i >= 0; i--) {
    sumR.at(i) = sumR.at(i+1) + i;
  }
  reverse(sumR.begin(), sumR.end());
  for (int i = k-1; i < n+1; i++) {
    ans += sumR.at(i) - sumL.at(i) + 1;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6428
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code

        int H = sc.nextInt(), W = sc.nextInt();
        boolean[][] map = new boolean[H][W];
        for (int h = 0; h < H; h++) {
            String s = sc.next();
            for (int w = 0; w < W; w++) {
                map[h][w] = s.charAt(w) == '#';
            }
        }

        // dp[h][w][f] := (w, h) の色を白にするためにflipしている: 1, していない:0時の最小回数
        int[][][] dp = new int[H + 1][W + 1][2];
        for (int[][] a: dp) for (int[] b : a) Arrays.fill(b, 1 << 30);
        dp[1][1][map[0][0] ? 1 : 0] = map[0][0] ? 1 : 0;

        for (int h = 1; h <= H; h++) {
            for (int w = 1; w <= W; w++) {
                if (w > 1) {
                    if (map[h - 1][w - 2] == map[h - 1][w - 1]) {
                        dp[h][w][0] = Math.min(dp[h][w][0], dp[h][w - 1][0]);
                        dp[h][w][1] = Math.min(dp[h][w][1], dp[h][w - 1][1]);
                    } else {
                        dp[h][w][0] = Math.min(dp[h][w][0], dp[h][w - 1][1]);
                        dp[h][w][1] = Math.min(dp[h][w][1], dp[h][w - 1][0] + 1);
                    }
                }
                if (h > 1) {
                    if (map[h - 2][w - 1] == map[h - 1][w - 1]) {
                        dp[h][w][0] = Math.min(dp[h][w][0], dp[h - 1][w][0]);
                        dp[h][w][1] = Math.min(dp[h][w][1], dp[h - 1][w][1]);
                    } else {
                        dp[h][w][0] = Math.min(dp[h][w][0], dp[h - 1][w][1]);
                        dp[h][w][1] = Math.min(dp[h][w][1], dp[h - 1][w][0] + 1);
                    }
                }
//                debug(w, h, dp[h][w][0], dp[h][w][1]);
            }
        }
        out.println(dp[H][W][map[H - 1][W - 1] ? 1 : 0]);

        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 23172
#[allow(unused_imports)]
use std::io::Write;
use std::collections::VecDeque;

// {{{
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// }}}

fn main() {
    input! {
        n: usize,
        d: i64,
        a: i64,
        monster: [(i64, i64); n],
    }

    let mut monster = monster;
    monster.sort();

    let d = d * 2;
    let mut tot = 0i64;
    let mut q = VecDeque::<(i64, i64)>::new(); // (coord, damage)
    let mut ans = 0i64;
    for m in monster {
        let (x, h) = m;
        while let Some((coord, damage)) = q.pop_front() {
            if coord >= x {
                q.push_front((coord, damage));
                break;
            }
            tot -= damage;
        }
        let mut h = h;
        h -= tot;
        if h > 0 {
            let num = (h + a - 1) / a;
            ans += num;
            let damage = num * a;
            tot += damage;
            q.push_back((x + d, damage));
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 16632
#define MOD_TYPE 1

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

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;

/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int csum[200010];
  csum[0] = 0;
  rep(i, n)
  {
    csum[i + 1] = csum[i] + (s[i] == 'R');
  }
  int Min = INF;
  rep(i, n + 1) // 前i個がR
  {
    int R1 = csum[i];
    int R2 = csum[n] - csum[i];
    int W1 = i - R1;
    int W2 = (n - i) - R2;
    int t = n - R1 - W2;
    t -= min(R2, W1);
    chmin(Min, t);
  }
  cout << Min << "\n";
}

int main()
{
  init_main();
  solve();
}


Measured memory_bytes: 4552
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		int f = 1;
		
		if(n > 1) {
			int f1 = 1;
			int f2 = 1;
			f = 0;
			
			for(int i = 1; i < n; i++) {
				f = f1 + f2;
				f1 = f2;
				f2 = f;
			}
		}
		
		System.out.println(f);
	}

}

Measured memory_bytes: 26092
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}
ll MOD = 1000000007;

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}
int N;
int main()
{
	cin >> N;
	ll cnt = 1;
	rep(i, N) {
		cnt *= (i + 1);
		cnt %= MOD;
	}
	cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))


signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int a,b,c,d; cin >> a >> b >> c >> d;
    int dx=d-b,dy=c-a;
    rep(i,dx)cout<<'U';
    rep(i,dy)cout<<'R';
    rep(i,dx)cout<<'D';
    rep(i,dy+1)cout<<'L';
    
    rep(i,dx+1)cout<<'U';
    rep(i,dy+1)cout<<'R';
    cout<<'D';
    cout<<'R';
    rep(i,dx+1)cout<<'D';
    rep(i,dy+1)cout<<'L';
    cout<<'U';
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,val[100005][5];
int main()
{
    //int n,val[100005][5];
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=3;j++)
            cin>>val[i][j];
    for(int i=2;i<=n;i++)
    {
        int a,b;
        for(int j=1;j<=3;j++)
        {
            if(j==1){a=2;b=3;}
            if(j==2){a=1;b=3;}
            if(j==3){a=1;b=2;}
            if((val[i][j]+val[i-1][a])>(val[i][j]+val[i-1][b]))
                val[i][j]=val[i][j]+val[i-1][a];
            else val[i][j]=val[i][j]+val[i-1][b];
        }
    }
    cout<<max(val[n][1],max(val[n][2],val[n][3]))<<"\n";

}


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

#define ll long long int

using namespace std;


ll f(ll n, ll x, vector<ll> const & A, vector<ll> const & P) {
    if (x < 1) return 0;
    if (n == 0) return 1;
    if (x > 1 && x <= A[n-1] + 1) return f(n-1, x-1, A, P);
    if (x >= (1 + A[n-1] + 1)) return P[n-1] + 1 + f(n-1, x - (1 + A[n-1] + 1), A, P);
    return 0;
}

int main() {
    ll n, x;
    cin >> n >> x;
    vector<ll> A(n+1,1), P(n+1,1);

    for (ll i = 1; i <=n; ++i) {
        A[i] = 2 * A[i-1] + 3;
        P[i] = 2 * P[i-1] + 1;
    }
    ll res = f(n, x, A, P);
    cout << res << endl;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <iostream>
#include <math.h>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    int a[q], cor[n];
    REP(i, n)
    cor[i] = 0;
    REP(i, q) {
        cin >> a[i];
        cor[a[i] - 1]++;
    }
    REP(i, n) {
        if (q - cor[i] >= k) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s.at(i) == t.at(i)) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


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



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

  vector< int > v(n);
  for(int i =0; i<n; i++){
    cin>>v[i];
  }
  int step[n];
  step[0]=0;
  step[1] = abs(v[1]-v[0]);
  for(int i=2; i<n;i++){
      step[i] = min((abs(step[i-2])+abs(v[i]-v[i-2])), (abs(step[i-1])+abs(v[i] - v[i-1])));
  }
  if(n==0 || n==1){
    cout<<0;
    return 0;
  }

  cout<<step[n-1]<<"\n";

}


Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  vector<int> begin(n);
  vector<int> end(n);
  for(int i = 0;i < n;i++)begin[i] = i + a[i];
  for(int i = 0;i < n;i++)end[i] = i - a[i];
  map<int,int> count;
  for(int i = 0;i < n;i++)count[begin[i]]++;
  ll res = 0;
  for(int i = 0;i < n;i++){
    res += count[end[i]];
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 22668
n,m=map(int,input().split())
l=[0]*(n+1)
mod=10**9+7
for i in range(m):
    l[int(input())]=-1
l[0]=1
for i in range(n):
    if l[i]==-1:continue
    if l[i+1]!=-1:
        l[i+1]=(l[i+1]+l[i])%mod
    if i+2<=n:
        if l[i+2]!=-1:l[i+2]=(l[i+2]+l[i])%mod
print(l[n])

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

int main(){
    int r, d, i;
    long int x_0, x_1;
    cin >> r >> d >> x_0;
    for(i=0;i<10;i++){
        x_1 = r*x_0-d;
        cout << x_1 << endl;
        x_0 = x_1;
    }
    return 0;
}

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

int main() {
 UL N; scanf("%u",&N);
 UL A[200001]; rep(i,N) scanf("%u",&A[i]); A[N]=~0u;
 UL M; scanf("%u",&M);
 UL B[200001]; rep(i,M) scanf("%u",&B[i]); B[M]=~0u;
 UL p=0,q=0;
 while(p+q<N+M){
  if(A[p]<B[q]){ printf("%u\n",A[p]); p++; }
  else if (A[p]>B[q]){ q++; }
  else { p++; q++; }
 }
 return 0;
}



Measured memory_bytes: 4744
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
ll dp[100100];
 
int main() {
     string s;
     cin >> s;
     rep(i,s.size()){
         if(i%2==1){
             if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
                 cout << "No" <<endl;
                 return 0;
             }
         }
         else{
             if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
                 cout << "No" <<endl;
                 return 0;
             }
         }
     }
     cout << "Yes" <<endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "2 10 20" ].parse.expand.solve == "30\n50\n90\n170\n330\n650\n1290\n2570\n5130\n10250" );
	assert( [ "4 40 60" ].parse.expand.solve == "200\n760\n3000\n11960\n47800\n191160\n764600\n3058360\n12233400\n48933560" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto rdx = input.front.split.to!( long[] );
	return tuple( rdx[ 0 ], rdx[ 1 ], rdx[ 2 ] );
}

auto solve( long r, long d, long xa )
{
	auto xs = new long[]( 11 );
	xs[ 0 ] = xa;
	for( auto i = 1L; i < xs.length; i++ )
	{
		xs[ i ] = r * xs[ i - 1 ] - d;
	}
	return xs[ 1 .. $ ].to!( string[] ).join( "\n" );
}


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

    neg_num = 0
    sum_abs = 0
    min_abs = 100000
    for i in input().split():
        number = int(i)
        if number < 0:
            neg_num +=1

        sum_abs += abs(number)
        min_abs = min(min_abs, abs(number))

    if neg_num % 2 == 0:
        print(sum_abs)
    else:
        print(sum_abs - min_abs*2)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 11212
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int h ,w, k; cin >> h >> w >> k;
	vector<vector<char>> s(h, vector<char>(w));
	rep(i, h) {
		rep(j, w) {
			cin >> s[i][j];
		}
	}
	vector<vector<int>> c(h, vector<int>(w, 0));
	int t = 1;
	rep(i, h) {
		bool check = false;
		rep(j, w) {
			if(s[i][j] == '#') check = true;
		}

		if(check) {
			int cnt = 0;
			rep(j, w) {
				if(s[i][j] == '#') {
					cnt ++;
				}

				if(cnt == 0) {
					c[i][j] = t;
				} else {
					c[i][j] = t + cnt - 1;
				}
				if(j == w - 1) {
					t = t + cnt - 1;
					++t;
				}
			}
		} else {
			if(i == 0) continue;
			rep(j, w) {
				c[i][j] = c[i - 1][j];
			}
		}
	}

	per(i, h) {
		if(c[i][0] == 0) {
			if(i == h - 1) continue;
			rep(j, w) {
				c[i][j] = c[i + 1][j];
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << c[i][j];
			if(j != w - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 1280
N = int(input())
dict = {}
for i in range(1,N+1):
    s,p = input().split()
    pt = int(p)
    if s in dict:
        dict[s].append((pt,i))
    else:
        dict[s] = [(pt,i)]
for key in dict:
    dict[key].sort(key = lambda x: -x[0])
    # print(key,dict[key])
d = list(dict)
d.sort()
# print(d)
for town in d:
    for p,id in dict[town]:
        print(id)

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

int main(){
  int check = 0;
  string S;
  cin >> S;
  for(int i=0; i<4 ; i++){
    for(int j=i+1; j<4; j++){
      if(S.at(i) == S.at(j)){
        check ++;
      }
    }
  }
  if(check == 2){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int> > f(n, vector<int>(m));
    for(int i=0; i<n; ++i){
        for(int j=0; j<m; ++j){
            cin >> f[i][j];
        }
    }

    int d;
    cin >> d;
    vector<int> inCnt(n, 0);
    vector<vector<int> > edges(n);
    for(int i=0; i<d; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(b);
        ++ inCnt[b];
    }

    vector<int> e(m);
    for(int i=0; i<m; ++i){
        cin >> e[i];
        -- e[i];
    }
    int r;
    cin >> r;
    vector<int> eThreshold(r);
    vector<vector<int> > eList(r, vector<int>(m));
    for(int i=0; i<r; ++i){
        cin >> eThreshold[i];
        for(int j=0; j<m; ++j){
            cin >> eList[i][j];
            -- eList[i][j];
        }
    }

    vector<vector<int> > permutation(1, vector<int>(m));
    for(int i=0; i<m; ++i)
        permutation[0][i] = i;
    for(;;){
        vector<int> v = permutation.back();
        if(!next_permutation(v.begin(), v.end()))
            break;
        permutation.push_back(v);
    }

    vector<priority_queue<pair<vector<int>, int> > > pq(permutation.size());
    for(int i=0; i<n; ++i){
        if(inCnt[i] != 0)
            continue;
        for(unsigned j=0; j<permutation.size(); ++j){
            vector<int> f2(m);
            for(int k=0; k<m; ++k)
                f2[k] = f[i][permutation[j][k]];
            pq[j].push(make_pair(f2, i));
        }
    }

    int eNext = 0;
    vector<bool> check(n, false);
    for(int i=0; i<n; ++i){
        if(eNext < r && eThreshold[eNext] == i){
            e = eList[eNext];
            ++ eNext;
        }

        int eIndex = find(permutation.begin(), permutation.end(), e) - permutation.begin();
        int curr;
        for(;;){
            curr = pq[eIndex].top().second;
            pq[eIndex].pop();
            if(!check[curr])
                break;
        }
        cout << (curr + 1) << endl;
        check[curr] = true;

        for(int next : edges[curr]){
            -- inCnt[next];
            if(inCnt[next] == 0){
                for(unsigned j=0; j<permutation.size(); ++j){
                    vector<int> f2(m);
                    for(int k=0; k<m; ++k)
                        f2[k] = f[next][permutation[j][k]];
                    pq[j].push(make_pair(f2, next));
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 84996
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# import os
# fin = open('in_2.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    # tokens = iterate_tokens()
    # N = int(next(tokens))  # type: int
    # K = int(next(tokens))  # type: int
    # S = next(tokens)  # type: str
    N, K = mi()
    S = li()

    # write code
    A = list(S)
    A[K-1] = A[K-1].lower()
    print(''.join(A))


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

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		ans += (a - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    N, M = (int(i) for i in input().split())
    G = [[] for _ in range(N)]
    edges = []
    s = -1
    for i in range(M):
        a, b = (int(i)-1 for i in input().split())
        if i == 0:
            s = a
        G[a].append(b)
        G[b].append(a)
        edges.append((a, b))

    def dfs(v, seen, remove_edge):
        todo = []
        seen[v] = True
        todo.append(v)
        while todo:
            u = todo[-1]
            for next_v in G[u]:
                if seen[next_v]:
                    continue
                if (u, next_v) == remove_edge or (next_v, u) == remove_edge:
                    continue
                seen[next_v] = True
                todo.append(next_v)
                break
            else:
                todo.pop()

    ans = 0
    for e in edges:
        seen = [False] * N
        dfs(s, seen, e)
        if all(seen):
            continue
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  vector<int> x(3);
  for (int i=0; i<3; i++){
    cin >>x.at(i);
  }
  sort(x.begin(), x.end());
  cout <<x.at(0)+x.at(1) <<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

# from collections import deque

def linput(_t=int): return list(map(_t, input().split()))

def gcd(n,m):
    while m: n,m = m, n%m
    return n

def lcm(n,m): return n*m//gcd(n,m)

def main():
    # N = int(input())
    # A = int(input())
    A,B,C = linput(str)
    # B,C = linput()
    # S = input()

    # vA = linput()
    # S = input()
    # mX = [linput() for _ in [0,]*N]

    # res = 0
    # res = sum(int(a) for a in (A,B,C))
    # print(res)
    print(C,A,B)
    # print(("No","Yes")[res%2])


main()


Measured memory_bytes: 3060
n=int(input())
a=a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
if n%2==0:
  for i in range(1,n//2):
    ans +=2*a[i]
  ans+=a[0]
else:
  for i in range(1,n//2):
    ans +=2*a[i]
  ans +=a[n//2]
  ans+=a[0]
print(ans)

Measured memory_bytes: 31676
N,*L = $<.read.split.map(&:to_i)

B = [1-L[0]]+[0]*N
N.downto(1).inject(0){|s,i|
	L[i] + B[i]=s
}
N.times{|d|
	b = B[d]*2 - L[d+1]
	(p(-1); exit) if b<0
	B[d+1] = b if b < B[d+1]
}
(p(-1); exit) if B[-1]!=0

p B.sum+L.sum


Measured memory_bytes: 22960
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int x;

//使用する関数
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;
}



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

	cin >> x;
	cout << (x / 500) * 1000 + ((x % 500) / 5) * 5 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
	public static void main(String... args) {
		Main m = new Main();
		m.solve();
		m.close();
	}

	Scanner sc;
	PrintWriter pw;
	public Main() {
		sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
	}
	private void close() {
		pw.flush();
		pw.close();
	}
	private void solve() {
		while(sc.hasNextLong()) {
			BigInteger a = BigInteger.valueOf(sc.nextLong());
			BigInteger b = BigInteger.valueOf(sc.nextLong());
			pw.printf("%d %d\n",gcd(a,b),lcm(a,b));
		}
	}
	// 最大公約数
	public BigInteger gcd(BigInteger l, BigInteger r){
		return l.gcd(r);
	}
	// 最小公倍数
	public BigInteger lcm(BigInteger l, BigInteger r){
		return l.multiply(r).divide(l.gcd(r));
	}
}

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

int main(){
    int n, m;
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        vector<int> a(n);
        rep(i, 0, n) cin >> a[i];
        int ans = -1;
        rep(i, 0, n){
            rep(j, i + 1, n){
                if(a[i] + a[j] <= m){
                    ans = max(ans, a[i] + a[j]);
                }
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}

Measured memory_bytes: 3068