akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long a,n,m,k,s=0,p,ar[101][101],ar1[100001],i,j,c=0,r,t;
int main()
{
	cin>>a;
	for(i=0;i<a;i++)
		cin>>ar1[i];
	sort(ar1,ar1+a);
	cout<<ar1[a-1]-ar1[0];
}

Measured memory_bytes: 256
import sys

def gcd(a, b): return gcd(b, a % b) if b else abs(a)
def lcm(a, b): return abs(a // gcd(a, b) * b)

a, b, c = map(int, sys.stdin.readline().split())

def main():
    print("NO" if c % gcd(a, b) else "YES")

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3060
#import numpy as np

def FindMaxCon(res, water, C, D, E):
  c = 0
  d = 0
  tmpCon = 0
  dp = list([False] * 3001)
  dp[0] = True
  for i in range(3001):
    if(i - C >= 0 and i - D >= 0):
      dp[i] = dp[i - C] or dp[i - D]
    elif(i - C >= 0):
      dp[i] = dp[i - C]
    elif(i - D >= 0):
      dp[i] = dp[i - D]
  tmpSugar = 0
  for i in range(min(res, int(E * water / 100)) + 1):
    if(dp[i]):
      tmpSugar = i
  ans = tmpSugar
  return ans

A, B, C, D, E, F = (int(_) for _ in input().split())
amax = F / (A * 100)
bmax = F / (B * 100)
amax = int(amax)
bmax = int(bmax)
water = 0
sugar = 0
waterAns = 100 * A
sugarAns = 0
con = 0
conAns = 0
for a in range(1, amax + 1):
  for b in range(bmax + 1):
    water = 100 * (a * A + b * B)
    if(water > F):
      continue
    else:
      res = F - water
      tmp = FindMaxCon(res, water, C, D, E)
      sugar = tmp
      con = sugar / water
      if(con > conAns):
        conAns = con
        waterAns = water
        sugarAns = sugar
answer = str(waterAns + sugarAns) + " " + str(sugarAns)
print(answer)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
ll INF = 1'000'000'000'000'000'000;

int main(){
  int n;
  cin >> n;
  ll ans = 1;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
    if (a.at(i) == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i,n){
    if (INF/ans < a.at(i) || ans > INF){
      cout << -1 << endl;
      return 0;
    }
    ans *= a.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3996
let levenshtein_distance s t =
  let m = String.length s in
  let n = String.length t in
  let d = Array.make_matrix (m + 1) (n + 1) 0 in
  for i = 1 to m do
    d.(i).(0) <- i
  done;
  for j = 1 to n do
    d.(0).(j) <- j
  done;
  for j = 1 to n do
    for i = 1 to m do
      let c = if s.[i-1] = t.[j-1] then 0 else 1 in
      d.(i).(j) <- if d.(i-1).(j) + 1 < d.(i).(j-1) + 1 then d.(i-1).(j) + 1 else d.(i).(j-1) + 1;
      d.(i).(j) <- if d.(i-1).(j-1) + c < d.(i).(j) then d.(i-1).(j-1) + c else d.(i).(j)
    done
  done;
  d.(m).(n)

let () =
  let s1 = read_line () in
  let s2 = read_line () in
  Printf.printf "%d\n" (levenshtein_distance s1 s2)

Measured memory_bytes: 10372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

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

    vector<int> p(n);
    rep(i,n)    cin >> p[i];

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

    int ans(0);
    rep(i,k){
        ans += p[i];
    } 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

const vector<int> dx4 = {-1,  0,  1,  0};
const vector<int> dy4 = { 0,  1,  0, -1};
const vector<int> dx8 = {-1, -1, -1,  0,  1,  1,  1,  0};
const vector<int> dy8 = {-1,  0,  1,  1,  1,  0, -1, -1};

int main(){
    int n;
    cin >> n;
    vector<int> list = {111, 222, 333, 444, 555, 666, 777, 888, 999};

    for(int i = 0; i < list.size(); i++){
        if(n <= list[i]){
            cout << list[i] << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n; cout << 111 * ((n + 110) / 111) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;

//nのp乗
ll power(ll n,ll p){
    if(p==0){return 1;}
    if(p%2==1){return n*power(n,(p-1)/2)*power(n,(p-1)/2);}
    else{return power(n,p/2)*power(n,p/2);}
}

int plu(int x,int y){
    bitset<12> X(x);
    bitset<12> Y(y);
    bitset<12> Z=(X | Y);
    int z=Z.to_ullong();
    return z;
}

int main() {
    int N,M;
    cin>>N>>M;
    vector<pair<int,int>> key(M);
    rep(i,M){
        cin>>key.at(i).first;
        int b;
        cin>>b;
        rep(j,b){
            int c;
            cin>>c;
            --c;
            key.at(i).second+=power(2,c);
        }
    }

/*rep(i,M){
    cout<<key.at(i).second<<" ";
}
cout<<endl;*/

    int P=power(2,N);
    vector<vector<int>> dp(M,vector<int>(P,-1));
    dp.at(0).at(key.at(0).second)=key.at(0).first;
    dp.at(0).at(0)=0;
    for(int i=1;i<M;i++){
        rep(j,P){
            dp.at(i).at(j)=dp.at(i-1).at(j);
        }
        rep(j,P){
            if(dp.at(i-1).at(j)!=-1){
                int k1=j;
                int k2=key.at(i).second;
                int k=plu(k1,k2);

//cout<<k<<endl;

                if(dp.at(i).at(k)==-1){dp.at(i).at(k)=dp.at(i-1).at(j)+key.at(i).first;}
                else{dp.at(i).at(k)=min(dp.at(i).at(k),dp.at(i-1).at(j)+key.at(i).first);}
            }
        }
    }
    cout<<dp.at(M-1).at(P-1)<<endl;
}

Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
const int N = (int)1e5+5;
long long int arr[N];
int main()
{
    int t,a,b,c,n,i,j=0,m1,m2=0,d1,d2;
 string s;

 cin>>s;
 n=s.size();
 m1=n/2;
for(i=0;i<m1;i++)
{
    if(s[i]!=s[n-i-1])
    {
    m2++;

    }

}
cout<<m2<<endl;






    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

int w,a,b;
cin >> w >> a >> b;
  
  if(b < a && b + w  < a ){cout << a - (b + w) << endl; return 0;}
  if(a + w < b && a + w < b + w){cout << b - (a + w) << endl; return 0;} 
  cout << 0 << endl;

return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        k:i64,
        x:i64
    }
    let left = std::cmp::max(-1000000, x-k+1);
    let right = std::cmp::min(1000000, x+k-1);
    for i in left..right {
        print!("{} ", i);
    }
    println!("{}", right);
}

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

const int maxn = 2000000 + 5;
const int maxm = 10000 + 5;

int n;
int A[maxn],B[maxn],C[maxm];

void Counting_Sort(int left,int right){
	for(int i = left;i <= right; i++)C[A[i]]++;
	for(int i = 1;i <= maxm; i++)C[i] += C[i-1];
	for(int i = left;i <= right; i++){
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}
}

int main(){
	scanf("%d",&n);
	for(int i = 1;i <= n; i++)scanf("%d",&A[i]);
	Counting_Sort(1,n);
	for(int i = 1;i <= n; i++){
		if(i != 1)printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
}

Measured memory_bytes: 18828
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i):a(x,3,x);[[b(p:=i+t+30),a(q:=p+1,3,q),[*map(b,r(q,v:=i+60))],a(v,x,i+t,1),b(p),a(q,i+t,q)]for t in r(30)]
p(3934)
a(0,1,3)
a(2,3,3,1)
d(0,9)
d(1,50)
for t in r(60):a(2,2,2);[t-31<s<30!=(a(8+t-s,50+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]

Measured memory_bytes: 9244
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)

const ll INF = 1LL << 60;



signed main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>p(m + 1);
	vector < vector<ll>> s(m + 1);

	rep(i, m) {
		ll k;
		cin >> k;
		rep(j, k){
			ll a;
			cin >> a;
			s[i].push_back(a);
		}
	}
	rep(i, m)cin >> p[i];
	ll ans = 0;
	rep(bits, 1 << n) {
		bool flag = true;
		rep(j, m) {
			ll a = 0;
			for (ll i : s[j]) {
				if ((bits >> (i - 1)) & 1)a++;
			}
			if (a % 2 != p[j]) {
				flag = false;
				break;
			}
		}
		if (flag)ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int res;
    int i;

    scanf ( "%d", &res );
    if ( !res ) break ;

    for ( i = 0; i < 9; ++i )
    {
      int d;

      scanf ( "%d", &d );
      res -= d;
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

void go(){
	int r;cin>>r;
	cout << r*r;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


// return sum of top K element (default: maximum)
template<typename T, T identity, typename V=vector<T>,
         typename C1=less<T>, typename C2=greater<T> >
struct PrioritySum{
  size_t num;
  T sum;
  priority_queue<T, V, C1> pq1;
  priority_queue<T, V, C2> pq2;
  PrioritySum():num(0),sum(identity){}
  PrioritySum(size_t num):num(num),sum(identity){}

  void resolve(){
    assert(size()>=num);
    while(pq2.size()<num){
      sum+=pq1.top();
      pq2.emplace(pq1.top());
      pq1.pop();
    }
    while(pq2.size()>num){
      sum-=pq2.top();
      pq1.emplace(pq2.top());
      pq2.pop();
    }
    if(pq1.empty()||pq2.empty()) return;
    while(C2()(pq1.top(),pq2.top())){
      T t1=pq1.top();pq1.pop();
      T t2=pq2.top();pq2.pop();
      sum+=t1;
      sum-=t2;
      pq1.emplace(t2);
      pq2.emplace(t1);
    }
  }

  T query(){resolve();return sum;}

  void push(const T &x){pq1.emplace(x);}
  void expand(){num++;}
  void shrink(){assert(num);num--;}

  size_t size()const{return pq1.size()+pq2.size();}
  bool isvalid()const{return num<=size();}
};
template<typename T>
using MaximumSum=PrioritySum<T, T(0), vector<T>, less<T>, greater<T> >;
template<typename T>
using MinimumSum=PrioritySum<T, T(0), vector<T>, greater<T>, less<T> >;


//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<Int> ps(a),qs(b),rs(c);
  for(Int i=0;i<a;i++) cin>>ps[i];
  for(Int i=0;i<b;i++) cin>>qs[i];
  for(Int i=0;i<c;i++) cin>>rs[i];

  sort(ps.rbegin(),ps.rend());
  sort(qs.rbegin(),qs.rend());

  ps.resize(x);
  qs.resize(y);
  for(Int r:rs) qs.emplace_back(r);

  MaximumSum<Int> ss(x),ts(y);
  for(Int p:ps) ss.push(p);
  for(Int q:qs) ts.push(q);

  Int ans=ss.query()+ts.query();
  for(Int i=0;i<x;i++){
    ss.shrink();
    ts.expand();
    if(ss.isvalid() and ts.isvalid())
      chmax(ans,ss.query()+ts.query());
  }
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 9708
#include <iostream>

using namespace std;

const int MAXN = 1e5 + 5;

int n;
int num[MAXN];

int Gcd(int a, int b) {
    if (a > b) swap(a, b);
	return a == 0 ? b : Gcd(a, b % a);
}

struct Node{
	int val;
	Node *ch[2];
	Node(int val = 0): val(val) {ch[0] = ch[1] = NULL;}
};

Node *rt = NULL;

void Build(Node *&now, int l, int r) {
	now = new Node();
	if (l == r) {
	    now->val = num[l];
		return;
	}
	int mid = l + r >> 1;
	Build(now->ch[0], l, mid);
	Build(now->ch[1], mid + 1, r);
	now->val = Gcd(now->ch[0]->val, now->ch[1]->val);
}

void Modify(Node *now, int pos, int k, int nowl, int nowr) {
	if (nowl == pos && nowr == pos) {
		now->val = k;
		return;
	}
	int mid = nowl + nowr >> 1;
	if (pos <= mid) Modify(now->ch[0], pos, k, nowl, mid);
	else Modify(now->ch[1], pos, k, mid + 1, nowr);
	now->val = Gcd(now->ch[0]->val, now->ch[1]->val);
}

int main() {
	ios :: sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> num[i];
	Build(rt, 1, n);
	int ans = rt->val;
	for (int i = 1; i <= n; i++) {
		Modify(rt, i, 0, 1, n);
		ans = max(ans, rt->val);
		Modify(rt, i, num[i], 1, n);
	}
	cout << ans << endl;
	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  ll x, y; cin >> x >> y;
  ll n = x;
  if(x % y != 0) {
    while(true) {
      if(n % y != 0) {
        cout << x << endl;
        return 0;
      }
      n += x;
    }
  } else {
    cout << -1 << endl;
  }

  return 0;
}

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

int n,m;
string s[100],t[100];



int main(){
  int i,j,now=1,ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)cin >> s[i];
  scanf("%d",&m);
  for(i=0;i<m;i++)cin >> t[i];

   for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(i!=j){
	 if(s[i]==s[j])now++;
    }
    }
    for(j=0;j<m;j++){
	 if(s[i]==t[j])now--;
      
      }
    if(now>ans)ans=now;
    now = 1;
    }

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


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

const ll INF = 1LL << 60;

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

    string sa,sb,sc;
    cin >> sa >> sb >> sc;
    ll na = sa.size();
    ll nb = sb.size();
    ll nc = sc.size();
    ll ta = 0;
    ll tb = 0;
    ll tc = 0;
    deque<char> da(na);
    deque<char> db(nb);
    deque<char> dc(nc);

    for (ll i = 0; i < na; i++){
        da[i] = sa[i];
    }
    for (ll i = 0; i < nb; i++){
        db[i] = sb[i];
    }
    for (ll i = 0; i < nc; i++){
        dc[i] = sc[i];
    }

    char now = 'a';

    while (true){
        if (now == 'a'){
            if (da.size() == 0){
                cout << "A" << endl;
                break;
            }
            now = da[0];
            da.pop_front();
        }
        if (now == 'b'){
            if (db.size() == 0){
                cout << "B" << endl;
                break;
            }
            now = db[0];
            db.pop_front();
        }
        if (now == 'c'){
            if (dc.size() == 0){
                cout << "C" << endl;
                break;
            }
            now = dc[0];
            dc.pop_front();
        }
    }

}

Measured memory_bytes: 3664
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	if(n%m==0)return puts("-1"),0;
	printf("%d\n",n);
	return 0;
}

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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


ll combi2(ll n) {
  if(n%2 == 0)
    return n/2*(n-1);
  else
    return (n-1)/2*n;
}




int main(){
  ll n;
  cin >> n;	
  
  vector<ll> a(n);
  rep(i,0,n)
    cin >> a.at(i);
  
  map<ll,ll> m;
  rep(i,0,n)
    m[a.at(i)]++;
  
  ll ans = 0;
  for(auto it = m.begin(); it != m.end(); ++it) {
    if(it->se > 1)
      ans += combi2(it->se);
  }
  //cout << ans << endl;
  
  rep(i,0,n){
    ll tmp = ans;
    tmp -= combi2(m[a.at(i)]);
    if(m[a.at(i)] > 2)
      tmp += combi2(m[a.at(i)]-1);
    
    cout << tmp << endl;

  }
  
  
}

Measured memory_bytes: 11776
import java.util.Scanner;

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

		int a = sc.nextInt();	//1の枚数
		int b = sc.nextInt();	//0の枚数
		int c = sc.nextInt();	//-1の枚数
		int k = sc.nextInt();	//選択の枚数

		int sum = 0;
		//1を取り出せるか？
		if(k>0) {
			for(int i=0; i < a; i++) {
				sum++;
				k--;
				if(k == 0) {
					break;
				}
			}
		}

		//0を取り出せるか?
		if(k>0) {
			for(int i=0; i < b; i++) {
				k--;
				if(k == 0) {
					break;
				}
			}
		}

		//-1を取り出せるか？
		if(k>0) {
			for(int i=0; i < c; i++) {
				sum--;
				k--;
				if(k == 0 || k > c) {
					break;
				}
			}
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 36228
// D - Div Game
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// 素数と個数を求める
vector<pair<ll,ll>> factorize(ll n){
  vector<pair<ll,ll>> res;
  for(ll i=2L; i*i<=n; ++i){
    if (n%i) continue;
    res.emplace_back(i,0);
    while(n%i == 0){
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n,1L);
  return res;
}

// // a^n を計算する(二分累乗法:O(logn))
// ll llpow(ll a, ll n) {
// 	ll x;
// 	for(x=1; n>0; a*=a, n>>=1) if(n&1) x*=a;
// 	return x;
// }

int main(){
	ll N; cin>>N;
	vector<pair<ll,ll>> P = factorize(N);
	ll ans = 0;
	for(auto x:P){
		ll p,c; tie(p,c) = x;
		// cout<<" p "<<p;
		// cout<<" c "<<c;
		// cout<<"\n";
		for(ll i=1,pi=p; c>0; c-=i, i++,  pi*=p){
			// cout<<" i "<<i;
			// cout<<" pi "<<pi;
			// cout<<" c "<<c;
			// cout<<"\n";
			if(N%pi) continue;
			N /= pi;
			ans++;
		}
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=998244353;
char s[2010];
LL f[4010][4010],n,sum[4010];
void add(LL &x,LL y) {x+=y;x%=mod;}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(LL i=1;i<=n;i++)
	{
		sum[i]=sum[i-1];
		if(s[i]=='0') sum[i]+=2;
		if(s[i]=='1') sum[i]++;
	}
	f[0][0]=1;
	for(LL i=0;i<2*n;i++)
		for(LL j=0;j<=i;j++) if(f[i][j])
		{
			LL s1=sum[min(i+1,n)]-j,s2=2*min(i+1,n)-sum[min(i+1,n)]-(i-j);
			//printf("%lld %lld %lld %lld %lld\n",i,j,f[i][j],s1,s2);
			if(s1) add(f[i+1][j+1],f[i][j]);
			if(s2) add(f[i+1][j],f[i][j]);
		}
	printf("%lld",f[2*n][sum[n]]);
}

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

public class Test
{
	public static void Main()
	{
		// my code goes here
		var x = Console.ReadLine().Split().Select(y => int.Parse(y)).ToArray();
		int n = x[0];
		int k = x[1];
		int[] counter = new int[n];
		for(int m=0;m!=n;m++){counter[m] = 0;}
		int ans = 0;
		int d = 0;
		int e = 0;
		for(int i=0; i!=k;i++){
			d = int.Parse(Console.ReadLine());
			x = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
			for(int j=0; j!=d; j++){
				e = x[j];
				counter[e-1] += 1;
			}
		}
		for(int l=0;l!=n;l++){
			if(counter[l]==0){ans++;}
		}
		
		Console.WriteLine(ans);
		
	}
}

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

using namespace std;

int main(){
	int n, a, b, c, d;
	int score[101];
	int pnt[101];
	fill_n(pnt, 101, 0);
	vector<pair<int, int> > v;
	cin >> n;
	for(int i = 0; i < n*(n-1)/2; i++){
		cin >> a >> b >> c >> d;
		if(c < d) pnt[b]+=3;
		else if(c > d) pnt[a]+=3;
		else pnt[b]++, pnt[a]++;
	}
	for(int i = 1; i <= n; i++){
		v.push_back(make_pair(pnt[i], i));
	}
	sort(v.begin(), v.end());
	int index = 0;
	int before = 0;
	int same = 0;
	for(int i = v.size() - 1; i >= 0; i--){
		if(v[i].first == before){
			same++;
			score[v[i].second] = index;
		}else{
			index += same + 1;
			score[v[i].second] = index;
			before = v[i].first;
			same = 0;
		}
	}

	for(int i = 1; i <= n; i++){
		cout << score[i] << endl;
	}

	return 0;
}


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

using namespace std;
typedef long long ll;
const int modu = 1e9 + 7;
int a[405], b[405], n, c;
ll f[405][405], p[405][405], s[405][405];

int main() {
	cin >> n >> c;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) cin >> b[i];
	for (int i = 1; i <= 400; ++i) {
		p[i][0] = 1;
		for (int j = 1; j <= 400; ++j)
			p[i][j] = p[i][j-1]*i % modu;
	}
	for (int i = 0; i <= 400; ++i) {
		s[i][0] = 0;
		for (int j = 1; j <= 400; ++j)
			s[i][j] = (s[i][j-1] + p[j][i]) % modu;
	}
	memset(f, 0, sizeof(f));
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= c; ++j)
			for (int k = 0; k <= j; ++k) {
				f[i][j] = (f[i][j] + f[i-1][k]*(s[j-k][b[i]] - s[j-k][a[i]-1]+modu)%modu)%modu;
			}
	}
	cout << f[n][c] << endl;
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N,M;
int A;
int sum, ans;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> A;
		sum += A;
	}
	ans = N - sum;
	if (ans < 0) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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;
ll solve(ll a){
    ll cnt = 0;
    while(a > 0){
        cnt += a/5;
        a /= 5;
    }
    return cnt;
}
int main(){
    ll n;
    cin >> n;
    ll ans;
    if (n%2){
        ans = 0;
    }
    else{
        ans = solve(n/2);
    }
    PRINT(ans);
}


Measured memory_bytes: 256
_n = gets.to_i
a = gets.split.map(&:to_i)

alice = a.sort.reverse.select.each_with_index { |_, i| i % 2 == 0 }.inject(:+)
bob = a.sort.reverse.select.each_with_index { |_, i| i % 2 == 1 }.inject(:+)

puts alice - bob


Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>

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

int main()
{
	ll x; int k;
	cin>>x>>k;
	ll r[100001], ra[100001];
	r[0]=0; ra[0]=0;
	for(int i=1; i<=k; i++){
		cin>>r[i];
		if(i%2) ra[i]=ra[i-1]+r[i]-r[i-1];
		else ra[i]=ra[i-1]-r[i]+r[i-1];
	}
	int q;
	cin>>q;
	ll a[100000], ans[100000];
	P ti[100000];
	for(int i=0; i<q; i++){
		ll t;
		cin>>t>>a[i];
		ti[i]=P(t, i);
	}
	sort(ti, ti+q);
	ll x1=0, x2=x;
	int e=-1;
	ll ans0=0;
	int j=0;
	for(int i=0; i<=k; i++){
		while(j<q && (i==k || ti[j].first<r[i+1])){
			int i1=ti[j].second;
			ll t1=ti[j].first-r[i];
			if(e>=0){
				if(i%2) ans[i1]=min(x, ans0+t1);
				else ans[i1]=max(0ll, ans0-t1);
			}else if(x1>a[i1]){
				if(i%2) ans[i1]=min(x, x1-ra[i]+t1);
				else ans[i1]=max(0ll, x1-ra[i]-t1);
			}else if(x2<a[i1]){
				if(i%2) ans[i1]=min(x, x2-ra[i]+t1);
				else ans[i1]=max(0ll, x2-ra[i]-t1);
			}else{
				if(i%2) ans[i1]=min(x, a[i1]-ra[i]+t1);
				else ans[i1]=max(0ll, a[i1]-ra[i]-t1);
			}
			j++;
		}
		if(i==k) break;
		if(e>=0){
			if(i%2) ans0=min(x, ans0+r[i+1]-r[i]);
			else ans0=max(0ll, ans0-r[i+1]+r[i]);
		}else if(i%2){
			if(x+ra[i+1]<x2){
				x2=x+ra[i+1];
			}
			if(x1>=x2){
				e=i+1; ans0=x;
			}
		}else{
			if(ra[i+1]>x1){
				x1=ra[i+1];
			}
			if(x1>=x2){
				e=i+1; ans0=0;
			}
		}
	}
	for(int i=0; i<q; i++) cout<<ans[i]<<endl;	
    return 0;
}

Measured memory_bytes: 5888
N, K = map(int, input().split())
# print(N, K)

max_edges = (N - 2) * (N - 1) // 2
if max_edges < K:
    print(-1)
    exit()

remain = max_edges - K
print(N - 1 + remain)
for i in range(2, N + 1):
    print(1, i)

for i in range(2, N + 1):
    if remain <= 0:
        break
    for j in range(i + 1, N + 1):
        if remain <= 0:
            break
        print(i, j)
        remain -= 1


Measured memory_bytes: 43760
#include <iostream>
#include <stdio.h>
using namespace std;

const int MO=2019;

int main()
{
	int l,r;
	cin>>l>>r;
	if(l+MO<=r)
	{
		cout<<0<<endl;
		return 0;
	}
	// l<r
	l=l%MO;
	r=r%MO;
	if(r<l)
		r+=MO;
	int ans=MO;
	for(int i=l;i<=r;i++)
		for(int j=i+1;j<=r;j++)
			ans=min(ans,i*j%MO);
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const ll mod = 1000000007;
int n, c;
const int N = 410;
int l[N], r[N];
ll sum[N][N];
ll d[N][N];

ll get_st(ll a, int st) {
	ll res = 1;
	while(st) {
		if (st & 1) {
			(res *= a) %= mod;
		}
		(a *= a) %= mod;
		st >>= 1;
	}
	return res;
}

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	cin >> n >> c;
	forn(i, n)
		cin >> l[i];
	forn(i, n)
		cin >> r[i];
	forn(st, N) {
		forn(j, N) {
			sum[st][j] = get_st(j, st);
			if (j)
				(sum[st][j] += sum[st][j - 1]) %= mod;
		}
	}
	memset(d, 0, sizeof(d));
	d[0][0] = 1ll;
	forn(i, n) {
		forn(j, c + 1) {
			forn(k, c + 1 - j) {
				(d[i + 1][j + k] += d[i][j] * (sum[k][r[i]] - sum[k][l[i] - 1] + mod)) %= mod;
			}
		}
	}
	cout << d[n][c] << endl;
	
	return 0;
}


Measured memory_bytes: 2816
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
int x[10001];
int i;
i=0;
int z=0;
do{
scanf("%d",&x[i]);
i++;
}while(x[i-1]!=0);
for(z=0;z<i-1;z++){
	
	
	printf("Case %d: %d\n",z+1,x[z]);
	
	
}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
int dx[8]={0,0,1,1,1,-1,-1,-1};
int dy[8]={1,-1,1,-1,0,1,-1,0};
bool G[710][710];
int c[2];
int d[710];
vector<P> v;
int n,m;
bool f=true;
bool dp[1410];
void dfs(int v,int dr){
    d[v]=dr;
    c[dr]++;
    for(int i=0;i<n;i++){
        if(v!=i&&G[v][i]){
            if(d[i]==-1){
                dfs(i,dr^1);
            }else if(d[i]!=(dr^1)){
                f=false;
            }
        }
    }
}
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)G[i][j]=true;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;a--;b--;
        G[a][b]=false;
        G[b][a]=false;
    }
    for(int i=0;i<n;i++)d[i]=-1;
    for(int i=0;i<n;i++){
        c[0]=0;c[1]=0;
        if(d[i]!=-1)continue;
        dfs(i,0);
        v.push_back(P(c[0],c[1]));
    }
    if(!f){
        cout<<-1<<endl;
        return 0;
    }
    dp[0]=true;
    for(int i=0;i<v.size();i++){
        for(int j=n;j>=0;j--){
            if(dp[j]){
                dp[j]=false;
                dp[j+v[i].first]=true;
                dp[j+v[i].second]=true;
            }
        }
    }
    int mi=n;int a;
    for(int i=0;i<=n;i++){
        if(dp[i]&&mi>abs(n/2-i)){
            mi=abs(n/2-i);
            a=i;
        }
    }
    int b=n-a;
    cout<<a*(a-1)/2+b*(b-1)/2<<endl;
}

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

using namespace std;

#define int long long 

signed main(){

  int n,a,b; cin >> n >> a >> b;
  vector<int> x(n+1);
  for(int i = 0; i < n; i++) cin >> x[i];

  int ans = 0;
  for(int i = 0; i < n-1; i++){
    if((x[i+1] - x[i]) * a <= b){
      ans += (x[i+1] - x[i]) * a;
    }
    else {
      ans += b;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
using namespace std;
int main(){
    int n; cin >> n;
    int p[n]; cinf(n,p);
    int ans = 0;
    for(int i=1;i<n-1;i++){
        if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
        else if(p[i-1] > p[i] && p[i] > p[i+1]) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define lowbit(x) ((x)&(-x))
#define inf 0x3f3f3f3f
#define endl '\n'
#define MP(x,y) (make_pair(x,y))
#define pll pair<int,int>
#define pi 3.1415926535
using namespace std;
int x,y,z;
int main(){
    cin>>x>>y>>z;
    swap(x,z);
    swap(y,z);
    cout<<x<<' '<<y<<' '<<z<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n],index[n+1];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        index[a[i]] = i+1;
    }
    for(int i=1;i<n+1;i++){
        printf("%d ",index[i]);
    }
}

Measured memory_bytes: 1536
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, S: str):
    if N % 2 == 1:
        print(NO)
    else:
        if S[:N//2] == S[N//2:]:
            print(YES)
        else:
            print(NO)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

fac = [1, 1]     # 元テーブル
f_inv = [1, 1]   # 逆元テーブル
inv = [0, 1]     # 逆元テーブル計算用テーブル

def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod//i)) % mod)
        f_inv.append((f_inv[-1] * inv[-1]) % mod)

def cmb(n, r, mod):
    if n < 0 or r < 0:
        return 0
    if r > n:
        return 0

    return fac[n] * f_inv[r] * f_inv[n-r] % mod


def main():
    N,M,K = map(int, readline().split())

    MOD = 998244353
    prepare(N + 10, MOD)

    if M == 1 and K == N - 1:
        print(1)
        exit()

    m = M
    for _ in range(N-1):
        m *= M - 1
        m %= MOD

    ans = 0
    for k in range(K+1):
        ans += (m * cmb(N-1, k, MOD)) % MOD
        ans %= MOD

        m *= pow(M-1, MOD-2, MOD)
        m %= MOD

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32948
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A + B > C + D) {
		cout << "Left" << endl;
	}
	else if (A + B == C + D) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}
	return 0;
}




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

using namespace std;

typedef long long ll;

const string T[] = {"dream", "dreamer", "erase", "eraser"};

const int Maxn = 100010;
bool dp[Maxn];

int main() {
    string s;
    cin >> s;
    int n = (int) s.size();

    dp[0] = true;
    for (int i = 0; i <= n; ++i) {
        if (!dp[i]) continue;

        string tmp = s.substr(i, 5);
        if (tmp == T[0] || tmp == T[2]) dp[i + 5] = true;

        tmp = s.substr(i, 6);
        if (tmp == T[3]) dp[i + 6] = true;

        tmp = s.substr(i, 7);
        if (tmp == T[1]) dp[i + 7] = true;
    }

    cout << (dp[n]?"YES":"NO") << endl;
}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
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; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    bool good = true;
    rep(i, S.size()){
        if((i+1)%2 == 0){
            if(S[i] == 'R'){
                good = false; break;
            }
        }
        else{
            if(S[i] == 'L'){
                good = false; break;
            }
        }
    }
    cout << (good ? "Yes" : "No") << endstr;
    return 0;
}


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

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

	int n;
	cin >> n;

	int a[n];
	memset(a, 0, sizeof(a));
	for (int i = 0; i < n - 1; ++i) {
		int x;
		cin >> x;
		++a[x - 1];
	}
	for (auto x : a) {
		cout << x << '\n';
	}
}


Measured memory_bytes: 5216
using System;
using System.Collections.Generic;

public class B {
    public static void Main(){
        List<int> reizoko = new List<int>();
        List<int> densirenzi = new List<int>();
        List<int> waribiki = new List<int>();
        
        string[] line = Console.ReadLine().Split(' ');
        int A = int.Parse(line[0]);
        int B = int.Parse(line[1]);
        int M = int.Parse(line[2]);
        
        int minReizoko = 100000;
        int minDensirenzi = 100000;
        
        line = Console.ReadLine().Split(' ');
        for (int i=0;i<A;i++)
        {
            reizoko.Add(int.Parse(line[i]));
            minReizoko = Math.Min(minReizoko, reizoko[i]);
        }
        
        line = Console.ReadLine().Split(' ');
        for (int i=0;i<B;i++)
        {
            densirenzi.Add(int.Parse(line[i]));
            minDensirenzi = Math.Min(minDensirenzi, densirenzi[i]);
        }
        
        int minSum = minReizoko + minDensirenzi;
        for (int i=0;i<M;i++)
        {
            line = Console.ReadLine().Split(' ');
            int x = int.Parse(line[0])-1;
            int y = int.Parse(line[1])-1;
            int c = int.Parse(line[2]);
            minSum = Math.Min(minSum, reizoko[x]+densirenzi[y]-c);
        }
        Console.WriteLine(minSum);
    }
}


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

namespace ABC138C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = CIN.Int();
            int[] v = CIN.IntArray();
            
            Array.Sort(v);
            double ans = v[0];
            for (int i = 1; i < N; i++)
            {
                ans = (ans + v[i]) / 2;
            }
            Console.WriteLine(ans);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

using namespace std;

int main()
{

    int n,a=0,b=0,c=0,d=0;
    string s;
    cin>>n;
    while(n--){
        cin>>s;
        if(s=="AC"){
            a++;
        }
        else if(s=="WA"){
            b++;
        }
        else if(s=="TLE"){
            c++;
        }
        else{
            d++;
        }


    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;





    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
vi G[MAX_N];
ll A[MAX_N];
vector<ll> C[MAX_N];
bool used[MAX_N];

void loop(int v, int k) {
	used[v] = true;
	C[k].pb(A[v]);
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(!used[n]) loop(n, k);
	}
}

void solve() {
	cin >> N >> M;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}
	int K = 0;
	rep(i, 0, N) {
		if(used[i]) continue;
		loop(i, K++);
	}
	if(K == 1) {
		cout << 0 << "\n";
		return;
	}
	ll ans = 0;
	vector<ll> vec;
	rep(i, 0, K) {
		sort(all(C[i]));
		if(sz(C[i]) == 0) {
			cout << "Impossible\n";
			return;
		}
		ans += C[i][0];
		rep(j, 1, sz(C[i])) {
			vec.pb(C[i][j]);
		}
	}
	// debug(vec);
	if(sz(vec) < K - 2) {
		cout << "Impossible\n"; return;
	}
	else {
		sort(all(vec));
		cout << ans + accumulate(vec.begin(), vec.begin() + K - 2, 0LL) << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 16756
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
ps = m.times.map { gets.split }

ph = Array.new(n + 1) { 0 }
bh = Array.new(n + 1) { [] }

flag = false
ps.each do |e|
  p = e[0].to_i
  s = e[1].chomp
  bh[p].push s
end

count = 0

1.upto(n) do |i|
  flag = false
  p = 0
  bh[i].each do |s|
    break if flag

    if s == 'AC'
      count += 1
      flag = true
      ph[i] = p
    else
      p += 1
    end
  end
end

puts "#{count} #{ph.reduce(:+)}"


Measured memory_bytes: 25596
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = {{typeid(int), "%d"},
                                                      {typeid(ll), "%lld"},
                                                      {typeid(double), "%lf"},
                                                      {typeid(char), "%c"}};

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
  // INFILE();
  ll n;
  cin >> n;

  vector<vector<ll>> v(n);
  for (auto &val : v) {
    val.resize(2);
    scan(val);
  }
	ll a = v[0][0], b = v[0][1];

	for(const auto &val : v) {
		if (a <= val[0] && b <= val[1]) {
			a = val[0];
			b = val[1];
			continue;
		}

		ll m = max((a + val[0] - 1) / val[0], (b + val[1] - 1) / val[1]);
		a = val[0] * m;
		b = val[1] * m;
	}

	cout << a + b << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  auto tFormat = scanType[typeid(T)];
  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 256