akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long ll;
ll rsum[100005];        // (0...i)の時計回りの摂取カロリーのみの累積和
ll lsum[100005];        // (i...(n+1)(=0))の反時計回りの摂取カロリーのみの累積和
// 上記のものに消費カロリーも考慮したものの最大値を保存
ll max_rsum[100005];
ll max_lsum[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    ll c;
    cin >> n >> c;
    vector<ll> x(n);
    vector<int> v(n);
    ll tmp = 0;
    for(int i = 0; i < n; ++i){
        cin >> x[i] >> v[i];
        rsum[i+1] = rsum[i] + v[i];
        tmp = max(tmp, rsum[i+1] - x[i]);
        max_rsum[i+1] = tmp;
    }
    tmp = 0;
    // rsumとindexを揃える
    for(int i = n; i > 0; --i){
        lsum[i] = lsum[i+1] + v[i-1];
        tmp = max(tmp, lsum[i] - (c - x[i-1]));
        max_lsum[i] = tmp;
    }
    
    ll res = 0;
    res = max(res, *max_element(max_rsum, max_rsum + n + 1));
    res = max(res, *max_element(max_lsum, max_lsum + n + 1));

    for(int i = 1; i <= n; ++i){
        ll temp = rsum[i] - 2 * x[i - 1] + max_lsum[i + 1];
        res = max(res, temp);
        
        temp = lsum[n + 1 - i] - 2 * (c - x[n - i]) + max_rsum[n - i];
        res = max(res, temp);
    }

    cout << res << endl;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (n); ++i)
#define repe(i, n) for (int64_t i = 0; i <= (n); ++i)
#define reps(i, s, n) for (int64_t i = (s); i < (n); ++i)
#define repse(i, s, n) for (int64_t i = (s); i <= (n); ++i)
#define repr(i, n) for (int64_t i = (n); i >= 0; --i)
const int64_t inf = (int64_t)1e18;
const int64_t mod = (int64_t)1e9 + 7;

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

  int64_t N, M; cin >> N >> M;
  vector<pair<int64_t, int64_t>> AB(N);
  rep(i, N) {
    int64_t a, b; cin >> a >> b;
    AB[i] = make_pair(a, b);
  }
  sort(AB.begin(), AB.end());

  int64_t cnt = 0;
  int64_t ans = 0;
  int i = 0;
  rep(i, N) {
    int64_t a, b;
    a = AB[i].first; b = AB[i].second;
    if (cnt + b > M) {
      ans += (M - cnt) * a;
      break;
    } else {
      ans += a * b;
      cnt += b;
    }
    if (cnt == M) break;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdint>

using namespace std;

int main()
{
	int_least32_t x, y;
	cin >> hex >> x;
	cin >> hex >> y;

	if(x == y) {
		cout << "=" << endl;
	}
	else if(x > y) {
		cout << ">" << endl;
	}
	else {
		cout << "<" << endl;
	}
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.*;
import java.math.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] intArray = Arrays.stream(sc.nextLine().split(" ")) 
                        .mapToInt(Integer::parseInt) 
                        .toArray();                       
        int five=0;
        int seven =0;
        int i=0;
        while(i < 3){
            if(intArray[i]==5){
                five++;
            }else if(intArray[i]==7){
                seven++;
            }
            i++;
        }
        
            if(five==2&&seven==1){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
            
            
        
    }
}

Measured memory_bytes: 26700
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

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

ll calc(mat &s, vec &c, vec &ans){
    ll res = 0;
    vec last(26, 0);
    rep(day, N){
        last[ans[day]] = day + 1;
        rep(i, 26){
            if(i == ans[day]){
                res += s[day][i];
            }else{
                res -= c[i] * (day + 1 - last[i]);
            }
        }
    }
    return res;
}

int main() {
    cin>>N;
    vec c(26), last(26, 0), ans(N);
    mat s(N, vec(26)), ans_another(26, vec(1, 0));
    rep(i,26) cin>>c[i];
    rep(i,N) rep(j, 26) cin>>s[i][j];
    ll score = 0;
    rep(day, N){
        vec temp(26, 0);
        rep(i, 26) temp[i] += s[day][i];
        rep(i, 26) temp[i] += c[i] * (day + 1 - last[i]);
        auto ite = max_element(ALL(temp));
        ans[day] = ite - temp.begin();
        ans_another[ans[day]].push_back(day + 1);
        last[ite - temp.begin()] = day + 1;
        rep(i, 26){
            if(i == ans[day]){
                score += s[day][i];
            }else{
                score -= c[i] * (day + 1 - last[i]);
            }
        }
    }
    rep(i,26) ans_another[i].push_back(N + 1);

    mat minus(N + 1, vec(26, 0));
    priority_queue<P, vector<P>, greater<P> > pque;
    rep(i, 26){
        vec &table = ans_another[i];
        int id = 0;
        reps(day, 1, N){
            if(table[id + 1] == day){
                ++id;
            }else{
                ll weight = s[day - 1][i], len = table[id + 1] - table[id] - 1;
                ll wh = day - table[id];
                weight += c[i] * ((len * (len + 1) / 2) - (wh * (wh - 1) / 2 + (len - wh) * (len - wh + 1) / 2));
                pque.emplace(weight, day * 26 + i);
            }
        }
    }
    rep(check, 300){
        P p = pque.top();
        pque.pop();
        ll day = p.se / 26, i = p.se % 26;
        --day;
        ll old = ans[day];
        ans[day] = i;
        if(!chmax(score, calc(s, c, ans))){
            ans[day] = old;
        }
    }

    rep(i,N) cout<<ans[i] + 1<<'\n';
}


Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
mt19937 _mt(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l,ll r){return uniform_int_distribution<ll>(l,r-1)(_mt);}
/*
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;
*/
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,in;
	cin>>n>>m;
	vl v(m);
	int h[]={2,5,5,4,5,6,3,7,6};
	vector<pair<vi,int>> dp(10010,pair<vi,int>(vi(9,0),0));
	rep(i,m){
		cin>>v[i];
	}
	sort(all(v));
	rep(k,m){
		in=v[k];
		range(i,1,10001){
			int t=(i-h[in-1]);
			if(t>=0){
				if(t!=0&&dp[t].sc==0)continue;
				else{
					if(dp[t].sc>=dp[i].sc-1){
						dp[i].sc=dp[t].sc+1;
						rep(j,9){
							dp[i].fs[j]=dp[t].fs[j];
						}
						dp[i].fs[in-1]++;
					}
				}
			}
		}
	}
	rrep(i,9){
		rep(j,dp[n].fs[i])cout<<i+1;
	}
	cout<<endl;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <ctype.h>
#include <string.h>


int main() {
	char c[1200];
	int i,len;
	scanf("%[^\n]" , c);

	len = sizeof(c);

	for (i = 0; i < len ;i++) {
	if (isupper(c[i])) {
		c[i] = tolower(c[i]);
		} else {
		c[i] = toupper(c[i]);
		}
	}

	printf("%s\n" ,c);

	return 0;
}


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

int main()
{
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;

  vector<int> s(S.size());
  for (int i = 0; i < S.size(); i++){
    s.at(i) = S.at(i);
  }
  
  for (int i = 0; i < s.size(); i++){
    if (i == A && s.at(i) != 45){
      cout << "No" << endl;
      return 0;
    } else if (i == A && s.at(i) == 45) continue;
    if (s.at(i) < 48 || s.at(i) > 57){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define rc(s) return cout<<s,0
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
long long n;
int main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    cout << (n-1)*(n)/2;
}


Measured memory_bytes: 256
# 2 * 5 = 10 なので、
# Nまでの偶数を順番に素因数分解して、そこで素因数として登場する 5 の合計が答えになる
# 2 はたくさんあるので、気にしなくていい。
# 素因数に 5 が出てくるのは 2+2+2+2+2 = 2*5 = 10 の時なので、偶数5回ごとに 5 は出てくる。
# さらに、10*5 = 50 の時には 5 が2回出てくる。
# なので、N を 5 で割って（切り捨て）、さらにその数を 5 で割って、と繰り返して合計を求める
N=int(input())
ans = 0
if N%2 == 1:
    print(0)
else:
    N //= 2
    while N > 0:
        N //= 5
        ans += N
    print(ans)



Measured memory_bytes: 2940
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String u, nl = System.getProperty("line.separator");
		StringBuilder 
			p = new StringBuilder(1000),
		  	d = new StringBuilder("."),
		  	s = new StringBuilder("#"),
		  	k = new StringBuilder(50);
		Scanner r = new Scanner(System.in);
		int h, w, ww = 0;
		while (4 > ww++) {
			d.append(d);
			s.append(s);
		}
		ww = d.length();
		while (0 != ((h = r.nextInt()) | (w = r.nextInt()))) {
			while (w > ww) {
				d.append(d);
				s.append(s);
				ww += ww;
			}
			p.append(u = s.substring(0, w)).append(nl);
			k.setLength(0);
			k.append(d.substring(0, w)).append(nl)
			.replace(0, 1, "#").replace(w - 1, w, "#");
			while (2 < h--) {
				p.append(k);
			}
			p.append(u).append(nl).append(nl);
		}
		System.out.print(p);
	}
}

Measured memory_bytes: 18392
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n, k; cin >> n >> k;

	int64_t r = (n % k);

	cout << min(r, k - r) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int L, n;
    vector<int> u, v, w;
    cin >> L;
    for(n = 1; (1<<n) <= L; n++);
    for(int i = 1; i < n; i++){
        u.push_back(i);
        u.push_back(i);
        v.push_back(i+1);
        v.push_back(i+1);
        w.push_back(0);
        w.push_back(1<<(i-1));
        if(((L>>(i-1))&1) == 1){
            u.push_back(i);
            v.push_back(n);
            w.push_back(L-(L%(1<<i)));
        }
    }
    int m = u.size();
    cout << n << " " << m << endl;
    for(int i = 0; i < m; i++){
        cout << u[i] << " " << v[i] << " " << w[i] << endl;
    }
}


Measured memory_bytes: 256
G=[]
def g(x):
  global G
  G=[]
  for i in range(51):
    G.append([])
    for j in range(1,i+1):
      if x&(1<<j):
        G[i].append((i%j,0))

from heapq import *
D=[0]*51
INF=1000
def ijk(s):
  for i in range(len(G)):
    D[i]=INF
  D[s]=0
  Q=[]
  heapify(Q)
  heappush(Q,(0,s))
  p,v,e=0,0,0
  while len(Q):
    p=heappop(Q)
    v=p[1]
    if D[v]<p[0]:
      continue
    for i in range(len(G[v])):
      e=G[v][i]
      if D[e[0]]>D[v]+e[1]:
        D[e[0]]=D[v]+e[1]
        heappush(Q,(D[e[0]],e[0]))

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
def j(x):
  g(x)
  for i in range(N):
    ijk(A[i])
    if D[B[i]]>=INF:
      return 0
  return 1

X=-1
for i in range(1,52):
  if j((1<<i)-1):
    X=(1<<i)-1
    break
if X==-1:
  print(-1)
  exit()
for i in range(51,-1,-1):
  if X&(1<<i):
    if j(X^(1<<i)):
      X^=(1<<i)
print(X)

Measured memory_bytes: 76708
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int a;
string s;

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

  cin >> a;
  cin >> s;
  string ans = a>=3200?s:"red";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
typedef unsigned long long int ull;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a>>b;
  cout <<(3*a+b)/2;
}

Measured memory_bytes: 3656
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto H = RD;
	auto W = RD;
	auto K = RD;

	auto dp = new long[][](H+1, W);
	dp[0][0] = 1;
	foreach (y; 0..H)
	{
		foreach (i; 0..2^^(W-1))
		{
			if (W == 1)
			{
				dp[y+1][0].moda(dp[y][0]);
				continue;
			}
			auto bit = new bool[](W-1);
			foreach (j; 0..bit.length)
			{
				if ((1L << j) & i)
					bit[j] = true;
			}
			bool ok = true;
			foreach (j; 1..bit.length)
			{
				if (bit[j-1] && bit[j])
				{
					ok = false;
					break;
				}
			}
			if (!ok) continue;
			foreach (j; 0..bit.length)
			{
				if (bit[j])
				{
					dp[y+1][j+1].moda(dp[y][j]);
					dp[y+1][j].moda(dp[y][j+1]);
				}
				else
				{
					if (j == 0)
						dp[y+1][j].moda(dp[y][j]);
					else if (!bit[j-1])
						dp[y+1][j].moda(dp[y][j]);
					if (j == bit.length-1)
						dp[y+1][W-1].moda(dp[y][W-1]);
				}
			}
		}
	}
	debug writeln(dp);
	writeln(dp[H][K-1]);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  if(a>=500){
    a%=500;
    if(a<=b){
      cout<<"Yes\n";
    }else{
      cout<<"No\n";
    }
  }else{
    if(a<=b){
      cout<<"Yes\n";
    }else{
      cout<<"No\n";
    }
  }
}

Measured memory_bytes: 256
x1,y1,x2,y2=map(int,input().split())

a_y=(y2-y1)
a_x=(x2-x1)

y3=y2+a_x
x3=x2-a_y
x4=x3-a_x
y4=y3-a_y

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
/*
    ZI0N
*/

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

//VARS
#define int               long long
#define ld                long double
#define mod1              1000000007
#define mod2              998244353
#define pi           `    3.14159265358979323846
#define hs                100006

#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define endl              "\n"

//INPUT
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define repe(i,a,b)       for(int i=a;i<=b;i++)
#define bac(i,a,b)        for(int i=a;i>b;i--)
#define bace(i,a,b)       for(int i=a;i>=b;i--)

//FAST
#define ios               ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//FUNCTIONS
#define DECIMAL(n)        std::cout << std::fixed << std::setprecision(n)
#define SORT(v)           sort(all(v))
#define DSORT(v)          sort(all(v),greater<int>())
#define REVERSE(v)        reverse(ALL(v))
#define GCD(m,n)          __gcd(m,n)
#define LCM(m,n)          m*(n/GCD(m,n))
#define init(x,a)         memset(x,a,sizeof(x))
#define trav(a, x)        for(auto& a : x)
#define display(x)        trav(a,x) cout<<a<<" ";cout<<endl

void solve(){
    string s;
    cin>>s;int n=s.size();
    vc<int> v(n),r,l;
    int res[n] = {0};
    rep(i,0,n){
        if(s[i]=='R')
            r.pb(i);
        else
            l.pb(i);
    }
    vc<int>::iterator it;
    rep(i,0,n){
        if(s[i]=='R'){
            it=upper_bound(all(l),i);
            int dist=*it - i - 1;
            int cal = (2-dist%2)%2;
            if(cal==1)
                res[dist+i+1]++;
            else
                res[i+dist]++;
        }
        else if(s[i]=='L'){
            it=lower_bound(all(r),i) - 1;
            int dist=i - (*it) - 1;
            int cal = (2-dist%2)%2;
            if(cal==1)
                res[i-1-dist]++;
            else
                res[i-dist]++;
        }
}
    display(res);

}


signed main(){
    ios
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
	int b=0,a,c,d;
	cin>>a;
	for(int i=1;1;i++){
		b+=i;
		if(b==a){
			for(int j=1;j<=i;j++)
				cout<<j<<endl;
			break;
		}
		if(b>a){
			for(int j=1;j<=i;j++){
				if(j!=b-a)
				cout<<j<<endl;
			}
			break;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std ;
long long n ,m ,a[100000]={} ,sum=0 ,tempt ;
priority_queue <long long> pq ;
int main()
	{
	cin>>n>>m ;
	for(int i=0 ;i<n ;i++)
		{
		cin>>tempt ;
		pq.push(tempt) ;
		}
	while(m--)
		{
		tempt=pq.top() ;
		tempt=double(tempt)/2 ;
		pq.pop() ;
		pq.push(tempt) ;
		}
	while(n--)
		{
		sum+=round(pq.top()) ;
		pq.pop() ;
		}
	cout<<sum<<endl ;
	}

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

int main() {
    vector<int> tasks;
    
    for (int i = 0; i < 3; i ++) {
        int newTask; cin >> newTask;
        tasks.push_back(newTask);
    }
    sort(tasks.begin(), tasks.end());
    int max = tasks.back();
    int min = tasks.front();

    cout << max - min << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n, t;
vector<int> a;
int p, ng;
int sum;
int ans;

signed main() {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> t; a.push_back(t);
        if (t > 0) p += t;
        else if (t < 0) ng += t;
    }
    if (p == 0) {
        sort(a.begin(), a.end(), greater<int>());
        cout << -ng + 2*a.front() << endl;

        sum = a.front();
        for (int i=1;i<n;i++) {
            cout << sum << " " << a[i] << endl;
            sum -= a[i];
        }
    }
    else if (ng == 0) {
        sort(a.begin(), a.end());
        cout << p - 2*a.front() << endl;

        sum = a.front();
        for (int i=1;i<n-1;i++) {
            cout << sum << " " << a[i] << endl;
            sum -= a[i];
        }
        cout << a[n-1] << " " << sum << endl;
    }
    else {
        cout << p - ng << endl;

        sort(a.begin(), a.end());
        sum = a.back(); a.pop_back();
        for (int i=n-2;i>=0;i--) {
            if (a[i] > 0) {
                cout << a[0] << " " << a[i] << endl;
                a[0] -= a[i];
                a.pop_back();
            }
            else break;
        }
        for (auto& it: a) {
            cout << sum << " " << it << endl;
            sum -= it;
        }
    }
}


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

int main()
{
    int n,a[100005],mx=0,cnt=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<n;i++){
       if(a[i-1]>=a[i]){
         cnt++;
       }else{
         if(cnt>mx){
            mx=cnt;
         }
         cnt=0;
       }
    }
    if(cnt>mx){
            mx=cnt;
    }
    printf("%d\n",mx);

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n){
    Int res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
    return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
Int extgcd(Int a, Int b, Int &x, Int &y) {
    Int g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

Int a[105];

int main(){
    cin.tie(0);

    int N;
    cin >> N;
    int K;
    cin >> K;
    int ans = 0;
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a, a+N);
    for (int i = 0; i < N-1; i++){
        if (K >= a[i]){
            K -= a[i];
            ans++;
        }
    }
    if (a[N-1] == K) ans++;

    cout << ans << endl;

    
    return 0;
} 


Measured memory_bytes: 888
n,m,k=map(int,input().split())
ans=0
mod=998244353
c=1
for i in range(k+1):
    ans+=c*m*pow(m-1,n-i-1,mod)
    ans%=mod
    c*=(n-i-1)*pow(i+1,mod-2,mod)
    c%=mod
print(ans)

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    
    ll n,q ;
    
    cin >>n;
    vector<ll> A(n);
    rep(i,n){
        cin >> A[i];
    }
    cin >> q;
    vector<ll> m(q);
    rep(i,q){
        cin >> m[i];
    }
    vector<ll> sums;
    vector<ll> ans(q);
    //rep(num,q){
        rep(i,(1<<n)){
            vector<ll> S;
            rep(j,n){
                if(i&(1<<j)){
                    S.pb(A[j]);
                }
            }
            ll sum = 0;
            rep(j,S.size()){
                sum += S[j];
                //cout << S[j]<<" ";
            }
            //cout << endl;
            sums.pb(sum);
            
        }
    //}
    
    rep(i,q){
        rep(j,sums.size()){
        if(sums[j] == m[i]){
        ans[i] = 1;
    }
        }
    }
    rep(i,q){
        if(ans[i]==1){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    
    
    
    
    return 0;
    

}


Measured memory_bytes: 11244
N = int(input())
As = list(map(int, input().split()))
Bs = [-1] * N
for i in reversed(range(N)):
  a = As[i]
  r = 0
  for j in range(2,N+1):
    j2 = j*(i+1)-1
    if j2 >= N:
      break
    r += Bs[j2]
  b = (r+a)%2
  #print(i, a, r, b)
  Bs[i] = b
#print(Bs)
Cs = []
for i in range(N):
  if Bs[i] == 1:
    Cs.append(str(i+1))
print(len(Cs))
if len(Cs) > 0:
  print(" ".join(Cs))


Measured memory_bytes: 17212
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long N, long long D, std::vector<long long> X, std::vector<long long> Y){
    ll cnt = 0;
    REP(i, N){
        if(X[i]*X[i]+Y[i]*Y[i] <= D*D) cnt++;
    }
    cout<<cnt<<endl;
}
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6416
#include<stdio.h>
#include<string.h>
void Length(void);

char A[1001], B[1001];

int a[1001][1001];

int n, m;

main(){
  int i, q;

  scanf("%d",&q);

  for(i = 0; i < q; i++){

    scanf("%s", A);

    scanf("%s", B);

    Length();

    printf("%d\n", a[m][n]);
  }

  return 0;
}

void Length(void){

  int i, j;

  m = strlen(A);

  n = strlen(B);

  for(i = 1; i <= m; i++){

    a[i][0] = 0;

  }

  for(j = 0; j <= n; j++){

    a[0][j] = 0;

  }

  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){

      if(A[i-1] == B[j-1])
      a[i][j] = a[i - 1][j - 1] + 1;



      else  if(a[i - 1][j] >= a[i][j-1])

	a[i][j] = a[i - 1][j];

      else a[i][j] = a[i][j -1];
    }
  }
}

Measured memory_bytes: 4944
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += (P[i][0])*P[i+1][1] - (P[i][1])*P[i+1][0]
print(abs(s)*0.5)

Measured memory_bytes: 7712
#include<stdio.h>
int main(void){
	char s[3], count=0;
	
	scanf("%s", s);
	
	if(s[0] == '1') count++; 
	if(s[1] == '1') count++; 
	if(s[2] == '1') count++; 
	
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=0,count=-1; cin >> n;
    vector<int> a(n),b(n),c(n-1);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(int i=0;i<n;i++){
        cin >> b.at(i);
    }
    for(int i=0;i<n-1;i++){
        cin >> c.at(i);
    }
    for(int i=0;i<n;i++){
        if(count+1==a.at(i)){
            ans += c.at(a.at(i)-2)+b.at(a.at(i)-1);
        }
        else{
            ans += b.at(a.at(i)-1);
        }
        count=a.at(i);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
/* By : rupesh282
 * link : https://atcoder.jp/contests/dp/tasks/dp_d  
 * */

#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;

const ll mod = 1e9+7;
const ll INF = 1e12;
int n , s;
vector<pair<int,int>>arr;
ll dp[100005][102];

ll recur(int ind , int w){
    if(w < 0)return -INF;
    else if(ind==0 && w>=0)return 0;

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

    ll first = arr[ind].second + recur(ind-1 , w-arr[ind].first);
    ll second = recur(ind - 1, w);
    return dp[ind][w] = max(first , second);
}

void solve(){
   cin>>n>>s; 
   arr.resize(n+1);
   for(int i=1;i<=n;i++)cin>>arr[i].first>>arr[i].second;


   for(int i=1;i<=s;i++){
       for(int j=1;j<=n;j++){
           if(arr[j].first <= i)
               dp[i][j] = max(arr[j].second + dp[i-arr[j].first][j-1] , dp[i][j-1]);
           else dp[i][j] = dp[i][j-1];
       }
   }

   cout<<(dp[s][n])<<endl;
   return;

}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


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

int main(){
  int s;
  cin>>s;
  if((s==0||s>=1300)&&(s%100>12||s%100==0)) cout<<"NA";
  if(s>99&&s<1300&&s%100<13&&s%100!=0) cout<<"AMBIGUOUS";
  if(s>0&&s<1300&&(s%100>12||s%100==0)) cout<<"MMYY";
  if(((s>0&&s<13)||s>=1300)&&s%100<13&&s%100>0) cout<<"YYMM";
}

Measured memory_bytes: 384
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container;

long mod = 1000000007;

long modpow2(long base, long x) {
  base %= mod;
  if(x==1) return base;
  if(x%2 == 0) return modpow2((base*base)%mod, x/2)%mod;
  else return (base*(modpow2((base*base)%mod, x/2)%mod))%mod;
}

long modinv(long a) {
  long b=mod, u=1, v=0;
  while(b>0) {
    long t = a/b;
    a -= t*b;
    long tmp = a;
    a = b;
    b = tmp;
    u -= t*v;
    tmp = u;
    u = v;
    v = tmp;
  }
  u %= mod;
  if(u<0) u += mod;
  return u;
}

long nCk(long n, long k) {
  long result = 1;
  k = min(n-k, k);
  for(int i=0; i<k; i++) {
    result *= n-i;
    result %= mod;
    result *= modinv(i+1);
    result %= mod;
  }
  result %= mod;
  return result;
}

void main() {
  long n, a, b;
  readf("%d %d %d\n", &n, &a, &b);
  long m = (modpow2(2, n) - 1 + mod)%mod;
  if(b<=n) m = (m - nCk(n, b) + mod) % mod;
  if(a<=n) m = (m - nCk(n, a) + mod) % mod;
  writeln(m);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
  int N;
  double sum;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  for (int i = 0; i < N; i++) {
    sum += A.at(i);
    if (i > 0) {
    sum = sum / 2.0;
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
/*
  B - NarrowRectanglesEasy
  Contest 056
  Rakesh Kumar --> 18/08/2020
 */

#include <bits/stdc++.h>

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

    int w = 0, a = 0, b = 0;
    std::cin >> w >> a >> b;
    int d = 0;
    if (a != 0) {
        if (a < b)
            d = b - (a + w);
        else
            d = a - (b + w);
    }
    if (d < 0)
        d = 0;
    std::cout << d << std::endl;

    return 0;
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI l(n);
    int l_sum = 0;
    int l_max = 0;
    REP(i, n) {
        int l;
        cin >> l;
        l_sum += l;
        l_max = max(l_max, l);
    }
    if(l_max * 2 < l_sum) cout << "Yes" << ln;
    else cout << "No" << ln;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>                                             
#include <cmath>                                                
using namespace std;                                            
                                                                
int main() {                                                    
  int x;                                                        
  cin >> x;                                                     
  int XCubic = pow(x,3);                                        
  cout << XCubic << endl;                                       
  return 0;                                                     
}                  

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define mod2 998244353
#define ll lli

using namespace std ;

#define N 200000+5 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main() 
{
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////    

    lli n;
    cin>>n;

    cout<<3*n*n<<endl;

}



Measured memory_bytes: 256
# Aizu Problem ITP_1_4_C: Simple Calculator
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    a, op, b = input().split()
    if op == '?':
        break
    if op == '/':
        op = '//'
    print(eval(a + op + b))

Measured memory_bytes: 7500
#include<stdio.h>

int main(){
  int i, j, n, p, r, x, A[100000], temp;

  scanf("%d", &n);
  if(n <= 100000 && n >= 1){
    for(i = 0; i < n; i++){
      scanf("%d", &A[i]);
      if(A[i] > 100000 || A[i] < 0) break;
    }
    p = 0;
    r = n-1;

    x = A[n-1];
    i = p-1;
    for(j = p; j < r; j++){
      if(A[j] <= x){
	i = i+1;
	temp = A[i];
	A[i] = A[j];
	A[j] = temp;
      }
    }
    temp = A[i+1];
    A[i+1] = A[r];
    A[r] = temp;

    for(j = 0; j < n-1; j++){
      if(j == i+1) printf("[%d] ", A[j]);
      else printf("%d ", A[j]);
    }
    printf("%d\n", A[j]);
  }
  return 0;
}



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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	ll n, x;
	cin >> n >> x;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	ll sum = 0;
	ll ans = 0;
	rep(i,n){
		sum += a[i];
		// 現在の aとsumの和を見て、ハミ出した分だけ操作する。
		int hami = sum - x;
		if(hami > 0){
			ans += hami;
			sum -= hami;
			a[i] -= hami;
		}
		if(i >= 1)sum -= a[i-1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#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 reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int h, w;
    char pic[100][100];
    cin >> h >> w;
    rep(hh, h){
        rep(ww, w){
            cin >> pic[ww][hh];
        }
    }

    rep(hh, h){
        rep(ww, w){
            if(pic[ww][hh] != '#') continue;
            bool flg = false;
            rep(i, 4){
                int deltax = ww + dx[i];
                int deltay = hh + dy[i];
                if(deltax < 0 || w <= deltax || deltay < 0 || h <= deltay) continue;
                if(pic[deltax][deltay] == '#'){
                    flg = true;
                    break;
                }
            }
            if(!flg){
                ans(false);
                return 0;
            }
        }
    }

    ans(true);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int n;
    cin>>n;
    string s;
    cin>>s;
    int max=0;
    int cntL=0;
    int cntR=0;
    for(int i=0;i<n;i++){
        if(s[i]=='('){cntL++;}
        if(s[i]==')'){cntR++;}
        if(max<cntR-cntL){max=cntR-cntL;}
    }
    string ans;
    for(int i=0;i<max;i++){
        ans=ans+'(';
    }
    ans=ans+s;
    for(int i=0;i<max+cntL-cntR;i++){
        ans=ans+')';
    }
    cout<<ans;
    return 0;
}

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

int main(){
    long long n, k;
    cin >> n >> k;

    vector<long long> T(n, 0);

    long long a;
    for(long long i = 0; i < n; i++){
        cin >> a;
        if(T[a-1] == 0){
            T[a-1] = 1;
        }
        else{
            T[a-1] += 1;
        }
    }

    long long kind = 0;

    for(long long i = 0; i < n; i++){
        if(T[i] != 0){
            kind += 1;
        }
    }

    //printf("kind %lld\n", kind);

    if(kind <= k){
        printf("0\n");
        return 0;
    }

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

    long long sum = 0;
    long long count = 0;
    for(long long j = 0; j < n; j++){
        if(T[j] != 0){
            sum += T[j];
            count++;
            if(count == (kind - k)){
                break;
            }
        }
        
    }

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

    return 0;

}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int a = scan.nextInt();
		int ans = 0;

		while (h > a * ++ans);
		System.out.println(ans);

		scan.close();
	}
}

Measured memory_bytes: 25172
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
A = [1]*N

for _ in range(K):
	d = INT()
	a = LIST()
	for i in range(len(a)):
		A[a[i]-1] = 0


print(sum(A))

Measured memory_bytes: 10044
W, H, N = map(int, raw_input().split())

w = [0, W]
h = [0, H]

for i in range(N):
    x, y, a = map(int, raw_input().split())

    if a == 1:
        w[0] = max(x, w[0])
    elif a == 2:
        w[1] = min(x, w[1])
    elif a == 3:
        h[0] = max(y, h[0])
    elif a == 4:
        h[1] = min(y, h[1])

print max(w[1]-w[0], 0) * max(h[1]-h[0], 0)

Measured memory_bytes: 2692
# -- coding: utf-8 --
import math
N, H = map(int, input().split())
th = []
sl_max = 0
for i in range(N):
    s, t = map(int, input().split())
    sl_max = max(sl_max, s)
    th.append(t)
turn = 0
thdec = sorted(th, reverse=True)

for i in range(len(thdec)):
    if thdec[i] >= sl_max:
        H -= thdec[i]
        turn += 1
        if H <= 0:
            break
    else:
        break

if H > 0:
    turn += math.ceil(H / sl_max)

print(turn)

Measured memory_bytes: 8276
#include<stdio.h>

int main(){
  int m,f,r,i,j;

  while(1){
    scanf("%d %d %d",&m,&f,&r);

    if(m==-1&&f==-1&&r==-1)break;

    if(m==-1||f==-1){
      printf("F\n");
      continue;
    }
    int sum=m+f;

    if(sum>=80)printf("A\n");
    else if(sum<80&&sum>=65)printf("B\n");
    else if(sum<65&&sum>=50)printf("C\n");  
    else if(sum<50&&sum>=30){
      if(r>=50)printf("C\n");
      else printf("D\n");
    }
    else if(sum<30)printf("F\n");
  }

  return 0;
}

Measured memory_bytes: 1012
s=input()
n=len(s)
for i in range(0,(n-1)//2):
    if s[i]!=s[n-1-i]:
        print("No")
        break
else:
    for j in range(0,((n-1)//2)//2):
        if s[j]!=s[((n-1)//2)-1-j]:
            print("No")
            break
    else:
        for k in range((n+1)//2,(3*n+1)//4):
            if s[k]!=s[n-1-(k-(n+1)//2)]:
                print("No")
                break
        else:
            print("Yes")

Measured memory_bytes: 3064
#include<stdio.h>
int main(void) {
	char s[101];
	int i;
	char hasi[2];
	int count = 0;
	scanf("%s", s);
	for (i = 1; s[i] != '\0'; i++) {
		count++;
		if (s[i + 1] == '\0') {
			count--;
			hasi[0] = s[0];
			hasi[1] = s[i];
		}
	}

	printf("%c%d%c\n", hasi[0], count, hasi[1]);
	return 0;
}

Measured memory_bytes: 128
#define R(x)if(r>x)r=x;
main(r,D,t,a,b,c,d,e,A,B,C){for(;scanf("%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&A,&B,&C)>7;printf("%d\n",r)){
	r=a*A+b*B+c*C;
	r=
		C>=d?a*A+b*B+e*C:
		(D=d,d-=C,t=B<d?B:d,B-=t,d-=t,t=A<d?A:d,A-=t,d-=t,r>(t=a*A+b*B+e*D))?t:r;
}exit(0);}

Measured memory_bytes: 600