akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn._
object Main extends App {
  val Array(n, m) = readLine.split(" ").map(_.toInt)
  val as = readLine.split(" ").map(i => (i.toLong, 1))
  val bs = Array.fill(m) {
    val b = readLine.split(" ")
    (b(1).toLong, b(0).toInt)
  }
  val all = (as ++ bs).sorted.reverse

  def count(i: Int, cards: Int, sum: Long): Long = {
    val (cost, num) = all(i)
    if (num < cards) count(i + 1, cards - num, sum + cost * num)
    else sum + cost * cards
  }

  println(count(0, n, 0))
}

Measured memory_bytes: 80724
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
vector<vector<Int> > a;
vector<vector<Int> > s;
inline Int rect(Int sy,Int sx,Int ty,Int tx){
  //cout<<sy<<" "<<sx<<":"<<ty<<" "<<tx<<endl;
  return s[ty][tx]+s[sy][sx]-(s[sy][tx]+s[ty][sx]);
}
Int dfs(Int sy,Int sx,Int ty,Int tx,Int k){
  if(k==0) return rect(sy,sx,ty,tx);
  Int res=0;
  if(k==1){
    {
      Int l=sy,r=ty;
      while(l+1<r){
	Int m=(l+r)>>1;
	if(rect(sy,sx, m,tx)<=rect( m,sx,ty,tx)) l=m;
	else r=m;
      }
      res=max(res,min(rect(sy,sx, l,tx),
		      rect( l,sx,ty,tx)));
      res=max(res,min(rect(sy,sx, r,tx),
		      rect( r,sx,ty,tx)));
    }
    {
      Int l=sx,r=tx;
      while(l+1<r){
	Int m=(l+r)>>1;
	if(rect(sy,sx,ty, m)<=rect(sy, m,ty,tx)) l=m;
	else r=m;
      }
      res=max(res,min(rect(sy,sx,ty, l),
		      rect(sy, l,ty,tx)));
      res=max(res,min(rect(sy,sx,ty, r),
		      rect(sy, r,ty,tx)));
    }
    return res;
  }
  for(Int i=sy;i<ty;i++){
    for(Int j=0;j<k;j++)
    res=max(res,min(dfs(sy,sx, i,tx,     j),
		    dfs( i,sx,ty,tx,k-(j+1))));
  }
  for(Int i=sx;i<tx;i++){
    for(Int j=0;j<k;j++)
      res=max(res,min(dfs(sy,sx,ty, i,     j),
		      dfs(sy, i,ty,tx,k-(j+1))));
  }
  return res;
}
signed main(){
  Int h,w,n;
  cin>>h>>w>>n;
  a.resize(h,vector<Int>(w));
  s.resize(h+1,vector<Int>(w+1,0));
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      cin>>a[i][j];


  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      s[i+1][j+1]=s[i+1][j]+a[i][j];

  for(Int j=0;j<=w;j++)
    for(Int i=0;i<h;i++)
      s[i+1][j]+=s[i][j];

  if(0){
    for(Int i=0;i<=h;i++){
      for(Int j=0;j<=w;j++){
	printf("%lld ",s[i][j]);
      }
      cout<<endl;
    }
  }

  Int ans=dfs(0,0,h,w,n-1);
  if(n==4){
    for(int y1=0;y1<=h;y1++){
      for(int y2=y1;y2<=h;y2++){
	for(int x1=0;x1<=w;x1++){
	  for(int x2=x1;x2<=w;x2++){
	    ans=max(ans,
		    min({ rect( 0, 0,y2,x1),
			  rect(y2, 0, h,x2),
			  rect(y1,x2, h, w),
			  rect(0 ,x1,y1, w)}));
	    
	    ans=max(ans,
		    min({ rect( 0, 0,y1,x2),
			  rect(y1, 0, h,x1),
			  rect(y2,x1, h, w),
			  rect( 0,x2,y2, w)}));
	  }
	}
      }
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3440
require 'set'
N,K = gets.split.map(&:to_i)
tds = N.times.map{ gets.split.map(&:to_i) }

# とりあえず価値が最大になるように取ってみると、
# この種類より少ない状態で、最大値になることはないことが分かる
# なのであとは、今まで入っていなかった種類のうち最大のものから順番に置き換えていって、
# その中で、最大だったものを出力するだけ
tds = tds.sort_by{|td| td[1]*-1 }
selected = tds[0, K]
not_selected = tds[K, N]

current_kinds = Set.new(selected.map{|td| td[0] })
current_score = selected.map{|td| td[1] }.inject(:+)
max = current_score + current_kinds.size ** 2

dups_set = Set[]
dups_in_selected = []
selected.each do |td|
  t,d = td
  if dups_set.include? t
    dups_in_selected << td
  else
    dups_set << t
  end
end

if not_selected.nil?
  puts max
  exit
end

not_selected.each do |td|
  t,d = td
  next if current_kinds.include? t
  # remove duplicates, insert new kind
  removed = dups_in_selected.pop
  break if removed.nil?
  current_score -= removed[1]
  current_score += td[1]
  current_kinds << td[0]
  max = [max, current_score + current_kinds.size ** 2].max
end
puts max


Measured memory_bytes: 20176
import math

n=input()
m=math.radians(60)

def kock(n, p1x, p1y, p2x, p2y):

    
    if(n == 0):
        return

    sx=(2*p1x+1*p2x)/3
    sy=(2*p1y+1*p2y)/3
    tx=(1*p1x+2*p2x)/3
    ty=(1*p1y+2*p2y)/3

    ux=(tx-sx)*math.cos(m)-(ty-sy)*math.sin(m)+sx
    uy=(tx-sx)*math.sin(m)+(ty-sy)*math.cos(m)+sy


    kock(n-1, p1x, p1y, sx, sy)
    print round(sx,8),round(sy, 8)
    kock(n-1, sx, sy, ux, uy)
    print round(ux, 8),round(uy, 8)
    kock(n-1, ux, uy, tx, ty)
    print round(tx, 8),round(ty, 8)
    kock(n-1, tx, ty, p2x, p2y)
    

p1x = 0.00000000
p1y = 0.00000000
p2x = 100.00000000
p2y = 0.00000000
 
print p1x, p1y
kock(n, p1x, p1y, p2x, p2y)
print p2x, p2y

Measured memory_bytes: 6652
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(a.begin(),a.end(),greater<int>());
  int sa=0,sb=0;
  rep(i,n){
    if(i%2==0) sa+=a[i];
    else sb+=a[i];
  }
  cout<<sa-sb<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Console.ReadLine();
		var d = Console.ReadLine().Select((c, i) => new { c, i }).ToLookup(_ => _.c, _ => _.i);

		var q =
			from i1 in d.Select(g => g.First())
			from i2 in d.Select(g => g.FirstOrDefault(x => x > i1)).Where(x => x > 0)
			select d.Count(g => g.Last() > i2);
		Console.WriteLine(q.Sum());
	}
}


Measured memory_bytes: 14176
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#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;
#define sp << " " <<
#define enl << 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> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void 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};


const int MAXN = 100010;

class SegmentTree {
public:
    vector<ll> dat;
    ll n;

    SegmentTree(ll nn){
        n = 1;
        while(n < nn) n*=2;
        dat.resize(2*n-1, 0);
    }

    void update(ll k, ll x){
        k += n-1;
        dat[k] = x;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = max(dat[2*k+1], dat[2*k+2]);
        }
    }

    ll getmax(ll a, ll b, ll k, ll l, ll r){
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return dat[k];
        else{
            ll v1 = getmax(a, b, 2*k+1, l, (l+r)/2);
            ll v2 = getmax(a, b, 2*k+2, (l+r)/2, r);
            return max(v1, v2);
        }
    }

    ll get(ll a, ll b){
        //cout << n << endl;
        return getmax(a, b, 0, 0, n);
    }
};

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

    ll n, t, tmpa;
    vector<ll> a;

    cin >> n >> t;
    rep(i, n){
        cin >> tmpa;
        a.push_back(tmpa);
    }

    SegmentTree tree(n);

    rep(i, n){
        tree.update(i, a[i]);
    }

    ll res[100010];
    reps(i, 0, n-2){
        res[i] = tree.get(i+1, n) - a[i];
    }
    res[n-1] = -a[n-1];

    //adebug(res, n);

    ll maxres = 0;
    ll maxcnt = 0;
    rep(i, n){
        if(res[i] > maxres){
            maxres = res[i];
            maxcnt = 1;
        }else if(res[i] == maxres){
            maxcnt++;
        }
    }

    //cout << maxres << endl;
    cout << maxcnt << endl;

    return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;

/*-------------------------------*/

int main(void)
{
  int p, minp, j, minj;
  cin >> p;
  minp = p;

  rep(i, 2){
    cin >> p;
    if (minp > p) minp = p;
  }
  cin >> j;
  cin >> p;
  minj = min(j, p);

  cout << minj + minp - 50 << endl;

  return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
map<int,int>Q,Q1,G;
const int INF=1e9+7;
const int N=1e5+10;
int D[N];
int main()
{
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&D[i]);
	int a,sa=0,sb=0;
	for(int i=0;i<n;i+=2)Q[D[i]]++;
	for(auto k:Q){
		if(k.second>=sa){
			sb=sa;sa=k.second;a=k.first;
		}else if(k.second>sb)sb=k.second;
	}
	//cout<<a<<' '<<sa<<' '<<sb<<'\n';
	for(int i=1;i<n;i+=2)Q1[D[i]]++;
	int ans=INF;
	for(auto k:Q1){
		int u=n/2-k.second;
		if(k.first==a)u+=n/2-sb;
		else u+=n/2-sa;
		ans=min(ans,u);
	}cout<<ans<<'\n';
}


Measured memory_bytes: 5376
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n = int(input())
p = [int(input()) for _ in range(n)]

print(max(p)//2 + sum(p) - max(p))








Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  S = (S[0] == '>' ? '<' : '>') + S + (S[N-1] == '>' ? '<' : '>');
  vector<ll> A(N+1);
  ll cnt = 0;
  rep(i, N+1) {
    if(S[i] == '>' && S[i+1] == '<') {
      // cout << i << endl;
      A[i] = 0;
      RREP(j, i-1, 0) {
        // cout << "RREP" << j << endl;
        if(A[j+1]+1 > A[j]) {
          cnt += A[j+1] + 1 - A[j];
          A[j] = A[j+1] + 1;
        } else {
          break;
        }
        if(S[j] == '<') break;
      }
      REP(j, i+1, N+1) {
        // cout << "REP" << j << endl;
        cnt += A[j-1] + 1 - A[j];
        A[j] = A[j-1] + 1;
        if(S[j+1] == '>') break;
      }
      // rep(i, N+1) cout << A[i] << ' '; cout << endl;
    }
  }
  // rep(i, N+1) cout << A[i] << ' '; cout << endl;
  cout << cnt << endl;
  return 0;
}



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


int main(){
	map<string,string> res;
	res["1 0 0"]="Close";
	res["0 1 0"]="Close";
	res["1 1 0"]="Open";
	res["0 0 1"]="Open";
	res["0 0 0"]="Close";
	string s;
	getline(cin,s);
	cout<<res[s]<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {

   long double a, b;
    cin >> a >> b;
    long double tmp = a * b;
    cout << ll(tmp) << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3736
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int n;

void CountingSort(int *,int *,int);
int main(){
  unsigned int *A, *B;
  int i,k=0;

  scanf("%d",&n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<A[i]){
      k = A[i];
    }
  }

  CountingSort(A,B,k);

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

void CountingSort(int *A,int *B,int k){
  int i,j,C[VMAX+1];

  for(i=0;i<=k;i++){
    C[i] = 0;
  }

  for(j=0;j<n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=k;i++){
    C[i] = C[i]+C[i-1];
  }

  for(j=n-1;j>=0;j--){
    B[C[A[j]]-1] = A[j];
    C[A[j]]--;
  }
}
  

   



Measured memory_bytes: 17464
/**
 * A - Apple Pie
 * https://atcoder.jp/contests/abc128/tasks/abc128_a
 **/
#include<iostream>

using namespace std;

int A, P;

int main() {
    cin >> A >> P;
    int ans;
    ans = (A * 3 + P)/2;
    cout << ans << endl;
}

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

int main(){
    long long N, M, mod=1e9+7;
    cin >> N >> M;
    long long x=1,y=1;
    for (int i=1; i<=N; ++i) {
        x*=i;
        x%=mod;
    }
    for (int j=1; j<=M; ++j) {
        y*=j;
        y%=mod;
    }
    if (N==M) {
        cout << (x*y*2)%mod << endl;
        return 0;
    }
    else if ((N+1)==M || (N-1)==M) {
        cout << (x*y)%mod << endl;
        return 0;
    }
    cout << 0 << endl;
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
long long a, b, c, k, res;
int main() {
    DAU
    cin >> a >> b >> c >> k;
    if (a <= k)
        res = a, k -= a;
    else {
        cout << k;
        PLEC
    }
    k -= b;
    if (k <= 0) {
        cout << res;
        PLEC
    }
    cout << res - min(k, c);
    PLEC
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string a, b = "CODEFESTIVAL2016";
	int count = 0;
	cin >> a;
	for (int i= 0; i < 16; i++) {
		if (a[i] != b[i])count++;
	}
	cout << count << endl;
	int x;
	cin >> x;
}

Measured memory_bytes: 256
a = 1000000007

def solve(m, n):
  if n == 1:
    return m % a
  elif n % 2 == 0:
    return solve((m % a) ** 2, n//2)
  else:
    return  ((m % a) * solve((m % a) ** 2, n//2)) % a

m, n = map(int, input().split())
print(solve(m, n))


Measured memory_bytes: 5604
#include <stdio.h>
#include <float.h>
 
int main(void)
{
    float x[4], y[4], AB, CD;
    int i, j, n;
     
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        for (j = 0; j < 4; j++){
            scanf("%f %f", &x[j], &y[j]);
        }
         
        if (x[1] == x[0]){
            AB = DBL_MAX;
        }
        else {  
            AB = (y[1] - y[0]) / (x[1] - x[0]);
        }
         
        if (x[3] == x[2]){
            CD = DBL_MAX;
        }
        else {
            CD = (y[3] - y[2]) / (x[3] - x[2]);
        }
         
        if (AB == CD){
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
     
    return (0);
}


Measured memory_bytes: 2064
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9


def dfs(cur, a, b, c):
    if (cur == N):
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <stdio.h>
int main (){
	int H1 , H2 , M1 , M2, K,ANS;
	scanf ("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);
	ANS= (H2*60 + M2) - (H1*60 + M1) - K ;
	printf("%d ",ANS);
	return 0;
}

Measured memory_bytes: 1728
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    cout<<'x';
  }
  cout<<endl;




  return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define NMAX 100

int insertionSort(int,int *);

int main(void){
  int i,N,A[NMAX];
  scanf("%d",&N);
  for(i = 0;i < N;i++){
    scanf("%d",&A[i]);
  }
    insertionSort(N,A);

    return 0;
  }

int insertionSort(int N,int *A){

  int i,j,key,k;

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

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




Measured memory_bytes: 2100
//  Created by ZJYelizaveta on 2017年11月18日 星期六 20时56分23秒
//  Copyright (c) 2017年 ZJYelizaveta. All rights reserved.

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

typedef long long ll;
ll a[100];
inline void prepare() {
	a[0] = 2, a[1] = 1;
	for (int i = 2; i <= 86; ++i) a[i] = a[i - 1] + a[i - 2];
}

int main()
{
	prepare();

	int n;
	cin >> n;
	printf("%lld\n", a[n]);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
vector<long long> a;

int main()
{
    cin >> n;
    a.resize(n+2, 0);

    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a[n + 1] - a[n]);

    for (int i = 1; i <= n; i++)
    {
        cout << sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << "\n";
    }
    return 0;
}


Measured memory_bytes: 2048
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }

    int main()
    {
        vector<ll>arr(1001);
        for(ll i=0;i<1001;i++)
        {
            arr[i] = (ll)pow(i,5);
        }
        ll x;cin>>x;
        for(ll i=0;i<1001;i++)
        {
            bool fg = true;
            for(ll j=0;j<1001;j++)
            {
                if(arr[i]-arr[j]==x)
                {
                    cout<<i<<" "<<j<<endl;
                    fg = false;
                    break;
                }
                if(arr[i]+arr[j] == x)
                {
                    cout<<i<<" "<<-j<<endl;
                    fg = false;
                    break;
                }
            }
            if(!fg){break;}
        }
        return 0;
    }

Measured memory_bytes: 4140
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(void){
	string s;
	map<char,bool> mp;
	cin>>s;
	char tmp;
	int i;
	for(i=0; i<s.size(); i++){
		tmp=s[i];
		if(mp[tmp] == false){
			mp[tmp]=tmp;
		}else{
			cout<<"no"<<endl;
			return 0;
		}
	}
	cout<<"yes"<<endl;
	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll A, B, C;
    ll x1, x2, x3;
    ll answer;

    cin >> A >> B >> C;
    x1 = max({A, B, C});
    x3 = min({A, B, C});
    ll sumABC = A + B + C;
    x2 =  sumABC - x1 - x3;
    
    answer = (x1 - x2) / 2 + (x1 - x3) / 2;
    x3 += ((x1 - x3) / 2) * 2;
    x2 += ((x1 - x2) / 2) * 2;

    if (x2 == x3 && x1 > x2) answer ++;
    else if (x2 != x3) answer += 2;
 
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string T;
    cin >> T;
    //cout << T << endl;
    
    for(int i = 0; i < T.size(); i++){
        if(T[i] == '?'){
            T[i] = 'D';
        }
    }

    cout << T << endl;
    
    return 0;
}

Measured memory_bytes: 3748
n,t=map(int,input().split())

c=[]
for i in range(n):
  c_=list(map(int,input().split()))
  c.append(c_)
  
c.sort()

for i in range(n):
  if c[i][1]<=t:
    print(c[i][0])
    exit()
    
  else:
    continue
    
print('TLE')

Measured memory_bytes: 9204
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	int x, y, z; cin >> x >> y >> z;

	cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

// 各桁の和
template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


class tree{
public:
  tree* par;
  vector<tree*> chi;
  int cnt;
};

int cnt(int a,int b){
  int count = -1;
  while(a){
    a /= b;
    ++count;
  }
  return count;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  vector<vector<int> > c(3,vector<int>(3));
  rep(i,3)rep(j,3)cin>>c[i][j];
  vector<int> dif(2);
  dif[0] = c[0][0] - c[0][1];
  dif[1] = c[0][1] - c[0][2];
  bool is_ok = true;
  rep(i,3){
    is_ok &= dif[0] == c[i][0] - c[i][1];
    is_ok &= dif[1] == c[i][1] - c[i][2];
  }

  
  dif[0] = c[0][0] - c[1][0];
  dif[1] = c[1][0] - c[2][0];
  rep(i,3){
    is_ok &= dif[0] == c[0][i] - c[1][i];
    is_ok &= dif[1] == c[1][i] - c[2][i];
  }
  string ans = (is_ok)? "Yes" : "No";
  print(ans);
  return 0;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if __name__ == '__main__':
    N = int(input())
    map = dict()
    for n in range(N, 1, -1):
        F = factorization(n)
        for f in F:
            p = f[0]
            e = f[1]
            if f[0] in map:
                map[p] += e
            else:
                map[p] = 0
                map[p] += e
    ans = 1    
    for m in map.values():
        ans *= (m + 1)
    print(ans%(pow(10, 9)+7))

Measured memory_bytes: 74276
def solve():
    N, T, A, *H = map(int, open(0).read().split())
    
    aveT = [0] * N
    for i in range(N):
        aveT[i] = T - H[i] * 0.006
    
    ans, d_min = 0, 10 ** 5
    for i in range(N):
        if abs(A - aveT[i]) < d_min:
            ans = i + 1
            d_min = abs(A - aveT[i])
    print(ans)


if __name__ == '__main__':
    solve()


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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define For(i,a,n) for(i=a;i<n;i++)
#define all(ar) ar.begin(),ar.end() 
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
const ll mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    ll n, l,r,ans,i,temp, fin = 0;
    cin>>n;
    ans = r = temp = n;
    while(fin<n){
        l = 1;
        while(l<=r){
            ll ex,surp,mid = l + (r-l)/2;
            ex = temp - mid;
            surp = (mid * (mid-1))/2;
            if(surp>=ex){
                //cout<<mid sp;
                ans = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        cout<<ans el;
        r = temp - ans;
        temp = r;
        fin+= ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "utility"


typedef std::pair<int,int> pint;

int main(int argc, char const *argv[]) {
  int N, M;
  std::cin >> N >> M;

  pint a[M];

  for (size_t i = 0; i < M; i++) {
    /* code */
    std::cin >> a[i].second >>a[i].first;
  }


  sort(a, a+M);

  // for (size_t i = 0; i < M; i++) {
  //   /* code */
  //   std::cout << a[i].second << a[i].first <<'\n';
  // }
  int pos = -1;
  int cc = 0;
  for (size_t i = 0; i < M; i++) {
    /* code */
    if (a[i].second >= pos) {
      /* code */
      pos = a[i].first;
      cc++;
    }
  }
  std::cout << cc << '\n';
  return 0;
}


Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc137/submissions/6836579

from heapq import heappush, heappop

n, m = map(int, input().split())
c = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    if a <= m:
        c[a - 1].append(b)
r = 0
h = []
for l in c:
    # m - c[i + 1] 日の仕事選びをする
    for x in l:
        # 条件に間に合う仕事を h に入れていく
        heappush(h, -x)
    # もし仕事があるなら最大の仕事をチョイスして h から削除
    if h:
        r -= heappop(h)
print(r)



Measured memory_bytes: 18504
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 3 + 10, INF = 1e9 * 1000;
vector<vector<ll>> gr;
string s;
bool used[SIZE], good[SIZE];

void dfs(int v) {
    used[v] = 1;

    for (auto to : gr[v]) {
        if (!used[to]) {
            dfs(to);
        }
    }
}

int main() {
    fastInp;
    
    ll n, m;
    cin >> n >> m;
    cin >> s;
    for (int i = 0; i < n; i++) good[i] = 1;

    gr.resize(n);
    for (int i = 0; i < m; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        gr[u].push_back(v);
        gr[v].push_back(u);
    }

    cerr << "baka\n";
    vector<ll> bd, cnt[2];
    cnt[0].resize(n);
    cnt[1].resize(n);
    for (int i = 0; i < n; i++) {
        ll fl1 = 0, fl2 = 0;
        for (auto to : gr[i]) {
            if (s[to] == 'A') {
                fl1++;
            } else {
                fl2++;
            }
        }
        if (!((fl1 >= 1) && (fl2 >= 1))) {
            bd.push_back(i);
            good[i] = 0;
        }
        cnt[0][i] = fl1;
        cnt[1][i] = fl2;
    }

    while (!bd.empty()) {
        ll v = bd.back();
        bd.pop_back();

        ll cur = !(s[v] == 'A');
        for (auto to : gr[v]) {
            bool k = 0;
            if ((cnt[1][to] >= 1 && cnt[0][to] >= 1)) k = 1;
            cnt[cur][to]--;
            if ((cnt[1][to] >= 1 && cnt[0][to] >= 1)) k = 0;

            if (k) {
                bd.push_back(to);
                good[to] = 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        if (good[i]) {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
    return 0;
}


Measured memory_bytes: 18640
#include <stdint.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using int_type = int64_t;

#define FOR(i, n) for (int_type i = 0; i < n; ++i)

int_type gcd(int_type a, int_type b) {
    return b == 0 ? a : gcd(b, a % b);
}
int_type lcm(int_type a, int_type b) {
    return (a * b) / gcd(a, b);
}

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

    int_type N;
    cin >> N;

    int_type P[8], Q[8], R[8];
    FOR(i, N) cin >> P[i];
    FOR(i, N) cin >> Q[i];

    int_type PN = 0, QN = 0;
    FOR(i, N) R[i] = i + 1;
    do {
        PN++;
        if (equal(R, R + N, P)) break;
    } while (next_permutation(R, R + N));
    FOR(i, N) R[i] = i + 1;
    do {
        QN++;
        if (equal(R, R + N, Q)) break;
    } while (next_permutation(R, R + N));

    cout << abs(PN - QN);

    return 0;
}


Measured memory_bytes: 512
def minesweeper(s, i, j):
    ans = 0
    for ii in range(-1,2):
        for jj in range(-1,2):
            try:
                if s[i+ii][j+jj] == "#" and ( (i+ii >= 0) and (j+jj >= 0) ):
                    ans += 1
            except:
                None
    return ans

h, w = map(int, input().split())
s = [input() for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            print(minesweeper(s, i, j), end="")
        else:
            print("#", end="")
    print("")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)     cerr<<#x<<":"<<x<<endl;
#define trace2(x,y) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<":"<<x<<"|"<<#y<<":"<<y<<"|"<<#z<<":"<<z<<endl;
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

int main(){
	fast_io;
	int n;
	cin>>n;
	vi a(n+1);
	vi p(2e6+5,0);
	for(int i=2;i<=n;i++){
		cin>>a[i];
		p[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		cout<<p[i]<<"\n";
	}

	
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

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

using namespace std;

vector<vector<pair<int, int>>> edges;
vector<int> colors;

void dfs(int cur) {
  auto& nexts = edges[cur];
  for (auto& next : nexts) {
    if (colors[next.first] == -1) {
      colors[next.first] = next.second ^ colors[cur];
      dfs(next.first);
    }
  }
}

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

  int N;
  cin >> N;

  edges.resize(N);
  for (int i = 1; i < N; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    edges[--u].emplace_back(--v, 0x1 & w);
    edges[v].emplace_back(u, 0x1 & w);
  }
  colors.resize(N, -1);
  colors[0] = 0;

  dfs(0);

  for (auto color : colors) {
    cout << color << endl;
  }
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll R;
ll t;
ll ret = 0;
ll A = 0, B = 0, C = 0;
string s;


void input() {
  IN(N);
  IN(R);
}

void solve() {
  if (N <= 10) {
    PRINT(R + 100 * (10 - N));
  } else {
    PRINT(R);
  }
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int[] a = new int[x];
        for(int i=0; i<x; i++) {
        	a[i] = sc.nextInt();
        }

        int y = sc.nextInt();
        int[] b = new int[y];
        for(int i=0; i<y; i++) {
        	b[i] = sc.nextInt();
        }

        int[]c = new int[y];

        for(int i=0; i<y; i++) {
        	for(int j=0; j<x; j++) {
        		if(b[i]==a[j]) {
        			c[i]++;
        		}
        	}
        }

        int d = 0;

        for(int i=0; i<y; i++) {
        	if(c[i]!=0) {
        		d++;
        	}
        }

        System.out.println(d);

        sc.close();
    }
}


Measured memory_bytes: 39904
fun main(args: Array<String>) {
    val s = readLine()!!

    var ans = 0L

    for (i: Int in 0 until (1 shl s.length - 1)) {
        var tmp: Long = (s[0] - '0').toLong()
        for (b: Int in 0 until s.length - 1) {
            if (1 and (i shr b) == 1) {
                ans += tmp
                tmp = (s[b + 1] - '0').toLong()
            } else {
                tmp = tmp * 10 + (s[b + 1] - '0')
            }
        }
        ans += tmp
    }

    println(ans)
}

Measured memory_bytes: 33628
using System;
using System.Linq;

namespace aoj.volume0 {
	class _0070 {
		private static void CreateMem(int[,] dp, int rank, int sum, bool[] mem) {
			if (rank > 10) return;
			for(int i = 0; i < 10; i++) {
				if (mem[i]) continue;
				mem[i] = true;
				dp[rank, sum + rank * i]++;
				CreateMem(dp, rank + 1, sum + rank * i, mem);
				mem[i] = false;
			}
		}
		public static void Main() {
			var dp = new int[11,331];
			CreateMem(dp, 1, 0, new bool[10]);
			string str;
			while((str = Console.ReadLine())!= null) {
				var data = str.Split().Take(2).Select(int.Parse).ToArray();
				Console.WriteLine((data[1] > 330) ? 0 : dp[data[0], data[1]]);
			}
		}
	}
}

Measured memory_bytes: 9552
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
const int maxn = 1e5+5;

int main(){
	string s; cin >> s;
	int n = s.size();
	for(int i = 0; i < n; i++){
		if((i + 1) & 1 && s[i] == 'L'){
			cout << "No" << endl;
			return 0;
		}
		if((i + 1) % 2 == 0 && s[i] == 'R'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int gcd(int a, int b){
	if( b==0) return a;

	return gcd(b , a%b);
}


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

	int k;
	cin>>k;

	ll sum =0;
	for(int i=1; i<=k; i++){
		for(int j=1; j<=k; j++){
			for(int n=1; n<=k; n++){
				sum += gcd(gcd(i,j),n);
			}
		}
	}
	writeln(sum);


}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

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

    char last2 = S[0];
    char last1 = S[1];
    ll ans = 0;
    REPi(i,2,N){
        char now = S[i];
        if(last2 == 'A' && last1 == 'B' && now == 'C')
            ans++;
        last2 = last1;
        last1 = now;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;

	string s[100];
	REP(i, h) cin >> s[i];

	REP(i, w + 2) cout << '#';
	cout << endl;
	REP(i, h){
		cout << '#';
		cout << s[i];
		cout << '#' << endl;
	}
	REP(i, w + 2) cout << '#';
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int a[N];
   map<int, ll> log;
   for (int i = 0; i < N; i++) {
      cin >> a[i];
      log[a[i]]++;
      log[a[i] - 1]++;
      log[a[i] + 1]++;
   }
   ll ans = 0;
   for (auto it = log.begin(); it != log.end(); it++) {
      chmax(ans, it->second);  
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n, k, x, y; cin >> n >> k >> x >> y;
  cout << min(k, n) * x + (n - min(k, n)) * y << endl;

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

long gcd(long a,long b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}
int main(){
    long X,Y;
    cin>>X>>Y;
    if(X%Y==0){
        cout<<-1<<endl;
        return 0;
    }
    long g=gcd(X,Y);
    long x=X/g;
    cout<<x*X<<endl;
    return 0;
}

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

int main()
{
  int a, b, c, K;
  cin >> a >> b >> c >> K;
  for (int i = 0; i < K; i++) {
    if (a >= b) {
      b *= 2;
    } else if (b >= c) {
      c *= 2;
    }
  }
  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,a[N],b[N],ans;
int ef(int x){
	int l=1,r=n;
	while (l<r){
		int mid=(l+r)/2;
		if (b[mid]<x)l=mid+1;
		else r=mid;
	}
	return l;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+n+1);
	for (int i=1;i<=n;i++)a[i]=ef(a[i]);
	for (int i=1;i<=n;i++){
		int t=abs(a[i]-i);
		if (t%2)ans++;
	}
	printf("%d\n",ans/2+ans%2);
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

//*---mint---*/
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint operator~() const { return mint(1) / *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint& operator/=(const mint& a){ (x*=a.pow(mod-2).x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  mint operator/(const mint& a)const{ return mint(*this) /= a;}
  mint pow(ll t) const {
    if(!t) return 1;
    mint res = pow(t/2);
    res *= res;
    return (t&1)?res*x:res;
  }
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
mint ex(mint x, ll t) { return x.pow(t);}
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
typedef vector<mint> vm;
struct comb {
  vm f, g;
  comb(){}
  comb(int mx):f(mx+1),g(mx+1) {
    f[0] = 1;
    rep(i,1,mx) f[i] = f[i-1]*i;
    g[mx] = f[mx].pow(mod-2);
    for(int i=mx;i>0;i--) g[i-1] = g[i]*i;
  }
  mint c(int a, int b) {
    if (a < b) return 0;
    return f[a]*g[b]*g[a-b];
  }
} c(3e6);
//c.c(a,b)=>aCb mod

// mint f(mint x, mint n){
//     mint res;
//     res = 3*k;
//     res *= k+1;
//     res *= 2 * n -1;
//     mint res2;
//     res2 = k;
//     res2 *= k+1;
//     res2 *= 2*k + 1;
//     res -= res2;
//     res /= 12;

// }

int main(){
    int n,k;
    mint ans = 0;
    cin >> n >> k;
    // if(n == k-1){
    //     puts("1");
    //     return 0;
    // }
    rep(i,1,n+1){
        mint res = (mint)i * n;
        res -= (mint)(i-1) * i /2;
        res -= (mint)(i-1) * i / 2;
        res += (mint)1;
        ans += res;
    }
    rep(i,1,k-1){
        mint res = (mint)i * n;
        res -= (mint)(i-1) * i /2;
        res -= (mint)(i-1) * i / 2;
        res += (mint)1;
        ans -= res;
    }


    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 50064