akhauriyash/Code-Regression huggingface dataset:
N,M=map(int,input().split())
if(abs(N-M)>=2):
    print(0)
elif(abs(N-M)==1):
    h=max(N,M)
    t=1
    m=1
    for i in range(1,h+1):
        t=(t*i)%1000000007
        if(i==h-1):
            m=t
    print((t*m)%1000000007)
elif(N==M):
    t=1
    for i in range(1,N+1):
        t=(t*i)%1000000007
    print((t**2*2)%1000000007)

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

int main(void) {
	string S, T, U;
	cin >> S >> T;
	int A, B;
	scanf("%d %d", &A, &B);
	cin >> U;
	if (U == S) {
		A--;
	} else if (U == T) {
		B--;
	}
	printf("%d %d", A, B);

	return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#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(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

int yote[1001];
int hose[1001];

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

	ll n;
	cin >> n;
	int a[1001][1001];
	rep(i, n)
	{
		rep(j, n - 1)
		{
			cin >> a[i][j];
		}
	}

	ll day = 0;
	bool flag = false;
	//	vector<vector<ll>> yote(n, vector<ll>(n - 1, 0));

	int hantei = 0;
	for (int j = n - 2; j >= 0;)
	{
		flag = false;
		for (int i = 0; i < n; i++)
		{
			if (j - hose[i] < 0)
			{
				continue;
			}

			yote[i] = a[i][j - hose[i]];

			if (yote[a[i][j - hose[i]]-1] == i + 1)
			{
				hose[a[i][j - hose[i]]-1]++;
				hose[i]++;

				flag = true;
			}
		}
		if (!flag)
			break;

		day++;
		for (int i = 0; i < n; i++)
		{
			yote[i] = 0;
			if (hose[i] >= n - 1)
				hantei++;
		}
		if (hantei == n)
			break;
		hantei = 0;
	}

	if (flag)
	{
		cout << day << endl;
	}
	else
	{
		cout << -1 << endl;
	}

}

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


int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    rep(i,n) cin>>x[i];
    
    int ans = 1e9;
    rep(i,n-k+1){
        int l=x[i];
        int r=x[i+k-1];
        ans=min(ans,r-l+min(abs(l),abs(r)));
    }
    cout<< ans << endl;
    return 0;
}


Measured memory_bytes: 640
from collections import Counter
import math
N = int(input())

L = math.sqrt(N)
# print(L)
now = 0
for i in range(1, int(L)+1):
    # print(i)

    if N % i == 0:
        tmp = i + N / i -2
        if now == 0:
            now = tmp
        elif now >= tmp:
            now = tmp
        
        # print(i)
        # print(N/i)
print(int(now))

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b;
	cin >> a >> b;
	vi h(1000, 0);
	h[1] = 1;
	rep2(i, 2, 1000) {
		h[i] = h[i - 1] + i;
		if (h[i] - h[i - 1] == b - a) {
			cout << h[i] - b << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] ags){
		Scanner sc = new Scanner(System.in);
		int reg=0;
		int num2 = sc.nextInt();
		int num=num2;
		int reg2=0;
		for(reg=0;num>0;reg++){
			if(num%10==0&&num>=10){
				while(num%10==0){
					num/=10;
				}
			}
			if(num>0){
				num--;
			}
		}
		if(num2%reg==0){
				reg2=1;
		}
		if(reg2==1){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

class Point {
public:
  ld x, y;

  Point() {}
  Point(ld x, ld y): x(x), y(y) {}

  Point operator + (const Point &p) {
    return Point(x + p.x, y + p.y);
  }
  Point operator - (const Point &p) {
    return Point(x - p.x, y - p.y);
  }
  Point operator * (const ld k) {
    return Point(x * k, y * k);
  }
  Point operator / (const ld k) {
    return Point(x / k, y / k);
  }
  Point operator += (const Point &p) {
    x += p.x;
    y += p.y;
    return *this;
  }
  Point operator -= (const Point &p) {
    x -= p.x;
    y -= p.y;
    return *this;
  }
  Point operator *= (const ld k) {
    x *= k;
    y *= k;
    return *this;
  }
  Point operator /= (const ld k) {
    x /= k;
    y /= k;
    return *this;
  }
  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point &p) const {
    return equals(x, p.x) && equals(y, p.y);
  }
  friend ostream& operator << (ostream &os, const Point &p) {
    os << p.x << ' ' << p.y;
    return os;
  }
  friend istream& operator >> (istream &is, Point &p) {
    ld x, y;
    is >> x >> y;
    p = Point(x, y);
    return is;
  }

  ld abs() {return sqrt(norm());}
  ld norm() {return x * x + y * y;}
};

ld dot(Point a, Point b) {
  return a.x * b.x + a.y * b.y;
}

ld cross(Point a, Point b) {
  return a.x * b.y - a.y * b.x;
}

class Segment {
public:
  Point p1, p2;

  Segment() {}
  Segment(Point p1, Point p2): p1(p1), p2(p2) {}
};

Point project(Segment s, Point p) {
  Point base = s.p2 - s.p1;
  ld r = dot(p - s.p1, base) / base.norm();
  return s.p1 + base * r;
}

class Circle {
public:
  Point p;
  ld r;

  Circle() {}
  Circle(Point p, ld r): p(p), r(r) {}
};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  Segment s;
  cin >> s.p1 >> s.p2;
  int q;
  cin >> q;
  while (q--) {
    Point p;
    cin >> p;
    cout << project(s, p) << '\n';
  }

  

  
  return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;

vector<vector<char>> ch;
vector<vector<bool>> visit;
int dx[8]={1, 0, -1, 0, 1, 1, -1, -1};
int dy[8]={0, 1, 0, -1, 1, -1, 1, -1};
int w, h;

void dfs(int x, int y){
    visit[x][y]=true;
    for(int i=0; i<8; i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
        if(visit[nx][ny] != 0 || ch[nx][ny] == '0') continue;
        dfs(nx, ny);
    }
}

int main(){
    while(cin >> w >> h){
        if(w==0 && h==0) break;
        ch.assign(h, vector<char>(w));
        visit.assign(h, vector<bool>(w,0));
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> ch[i][j];
            }
        }
        int res=0;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(ch[i][j] == '1' && visit[i][j] == 0){
                    dfs(i, j);
                    res++;
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}




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

using pii = pair<int, int>;

int main() {
    string s;
    while(cin >> s) {
        vector<string> v(8);
        v[0] = s;
        for(int i = 0; i < 7; ++i) {
            cin >> v[i + 1];
        }
        vector<vector<pii>> m = {{pii{0, 0}, pii{0, 1}, pii{1, 0}, pii{1, 1}},
                                 {pii{0, 0}, pii{1, 0}, pii{2, 0}, pii{3, 0}},
                                 {pii{0, 0}, pii{0, 1}, pii{0, 2}, pii{0, 3}},
                                 {pii{0, 0}, pii{1, -1}, pii{1, 0}, pii{2, -1}},
                                 {pii{0, 0}, pii{0, 1}, pii{1, 1}, pii{1, 2}},
                                 {pii{0, 0}, pii{1, 0}, pii{1, 1}, pii{2, 1}},
                                 {pii{0, 0}, pii{0, 1}, pii{1, -1}, pii{1, 0}}};
        vector<pii> b;
        for(int i = 0; i < 8; ++i) {
            for(int j = 0; j < 8; ++j) {
                if(v[i][j] == '1') b.emplace_back(i, j);
            }
        }
        sort(begin(b), end(b));
        for(int i = 3; i >= 0; --i) {
            b[i].first -= b[0].first;
            b[i].second -= b[0].second;
        }

        char ans = 'A' + find(begin(m), end(m), b) - begin(m);
        cout << ans << endl;
    }
}



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

int main() {
  
  int N, X, T;
  cin >> N >> X >> T;
  
  int kaisu;
  
  if(N%X == 0) kaisu = N / X;
  else kaisu = N / X +1;
  
  cout << kaisu * T << endl;
  
}

Measured memory_bytes: 3632
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v: Vec<u32> = read_vec();
    let (n, r) = (v[0], v[1]);
    if n >= 10 {
        println!("{}", r);
    } else {
        println!("{}", r + 100 * (10 - n));
    }
}


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

void solver() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  long long ans = 0;
  if (k <= a) {
    ans += 1 * k;
  } else {
    k -= a;
    ans += a;
    if (k > b) {
      k -= b;
      ans -= 1 * k;
    }
  }

  cout << ans << "\n";
}

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
#define int long long 
signed main(void){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    REP(i,tx-sx){
        cout << 'R';
    }
    REP(i,ty-sy){
        cout << 'U';
    }
    REP(i,tx-sx){
        cout << 'L';
    }
    REP(i,ty-sy){
        cout << 'D';
    }
    cout << 'D';
    REP(i,tx-sx+1){
        cout << 'R';
    }
    REP(i,ty-sy+1){
        cout << 'U';
    }
    cout << "LU";
    REP(i,tx-sx+1){
        cout << 'L';
    }
    REP(i,ty-sy+1){
        cout << 'D';
    }
    cout << 'R';
       
    cout << endl;
    return 0;
}

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

using ll = long long;

using namespace std;

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k < a) cout << k << '\n';
    else if (k < a + b) cout << a << '\n';
    else cout << a - (k - a - b) << '\n';
    return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
ll N, A[200010];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;

    ll t = 0;

    ll d[200010];

    REP(i,0,N){
        cin>>A[i];
        d[i] = (A[i] - (i+1));
    }
    sort(d, d+N);

    ll bb[3];

    bb[0] = d[N/2];
//    bb[0] = d[max(0LL, N/2 - 1)];
//    bb[1] = d[N/2];
//    bb[2] = d[min(N-1LL, N/2 + 1)];

    ll ans = LLINF;
    //REP(i,0,3){
    REP(i,0,1){
        ll b = bb[i];
        ll tans = 0;
        REP(j,0,N){
            tans += abs(A[j] - (j+1) - b);
        }
        ans = min(ans, tans);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;




int main()
{
    ll a,b=0;
    cin>>a;
    char car;
    cin>>car;
    b=b*10+car-'0';
    cin>>car;
    cin>>car;
    b=b*10+car-'0';
    cin>>car;
    b=b*10+car-'0';
    cout<<(a*b)/100;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std ;
int a[220];
int main(){
  int n,m;
  cin>>n>>m;
  a[1]=300000;
  a[2]=200000;
  a[3]=100000;
  
  if(n==1 and m==1){
    cout<<1000000<<endl;
  }
  else{
    cout<<a[n]+a[m]<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
vector<int> a, b;
int main() {
int N;
    cin >> N;
    a.resize(N); for (int i = 0; i < N; ++i) cin >> a[i];
    b.resize(N); for (int i = 0; i < N; ++i) cin >> b[i];
    int res = 0;
    for (int digit = 29; digit >= 0; --digit) {
        int bekihigh = 1<<(digit+1);
        int bekilow = 1<<digit;
        for (int i = 0; i < N; ++i) a[i] %= bekihigh, b[i] %= bekihigh;
        sort(b.begin(), b.end());
        long long num = 0;
        for (int i = 0; i < N; ++i) {
            int add = 0;
            if (bekilow - a[i] >= 0) {
                add += lower_bound(b.begin(), b.end(), bekihigh-a[i])
                        - lower_bound(b.begin(), b.end(), bekilow-a[i]);
            }
            else {
                add += lower_bound(b.begin(), b.end(), bekihigh-a[i]) - b.begin();
                add += lower_bound(b.begin(), b.end(), bekihigh)
                        - lower_bound(b.begin(), b.end(), bekihigh + bekilow - a[i]);
            }
            num += add;
        }
        if (num & 1) res += bekilow;
    }
    cout << res << endl;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010
#define mx7 10000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int cnt[mx7];

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

    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i)
            cnt[j]++;
    }

    LL ans = 0;
    for(int i = 1; i <= n; i++){
        ans += 1ll * i * cnt[i];
    }

    cout << ans << '\n';
    return 0;
}


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

int main() {
	int D;
	cin >> D;
	switch (D) {
		case 22:
			cout << "Christmas Eve Eve Eve\n";
			break;
		case 23:
			cout << "Christmas Eve Eve\n";
			break;
		case 24:
			cout << "Christmas Eve\n";
			break;
		case 25:
			cout << "Christmas\n";
			break;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> x(n);
  for(int i=0; i<n; i++){
    cin>>x.at(i);
  } 
  int sum=0;
  for(int i=0; i<n; i++){
    if(x.at(i)<=(k-x.at(i))){
      sum+=2*x.at(i);
    }
    if(x.at(i)>(k-x.at(i))){
      sum+=2*(k-x.at(i));
    }
  }
    cout<<sum<<endl;
}


Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <queue>
using namespace std;
struct process{
    string name;
    int time;
};


int main(){
    int n,q,count=0;
    cin>>n>>q;
    queue<process>a;
    while(n--){
        process x;
        cin>>x.name>>x.time;
        a.push(x);
    }
    while(1){
        if(a.empty()){
            break;
        }
        else{
            process b=a.front();
            a.pop();
            if(b.time<=q){
                count+=b.time;
                cout<<b.name<<" "<<count<<endl;
            }else{
                b.time-=q;
                count+=q;
                a.push(b);
            }
        }
    }
    return 0;
}




Measured memory_bytes: 6184
MAX = 10 ** 18
arr = $<.read.split.map(&:to_i).drop(1)

if arr.include?(0)
    ans = 0
else
    ans = 1
    arr.each do |x|
        ans *= x
        if MAX < ans
            ans = -1
            break
        end
    end
end

puts ans

Measured memory_bytes: 21748
#include<stdio.h>
int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  int a[3] = {A,B,C};
  for(int i = 0;i < 2;i++){
    for(int j = 0;j < 2;j++){
      if(a[j] < a[j + 1]){
        int t = a[j];
        a[j] = a[j + 1];
        a[j + 1] = t;
      }
    }
  }
  printf("%d",10 * a[0] + a[1] + a[2]);
  return 0;
}

Measured memory_bytes: 128
while True:
    m,f,r = map(int,input().split())
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif 80 <= m + f:
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if 50 <= r:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> a(N+1,0);
  for(int i=1;i<N+1;i++){
    cin>>a.at(i);
  }//代入
  vector<int> b(N+1,0);
  /*for(int i=1;i<N+1;i++){
    for(int j=1;j<N+1;j++){
      if(a.at(j)==i){
        b.at(i)=j;
      }
    }
  }*/
  for(int i=1;i<N+1;i++){
    b.at(a.at(i))=i;
  }
  for(int i=1;i<N+1;i++){
    cout<<b.at(i);
    if(i!=N){
    cout<<" ";
     }
  }
  cout<<endl;
}


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

int main(void) {

    int X, Y;
    cin >> X >> Y;

    int Crane = 2 * X - 0.5 * Y;
    int Turtle = - 1 * X + 0.5 * Y;

    if (Crane + Turtle == X && Crane >= 0 && Turtle >= 0) cout << "Yes";
    else cout << "No";

    return 0;

}

Measured memory_bytes: 3100
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;



int main() {
	string S;
	cin >> S;

	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

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

using namespace std;

int main()
{
    int a, b, t;
    scanf("%d %d %d",&a, &b, &t);
    int res = 0, i = 1;;
        t += 0.5;
         while((i * a) <= t){
            res += b;
            i++;
         }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int N;
  cin >> N;
  //vector<ll> A(N);
  vector<ll> idxp(N), idxm(N);
  map<ll, int> cnt;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    idxp[i] = i + 1 + a;
    idxm[i] = i + 1 - a;
    cnt[idxm[i]]++;
  }
  ll ans = 0;
  for (int i = 0; i < N;i++){
    cnt[idxm[i]]--;
    ans += cnt[idxp[i]];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 29016
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        long x=sc.nextLong();
        long d[] = new long[n+1];

        for(int i=0; i<n; i++) {
            d[i] = sc.nextInt();
        }
        for(int i=n-1; 0<=i; i--) {
            d[i] += d[i+1];
        }
        long e=5,s,ans=Long.MAX_VALUE;
        for(int i=1; i<=n; i++) {
            s=x*(n+i);
            for (int t=n-i,u=0; 0<=t; u++,t-=i,e+=2) {
                if(u<2)e=5;
                s+=e*(d[t]-d[t+i]);
                if(ans<s)break;
                if(t-i<0 && 0<t){
                    s+=(u>=1 ? e+2:e)*(d[0]-d[t]);
                    break;
                }
            }
            ans=min(ans,s);
        }
        out.println(ans);
        out.flush();
    }


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

    static long gcd(long a, long b){
        if(min(a,b) == 0)return max(a,b);
        return gcd(max(a,b) % min(a,b),min(a,b));
    }
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 49284
import java.util.*;

public class Main {
	Scanner sc;
	
	int max;
	int n;
	int[] d;
	boolean[] done;
	void dfs(int depth) {
		if( depth >= n + 1 ) {
			return;
		}
		if( done[depth] ) {
			return;
		}
		done[depth] = true;
		
		for( int i = 1; i <= max; ++i ) {
			int ni = Math.min(depth + i, n + 1);
			ni = Math.max(Math.min(ni + d[ni], n + 1), 0);
			
			dfs(ni);
		}
		
		return;
	}
	
	boolean res;
	void search(int depth) {
		if( depth >= n + 1 ) {
			res = false;
			return;
		}
		if( done[depth] ) {
			return;
		}
		done[depth] = true;
		
		for( int i = 1; i <= max; ++i ) {
			int ni = Math.min(depth + i, n + 1);
			ni = Math.max(Math.min(ni + d[ni], n + 1), 0);
			
			search(ni);
		}
	}
	
	void solve() {
		sc = new Scanner(System.in);
		
		while(true) {
			max = sc.nextInt();
			
			if( max == 0 ) break;
			
			n = sc.nextInt();
			d = new int[n + 2];
			
			d[0] = 0;
			for( int i = 1; i <= n; ++i ) {
				d[i] = sc.nextInt();
			}
			d[n+1] = 0;
			
			done = new boolean[n + 2];
			dfs(0);
			
			ArrayList<Integer> list = new ArrayList<Integer>();
			for( int i = 0; i <= n; ++i ) {
				if(done[i]) list.add(i);
			}
			
			boolean ans = false;
			for( int i : list ) {
				res = true;
				done = new boolean[n + 2];
				search(i);
				
				ans |= res;
			}
			
			System.out.println(ans ? "NG" : "OK");
		}
		
		sc.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void debug(Object... os) {
		System.out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 52636
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{

    int N,M,X,Y,x,y,mx,my;

    cin>>N>>M>>X>>Y;

    mx=X;
    my=Y;


    for(int i=1;i<=N;i++){
        cin>>x;
        mx=max(mx,x);
    }

    for(int i=1;i<=M;i++){
        cin>>y;
        my=min(my,y);
    }

    if(mx<my){
        cout << "No War" <<endl;
    }else{
        cout << "War" <<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import math

def comb(n, k):
    k = min(k, n - k)
    ans = 1
    for i in range(n, n - k, -1):
        ans *= i
    for i in range(1, k + 1):
        ans //= i 
    return ans

n = int(input())

if n == 22 :
    print("Christmas Eve Eve Eve")
elif n == 23 :
    print("Christmas Eve Eve")
elif n == 24 :
    print("Christmas Eve")
elif n == 25 :
    print("Christmas")


Measured memory_bytes: 3060
#include <stdio.h>
int main(){
    int n,a[100],temp,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
        for(int i=0;i<n-1;i++){
        for(int j=n-1;j>i;j--){
            if(a[j]<a[j-1]){
                temp=a[j];
                a[j]=a[j-1];
                a[j-1]=temp;
                ans++;
            }
        }
    }
    printf("%d",a[0]);
    for(int i=1;i<n;i++)printf(" %d",a[i]);
    printf("\n%d\n",ans);
}

Measured memory_bytes: 2732
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
 
typedef long long lint;
 
using namespace std;
 
int main(){
  int N,M;
  cin>>N;
  int T[N];
  REP(i,N)cin>>T[i];
  cin>>M;
  int P[M];
  int X[M];
  REP(i,M)cin>>P[i]>>X[i];
  int sum=0;
  REP(i,N)sum+=T[i];
  REP(i,M){
    cout<<sum-T[P[i]-1]+X[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

	int main(void) {
		int N;
		scanf("%d", &N);
		int T[100];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d", &T[i]);
			sum += T[i];
		}

		int M;
		scanf("%d", &M);
		int P[100], X[100];
		for (int i = 0; i < M; i++) {
			scanf("%d%d", &P[i], &X[i]);
		}
		int a;

		for (int i = 0; i < M; i++) {
			a = P[i];
			printf("%d\n", sum - T[a-1] + X[i]);
		}



		return 0;
	}


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



int main() {
  int N;
  cin >> N;
  
  int64_t sum=0;
  for(int i=1; i<=N; i++){
    if(i%3!=0 && i%5!=0){
      sum += i;
    }
  }
  cout << sum << endl;
  
}


Measured memory_bytes: 3636
# coding: utf-8

from collections import Counter

# 入力
n = input()
a = list(map(int, input().split()))

# 各要素数カウント
counter = Counter(a)

# メイン処理
count = 0
for k, v in counter.most_common():
    if k > v:
        count += v
    elif k < v:
        count += v - k

# 出力
print(count)


Measured memory_bytes: 21232
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'


template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char c) {
  return string(1,c);
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (int i = int(N)-1; i >= 0; --i) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef COMPETITIVE_PROGRAMMING_LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) if(0){}
#endif

 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  ll ans = 0;

  for (int i = 0; i < K; ++i) {
    int prev = -1;
    for (int j = i; j < N; j += K) {
      if (T[j] == 'r') {
        if (prev != 'p') {
          ans += P;
          prev = 'p';
        } else {
          prev = -1;
        }
      } else if (T[j] == 's') {
        if (prev != 'r') {
          ans += R;
          prev = 'r';
        } else {
          prev = -1;
        }
      } else {
        assert(T[j] == 'p');
        if (prev != 's') {
          ans += S;
          prev = 's';
        } else {
          prev = -1;
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
    int a,p;
    cin >> a >> p;
    p += a*3;
    if (p%2 == 0){
        cout << p/2;
    }
    if (p%2 == 1){
        cout << (p-1)/2;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		StringBuffer cards = new StringBuffer(sc.next());
		
		for (; !cards.toString().equals("-"); cards = new StringBuffer(sc.next())) {
			int m = sc.nextInt();

			int sum = 0;
			for (int i = 0; i < m; i++) {
				sum += sc.nextInt();
			}
			sum = sum % cards.length();
			cards = cards.append(cards.substring(0, sum));
			cards.delete(0, sum);

			System.out.println(cards);
		}
		
		sc.close();
	}
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);	
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		vi v(n);
		REP(i, n) {
			string s;
			cin >> s;
			if (s[0] != 'x')v[i] = stoi(s);
			else v[i] = 2 * INF;
		}
		int flag = 1;
		REP(i, n - 1) {
			if (flag) {
				if (v[i] == 2 * INF&&v[i + 1] == 2 * INF) {
					cout << "none" << endl;
					flag = 0;
				}
				else if (v[i] != 2 * INF&&v[i + 1] != 2 * INF) {
					if (i % 2 == 0 && v[i] >= v[i + 1]) {
						cout << "none" << endl;
						flag = 0;
					}
					else if (i % 2 == 1 && v[i] <= v[i + 1]) {
						cout << "none" << endl;
						flag = 0;
					}
				}
			}
		}
		if (flag) {
			int u = INF+1, l = -INF-1;
			REP(i, n) {
				if (v[i] == 2 * INF) {
					if (i % 2 == 0) {
						if (i != 0)u = min(u, v[i - 1] - 1);
						if (i != n - 1)u = min(u, v[i + 1] - 1);
					}
					else {
						l = max(l, v[i - 1] + 1);
						if (i != n - 1)l = max(l, v[i + 1] + 1);
					}
				}
			}
			if (u == l)cout << u << endl;
			else if (l < u)cout << "ambiguous" << endl;
			else cout << "none" << endl;
		}
	}
	return 0;
}

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

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

int main()
{
    int N, K;
    cin>>N>>K;
    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;

    long long M = 1000000007LL;
    vector<long long> F(N+1);
    F[0] = 1;
    for (int i=1; i<=N; i++)
        F[i] = F[i-1]*i%M;

    auto C = [&](long long a, long long b)
    {
        return F[a]*powmod(F[b], M-2, M)%M*powmod(F[a-b], M-2, M)%M;
    };

    sort(A.begin(), A.end());
    long long ans = 0;
    for (int i=0; i<N; i++)
    {
        if (i>=K-1)
            ans += A[i]*C(i, K-1)%M;
        if (N-i-1>=K-1)
            ans -= A[i]*C(N-i-1, K-1)%M;
        ans = (ans+M)%M;
    }
    cout<<ans<<endl;
}


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

#define D(X,F) \
  ( ( (X) / (F) ) % 10 )
#define INT(X) \
  ( *( (const int *)(X) ) )

static int
lcmp (
  const void *a,
  const void *b
  )
{
  return ( INT( a ) - INT( b ) );
}

static int
gcmp (
  const void *a,
  const void *b
  )
{
  return ( INT( b ) - INT( a ) );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  for ( ; ; )
  {
    int res;
    int n;

    scanf ( "%d", &n );
    if ( n == 0 )
      break ;

    if ( D( n, 1 ) == D( n, 10 )
      && D( n, 1 ) == D( n, 100 )
      && D( n, 1 ) == D( n, 1000 ) )
    {
      puts ( "NA" );
      continue ;
    }
 
    for ( res = 0; ; ++res )
    {
      int la[ 4 ], ga[ 4 ];

      if ( n == 6174 )
        break ;

      la[ 0 ] = ga[ 0 ] = D( n, 1000 );
      la[ 1 ] = ga[ 1 ] = D( n, 100 );
      la[ 2 ] = ga[ 2 ] = D( n, 10 );
      la[ 3 ] = ga[ 3 ] = D( n, 1 );
      qsort ( la, 4, sizeof ( int ), lcmp );
      qsort ( ga, 4, sizeof ( int ), gcmp );

      n = 1000 * ga[ 0 ] + 100 * ga[ 1 ] + 10 * ga[ 2 ] + ga[ 3 ]
        - 1000 * la[ 0 ] - 100 * la[ 1 ] - 10 * la[ 2 ] - la[ 3 ];
    }
    printf ( "%d\n", res );
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 612
s = input()
inp = list(s)

L_o = ['R','U','D']
L_e = ['L','U','D']
c = 0
l = len(s)

for i in range(l): #文字数だけループ
    if i%2 ==0 : #偶数
        for j in range(l):
            if 'L' in inp[i]: #Rを検索
                print('No')
                exit() 
    elif i%2 ==1: #奇数
        for k in range(3):
            if 'R' in inp[i]:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
n,x = map(int,input().split())

s = list(map(int,input().split()))

ans = 1

s.sort()

if sum(s)==x:
    print(n)
elif sum(s)<x:
    print(n-1)
else:
    if s[0]>x:
        print(0)
    else:
        for i in range(len(s)):
            if sum(s[:i]) <= x < sum(s[:i+1]):
                print(i)

Measured memory_bytes: 9160
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b, c) {
    // ????????????????????????
    var result = [a, b, c].sort(function(a, b) {
      return a - b;
    })
    console.log(result.join(' '));

  }(params[0], params[1], params[2]));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15500
/**
 *    author:  tourist
 *    created: 13.06.2020 15:34:38       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n + 1);
  while (k--) {
    for (int i = 0; i <= n; i++) {
      b[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      int from = max(i - a[i], 0);
      int to = min(i + a[i], n - 1);
      b[from] += 1;
      b[to + 1] -= 1;
    }
    bool changed = false;
    for (int i = 0; i < n; i++) {
      changed |= (a[i] != b[i]);
      a[i] = b[i];
      b[i + 1] += b[i];
    }
    if (!changed) {
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << a[i];
  }
  cout << '\n';
  return 0;
}


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

#define int long long

signed main()
{
    int i=0, j=0, ans=0;
    
    int n, m, a[100];
    double cnt=0;
    cin>>n>>m;
    for(i;i<n;i++){
        cin>>a[i];
        cnt+=a[i];
    }
    
    sort(a, a+n, greater<int>());

    if(a[m-1]<cnt/4/m)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque
n = int(stdin.readline())
d = [-1] * (n + 1)
def bfs(G):
    d[1] = 0
    dq = deque([1])
    while len(dq) > 0:
        v = dq.popleft()
        for c in G[v]:
            if d[c] < 0:
                d[c] = d[v] + 1
                dq.append(c)
    for i, x in enumerate(d[1:], start=1):
        print(i, x)
G = [0]
for i in range(n):
    G.append(list(map(int, stdin.readline().split()[2:])))
bfs(G)

Measured memory_bytes: 8056
n,m,x = map(int, input().split())

N=[]
NI=[]
for i in range(n) :
    N = list(map(str, input().split()))
    NI.append(N)

ans=-1

for i in range(1<<n) :
    A=[0]*(m+1)
    for j in range(n) :
        # print(NI[j])
        if (1<<j)&i :
            A=[x+int(y) for(x,y)in zip(A,NI[j])]
    # print(A)
    a = A[0]
    del A[0]
    if min(A)<x :
        a=-1
    elif ans==-1:
        ans = a
    elif ans>a :
        ans = a
print(ans)


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

int main(){
    string s;
    int sum = 0;
    cin >> s;
    rep(i, s.length()){
        sum += (int)s[i] -48;
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

LL a[300000],l[100001],r[100001];
int n;

int main(){
  cin>>n;
  REP(i,3*n)
    cin>>a[i];

  LL su=accumulate(a,a+n,(LL)0);
  priority_queue<LL,vector<LL>,greater<LL>> q;
  REP(i,n)
    q.push(a[i]);
  REP(i,n+1){
    l[i]=su;
    q.push(a[n+i]);
    su+=a[n+i]-q.top();
    q.pop();
  }

  su=accumulate(a+2*n,a+3*n,(LL)0);
  priority_queue<LL> q2;
  REP(i,n)
    q2.push(a[2*n+i]);
  REP(i,n+1){
    r[n-i]=su;
    q2.push(a[2*n-1-i]);
    su+=a[2*n-1-i]-q2.top();
    q2.pop();
  }
  
  LL ret=-1e18;
  REP(i,n+1){
    //cerr<<i<<" "<<l[i]<<" "<<r[i]<<endl;
    ret=max(ret,l[i]-r[i]);
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 5876
N = int(input())
S = input()
A = [1 if S[0]=='E' else 0]
for i in range(1,N):
  A.append(1 if S[i]=='E' else 0)
  A[i] += A[i-1]
ans = min(N-1-A[N-2], A[N-1]-A[0])
for i in range(1,N):
  ans = min(ans, i-A[i-1]+A[N-1]-A[i])
print(ans)

Measured memory_bytes: 15520
#include<stdio.h>

int main(void){
    int N,X,T,K;
    scanf("%d %d %d",&N,&X,&T);
    if(N%X==0){
        K=(N/X)*T;
        
    }else{
        K=(N/X+1)*T;
    }
    printf("%d",K);
}

Measured memory_bytes: 1700
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[101010], b[101010];
LL num;
int ans = 0;
vector<int>v;
int main(){
    INIT;
    cin >> n;
    REP(i, n)cin >> a[i];
    REP(i, n)cin >> b[i];
    REP(i, n){
        if(a[i] < b[i]){
            num += b[i] - a[i];
            ans++;
        }else if(a[i] > b[i]){
            v.emplace_back(a[i] - b[i]);
        }
    }
    sort(ALL(v));
    reverse(ALL(v));
    if(num == 0){
        cout << 0 << endl;
        return 0;
    }
    REP(i, (int)v.size()){
        ans++;
        num -= v[i];
        if(num <= 0){
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 1408
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
const bool DEBUG = 1;
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tuple<ll, ll> P;
typedef tuple<ll, ll, ll> P3;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<P> VP;
typedef vector<string> VS;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end())
#define PB push_back
#define EACH(i,c) REP(i,(c).size())
#define REACH(i,c) RREP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

#define BR cout<<"\n"

#define dump(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)<<"\n"
#define dump2(x,y) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n"
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<<"] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n"\
  <<" , "<<#z<<"="<<(z)<<"\n"

#define SAY(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<(x)<<"\n"

#define YES(x) cout<<((x)?"YES":"NO")<<"\n"
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n"
#define yes(x) cout<<((x)?"yes":"no")<<"\n"

inline int omajinai_int_in(){omajinai;int n;cin>>n;return n;}
inline ll omajinai_ll_in(){omajinai;ll n;cin>>n;return n;}
inline string omajinai_string_in(){omajinai;string n;cin>>n;return n;}
inline int int_in(){int n;cin>>n;return n;}
inline ll ll_in(){ll n;cin>>n;return n;}
inline string string_in(){string n;cin>>n;return n;}
#define oini omajinai_int_in()
#define oinl omajinai_ll_in()
#define oins omajinai_string_in()
#define ini int_in()
#define inl ll_in()
#define ins string_in()

#define isInside(x,y) (0<=(x)&&(x)<w&&0<=(y)&&(y)<h)

#define fi(x) (get<0>(x))
#define se(x) (get<1>(x))
#define th(x) (get<2>(x))
#define fo(x) (get<3>(x))

template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; EACH(i, v) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

ll ans;

int c[500],a[500],b[500];
int main() {
	//#####//
	int n=ini;
  REP(i,n-1)c[i]=ini,a[i]=ini,b[i]=ini;
  REP(i, n-1){
    ll s=0;
    s+=c[i]+a[i];
    FOR(j,i+1,n-1){
      if(s>a[j]){
        s=(ll)ceil((double)s/b[j])*b[j];
        s+=c[j];
      }else{
    	  	  s=a[j];
    	  	  s+=c[j];
      }
    }
    cout << s<<endl;
  }
  cout << 0 <<endl;
}

//


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
//#include<ctime>
//#include<cmath>
//#include<queue>

using namespace std;
#define LL long long

inline int read(){
	int x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int INF = 2147483600;
const int MAXN = 100010;

char str[MAXN+1]; int N;
int cnt=1;

inline void dfs(int k,int t){
	if(t==N) return ;
	if(str[t]=='1') cout<<k<<" "<<++cnt<<endl,dfs(cnt,t+1);
	else cout<<k<<" "<<++cnt<<endl,dfs(k,t+1);
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",str+1); N=strlen(str+1);
	if(str[1]!='1'||str[N]!='0'){
		puts("-1"); return 0;
	} int now=1;
	for(int i=1;i<N/2;i++){
		if(str[i]!=str[N-i]) {
			puts("-1"); return 0;
		} 
	}
	if(now==N-1){
		for(int i=1;i<N;i++){
			cout<<i<<" "<<i+1<<endl;
		} return 0;
	}
	dfs(1,1);
	return 0;
}



Measured memory_bytes: 1536
H,W = map(int,input().split())
s = []
black = 0
for i in range(H):
    l = list(input())
    for j in range(W):
        if l[j] == "#":
            black += 1
    s.append(l)
white = H*W-black
from collections import deque
q = deque([(0,0,0)])
s[0][0] = "#"
while q:
    x,y,cnt = q.popleft()
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
        nx,ny = x+dx,y+dy
        if 0<=nx<H and 0<=ny<W and s[nx][ny] != "#":
            if nx == H-1 and ny == W-1:
                print(white-cnt-2)
                exit(0)
            s[nx][ny] = "#"
            q.append((nx,ny,cnt+1))
print(-1)

Measured memory_bytes: 3316