akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll a,b,k;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>a>>b>>k;
    if(k<=a){
        cout<<a-k<<' '<<b<<endl;
        return 0;
    }
    if(k-a<=b){
        cout<<0<<' '<<b-(k-a)<<endl;
        return 0;
    }
    cout<<0<<' '<<0<<endl;

    return 0;
}

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

int main() {
  int K,S,ans=0;
  cin >> K >> S;
  for (int x=0; x<=K && x<=S; x++) {
    for (int y=0; y<=K && y<=S-x; y++) {
      if (S-x-y >=0 && S-x-y<= K) {
        ans++;
      }
    }
  }
  cout << ans << endl; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N,M;
	cin>>N>>M;
	vector<int> a(N+1);
	for(int i=0;i<M;i++){
		int j;
		cin>>j;
		a[j]++;
	}
	vector<long long> dp(N+1);
	dp[0]=1;
	for(int i=0;i<N;i++) {
		for(int j=i+1;j<=min(i+2,N);j++){
			if(a[j]==0) {
				dp[j]+=dp[i];
				dp[j]%=1000000007;
			}
		}
	}
	long long ans=dp[N];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
(let ((N (read))
      (M (read)))
     (loop for i below M with a and b do
           (setf a (1+ i))
           (setf b (- N i))
           (if (and (evenp N)
                    (<= (- b a) (/ N 2)))
               (decf b))
           (format t "~A ~A~%" a b)))

Measured memory_bytes: 24500
import sys
input = sys.stdin.readline
import random
import time
import copy
time0=time.time()

D=int(input())
C=[0]+list(map(int,input().split()))
S=[0]+[[0]+list(map(int,input().split())) for i in range(D)]

ANS=0
T=[0]
LAST=[0]*27
for day in range(1,D+1):
    SCORE=[-1<<30]*27
    for j in range(1,27):
        SC=0
        SC+=S[day][j]

        for k in range(1,27):
            if j==k:
                continue
            SC-=C[k]*(day-LAST[k])
        SCORE[j]=SC

    choose=SCORE.index(max(SCORE))
    T.append(choose)
    LAST[choose]=day

ANS=0
LAST=[[0]*27 for i in range(D+1)]
for day in range(1,D+1):
    for j in range(1,27):
        LAST[day][j]=LAST[day-1][j]
    t=T[day]
    ANS+=S[day][t]
    LAST[day][t]=day

    for j in range(1,27):
        ANS-=C[j]*(day-LAST[day][j])

MAX=ANS
MAXT=copy.deepcopy(T)
d=0
after_t=0

while time.time()-time0<1.77:
    BT=copy.deepcopy(T)
    BLAST=copy.deepcopy(LAST)
    BANS=ANS
    
    d=d%D+1
    after_t=after_t%26+1

    before_t=T[d]

    ANS+=S[d][after_t]-S[d][before_t]

    T[d]=after_t

    for day in range(d,D+1):
        if T[day]!=before_t:
            ANS+=C[before_t]*(day-LAST[day][before_t])
            LAST[day][before_t]=LAST[day-1][before_t]
            ANS-=C[before_t]*(day-LAST[day][before_t])
        else:
            break

    ANS+=C[after_t]*(d-LAST[d][after_t])
    LAST[d][after_t]=d

    for day in range(d+1,D+1):    
        if T[day]!=after_t:
            ANS+=C[after_t]*(day-LAST[day][after_t])
            LAST[day][after_t]=LAST[day-1][after_t]
            ANS-=C[after_t]*(day-LAST[day][after_t])

    if ANS*1000<MAX*999:
        T=BT
        LAST=BLAST
        ANS=BANS
    elif ANS>MAX:
        MAX=ANS
        MAXT=copy.deepcopy(T)

print(*MAXT[1:])


Measured memory_bytes: 179612
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, M;
    scan(N, M);
    long[] cnt = new long[](N);
    foreach (_; 0 .. M)
    {
        long a, b;
        scan(a, b);
        cnt[a - 1]++;
        cnt[b - 1]++;
    }
    foreach (c; cnt)
        writeln(c);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int x;
    cin >> x;
    if (x) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3548
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p1=[]
x1=[]
for i in range(m):
    p,x=map(int,input().split())
    p1.append(p)
    x1.append(x)
for i in range(m):
    print(sum(t)-t[p1[i]-1]+x1[i])
    

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<iomanip>
#include<algorithm>
using namespace std;

int main(){
	double st[80];
	string s;
	double x,y;
	int i=0,n=0;
	
	while(cin>>s){
		
		if(s=="+"){
			x=st[--i];
			y=st[--i];
			st[i] = y+x;++i;
		}
		else if(s=="*"){
			x=st[--i];
			y=st[--i];
			st[i] = y*x;++i;
		}
		else if(s=="-"){
			x=st[--i];
			y=st[--i];
			st[i] = y-x;++i;
		}
		else if(s=="/"){
			x=st[--i];
			y=st[--i];
			st[i] = y/x;++i;
		}else{
			st[i]=atoi(s.c_str());++i;
		}
	}
	
	while(n<i){
		cout<<setprecision(15)<<st[n]<<endl;
		++n;
	}
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a[3];
	cin >> a[0] >> a[1] >> a[2];
	REV(a[0]);REV(a[1]);REV(a[2]);
	char ans;
	char next = 'a';
	while(1){
		if(a[next-'a'].size()==0){
			ans = next;
			break;
		}
		int po = next - 'a';
		next = a[next-'a'][a[next-'a'].size()-1];
		a[po].pop_back();
	}
	ans += ('A'-'a');
	cout << ans << endl;
}

Measured memory_bytes: 256
object Main{
  def main(args:Array[String]) = {
    val list = scala.io.StdIn.readLine.split(" ").map(_.toLong).toList;
    val space = list(0) - 2
    val pattern = list(2) - list(1)
    if(list(2) - list(1) < 0){
      println(0)
    }else if(list(0) == 1){
      if(list(2) != list(1))
        println(0)
      else
        println(1)
    }else{
      println(pattern * space + 1)
    }
  }
}

Measured memory_bytes: 25536
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}
int gcdd(int a,int b, int c){
    int k=gcd(b,c);
    int r=gcd(a,k);
    return r;
}

int main()
{
    int k;
   cin>>k;
   long long int sum=0;
   for(int x=1;x<=k;x++){
        for(int y=1;y<=k;y++){
            for(int z=1;z<=k;z++){
                sum=sum+gcdd(x,y,z);
            }
        }

    }

   cout<<sum<<endl;
}



Measured memory_bytes: 3632
import sys

H, W = map(int, input().split())
C = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(10)]
A = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            if C[i][j] > C[i][k] + C[k][j]:
                C[i][j] = C[i][k] + C[k][j]

res = 0
for i in range(H):
    for j in range(W):
        if A[i][j] >= 0:
            res += C[A[i][j]][1]
print(res)


Measured memory_bytes: 9528
N, X = map(int, input().split())
cities = [int(i) for i in input().split()]
cities.sort()
dist = [int(abs(i-X)) for i in cities]
dist.sort()
 
if N==1:
    print(max(dist))
else:
    while len(dist)>0:
        m = min(dist)
        dist = [int(i%m) for i in dist]
        dist.sort()
        while len(dist)>0 and dist[0]==0:
            dist.remove(0)
        if len(dist)==0:
            break
        else:
            dist.append(m)
    print(m)

Measured memory_bytes: 14864
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 30 + 5;
const ll M = 1e9 + 7;
bool a[N][N];
ll dp[22][1 << 22];
int n;
int solve(int idx, int mask){
    if(idx == n){
        return 1;
    }
    if(dp[idx][mask] != -1)
        return dp[idx][mask];
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(((1 << i) & mask) || !a[idx][i])
            continue;
        ans += solve(idx + 1, mask | (1 << i));
        if(ans >= M) ans -= M;
    }
    return dp[idx][mask] = ans;
}
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> a[i][j];
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0);
return 0;
}


Measured memory_bytes: 721280
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) range(i,0,b)
#define rangei(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) rangei(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T>
ostream & operator << (ostream &os, tuple<T...> const &t){
    _ot<0>(os, t); return os;
}
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#define endl '\n'
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,l+n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;

int const inf = numeric_limits<int>::max();
template<class T>
struct SegmentTree {
    int n;
    vector<T> dat;
    SegmentTree(int n_ = 0) : n(n_){
        for(n = 1; n < n_; n <<= 1);
        dat.resize(n*2, inf);
    }
    T query(int v, int w, int l, int r){
        if(l >= r || w == 0) return inf;
        if(l + w == r) return dat[v];
        return min(query(v*2, w/2, l, min(r, w/2)),
                   query(v*2+1, w/2, max(0, l-w/2), r-w/2));
    }
    void update(int i, T x){
        dat[i+=n] = x;
        for(; i!=1; i/=2) dat[i/2] = min(dat[i], dat[i^1]);
    }
    T query(int l, int r){ return query(1,n,l,r); }
    size_t size() const { return n; }
};

int main(){
    fastios();
    int n, q;
    while(cin >> n >> q){
        SegmentTree<int> st(n);
        rep(i,q){
            char c;
            int x, y;
            cin >> c >> x >> y;
            if(c == '0'){
                st.update(x,y);
            } else {
                cout << st.query(x,y+1) << endl;
            }
        }
    }
}

Measured memory_bytes: 2052
n=int(input())
a=input()
b=input()
c=input()
s=0
for i in range(n):
    t=0
    if a[i]!=b[i]:
        t+=1
    if c[i]!=b[i]:
        t+=1
    if a[i]!=c[i]:
        t+=1
    if t:
        t-=1
    s+=t
print(s)

Measured memory_bytes: 3060
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    bool comp(pair<pair<string,int>,int> i,pair<pair<string,int>,int> j)
    {
        if(i.f.f!=j.f.f)
            return i.f.f<j.f.f;
        return i.f.s>j.f.s;
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            vector<pair<pair<string,int>,int> >v;
            string s;
            int x;
            for(i=0;i<n;++i)
            {
                cin>>s>>x;
                v.pb({{s,x},i+1});
            }
            sort(v.begin(),v.end(),comp);
            for(auto x:v)
                cout<<x.s<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
Q = int(input())

def check(x, a, b):
  y = (a <= -(-x // 2)) or (b <= -(-x // 2))
  z = (a <= (x // 2 + 1)) and (b <= (x // 2 + 1))
  return (-(-x // 2) + y) * ((x // 2 + 1) + z) < a * b

for _ in range(Q):
  a, b = map(int, input().split())

  ok = 0
  ng = a * b
  while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m, a, b): ok = m
    else: ng = m
  print(ok)

Measured memory_bytes: 40688
N,Q=map(int,input().split())
S=list(input())
S=[0]+S+[N+1]
TD=[list(input().split()) for _ in range(Q)]

def solve(place):
    if place == 0:
        return ('Left')
    elif place == N+1:
        return ('Right')
    for td in TD:
        char,to=td
        if S[place]!=char:continue

        if to=='L':place-=1
        elif to=='R':place+=1

        if place==0:
            return('Left')
        elif place==N+1:
            return('Right')
    return('Not Drop')

l,r=0,N+1
L,R=0,N+1

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Left':
        L=m
        l,r=m,r
    else:
        l,r=l,m

l,r=0,N+1

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Right':
        R=m
        l,r=l,m
    else:
        l,r=m,r

print(max(R-L-1,0))


Measured memory_bytes: 30200
'use strict'

function main(s) {

  const houses = s.split('\n')[1].split(' ').map(n => Number(n));
  const min = Math.min(...houses);
  const max = Math.max(...houses);

  const answer = max - min;
  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int main() {
    int N, ans = 0;

    cin >> N;

    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        ans += r-l+1;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n, s;
    while(cin >> n >> s, n+s){
        vector<int> r(n);
        for(int i = 0; i < n; i++)  cin >> r[i];
        sort(r.begin(), r.end());
        int ans = 0;
        for(int i = 0; i < n; i++){
            ans += (int)(r.end()-upper_bound(r.begin(), r.end(), s-r[i]));
            if(r[i]+r[i] > s)   ans--;
        }
        cout << ans/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
S = gets.chomp

for i in 0..S.length - 1
  if !((i + 1) % 2 == 1 && (S[i] == "R" || S[i] == "U" || S[i] == "D")) && !((i + 1) % 2 != 1 && (S[i] == "L" || S[i] == "U" || S[i] == "D"))
    puts "No"
    exit
  end
end

puts "Yes"


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

using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

const int MOD = int(1e6);
const int SIZE = 1010;

int64_t nCr(int64_t n, int64_t r) {
    if (r * 2 > n) r = n - r;
    int64_t numer = 1, denom = 1;
    for (int64_t i = 1; i <= r; ++i) {
        (numer *= (n - i + 1)) %= MOD;
        (denom *= i) %= MOD;
    }
    if (!numer && !denom) return 1;
    return numer / denom;
}

vector<bool> lose(SIZE);
vector<int64_t> dp(SIZE);
vector<int64_t> g[SIZE], num_children(SIZE);

void dfs(int node_idx) {

    dp[node_idx] = 1;

    if (g[node_idx].empty()) return;

    for (auto &elem : g[node_idx]) {

        dfs(elem);

        dp[node_idx] *= nCr(num_children[node_idx] + num_children[elem] + 1, num_children[elem] + 1);
        dp[node_idx] %= MOD;
        dp[node_idx] *= dp[elem];
        dp[node_idx] %= MOD;

        num_children[node_idx] += num_children[elem] + 1;
    }
}

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

    size_t N;
    cin >> N;

    for (size_t i = 0; i < N - 1; ++i) {
        int from, to;
        cin >> from >> to;
        from--, to--;
        g[from].emplace_back(to);
        lose[to] = true;
    }

    int root;
    for (size_t i = 0; i < N; ++i) {
        if (!lose[i]) {
            root = i;
            break;
        }
    }

    dfs(root);

    cout << dp[root] << "\n";

    return 0;
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
int a, b, c;
int n, m;
int main(){
	scanf("%d%d%d%d%d", &a, &b, &c, &n, &m);
	int ans = 2e9;
	rep(i, 0, 100001) {
		int nt = max(0, n - i), mt = max(0, m - i);
		ans = min(ans, i * c * 2 + nt * a + mt * b);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        string s,j;
        cin>>s>>j;
        ll ans=0;
        for(int i=0;i<s.length();i++){
            if(s[i]!=j[i])
                ans++;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a == 1) a += 13;
  if(b == 1) b += 13;
  if(a > b)
    cout << "Alice";
  else if(a < b)
    cout << "Bob";
  else
    cout << "Draw";
  cout << endl;
}


Measured memory_bytes: 256
import Data.List
import Control.Monad
import Data.Maybe
import Control.Arrow

main :: IO ()
main = do
  [n,k] <- rListM :: IO [Int]
  ls <- mapMaybe twl2tup <$> replicateM n rListM :: IO [(Int,Int)]
  let searched = find (\t -> snd t >= k) $ scanl1 (\(_,n') -> second (n' +)) (sort ls)
  let Just e = if isJust searched then searched else Just (0,0)
  print $ fst e

rListM :: Read a => IO [a]
rListM = fmap read . words <$> getLine

twl2tup :: [a] -> Maybe (a,a)
twl2tup [e1,e2] = Just (e1,e2)
twl2tup _ = Nothing


Measured memory_bytes: 99708
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define INF 20000000000000000
using ll = long long;

int coutdp[3][100001]={};

int main(){
    ll n;
    cin >> n;
    int a[3][100001];
    for(int i=1;i<=n;i++)    cin >> a[0][i] >> a[1][i] >> a[2][i];
    for(int i=0;i<3;i++)    coutdp[i][1] = a[i][1];
    for(int i=2;i<=n;i++){
        for(int j=0;j<3;j++){
            coutdp[j][i] = a[j][i] + max(coutdp[(j+1)%3][i-1],coutdp[(j+2)%3][i-1]);
        }
    }
    cout << max(max(coutdp[0][n],coutdp[1][n]),coutdp[2][n]) << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll N;
	cin >> N;
	vector<ll> A(N), X, S;
	REP(i, N)cin >> A[i];
	X = A;
	S = A;
	REP(i, N - 1)X[i + 1] ^= X[i];
	REP(i, N - 1)S[i + 1] += S[i];

	ll res = 0;
	REP(i, N) {
		ll l = i;
		ll r = N;
		while (r - l > 1) {
			ll mid = (l + r) / 2;
			ll dx = X[mid] ^ (i == 0 ? 0 : X[i - 1]);
			ll ds = S[mid] - (i == 0 ? 0 : S[i - 1]);
			if (dx == ds)l = mid;
			else r = mid;
		}
		res += l - i + 1;
	}
	cout << res << endl;

	return 0;
}


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

int main(){
  long n;
  cin >> n;
  double c = pow(n,0.5);
  long start = ceil(c);
  for(long i = start;i <= n;i--){
    if(n % i == 0){
      cout << floor(log10(n/i)) + 1 << endl;
      break;
    }
  }
}

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

int main(){
	int a, b, c, ans1=0, ans2=0;

	while( scanf("%d,%d,%d", &a,&b,&c) != EOF ){
		if( a*a + b*b == c*c ) ans1++;
		else if( a == b ) ans2++;
	}
	printf("%d\n%d\n", ans1, ans2);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    string S;
    cin >> S;
    i32 ans = 0;

    if (S =="SAT") ans = 1;
    else if (S == "FRI") ans = 2;
    else if (S == "THU") ans = 3;
    else if (S == "WED") ans = 4;
    else if (S == "TUE") ans = 5;
    else if (S == "MON") ans = 6;
    else if (S == "SUN") ans = 7;
    cout << ans << endl;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int &i: h)
        cin>>i;
    vector<int> dp(n,MOD);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        if(i+j<n)
            dp[i+j]=min(dp[i]+abs(h[i+j]-h[i]),dp[i+j]);
    }
    cout<<dp[n-1]<<endl;
    return 0;


    return 0;
}


Measured memory_bytes: 3956
long a[400],p[1<<16],s[1<<16];i,I;main(n){for(scanf("%d",&n);I<1<<n;I++){for(i=0;i<n*n;i++)I||scanf("%ld",a+i),s[I]+=I&1<<i/n&&I&1<<i%n?a[i]:0;for(i=I;i;i&=I)p[I]=fmax(p[I],p[I&~i]+s[i--]/2);}printf("%ld",p[I-1]);}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	int a, b,ans;
	cin >> a >> b;
	ans = max(a+b,a-b);
	ans = max(ans, a * b);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstring>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,a,b) for(int i=(a);i<=(b);i++)
#define P pair<int,int>
using namespace std;

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

int h,w;
int a[1002][1002];
string s[1002];

int main()
{
	cin>>h>>w;
	rep(i,h)cin>>s[i];
	vector<P> f[2];
	int now=0,pre=1,ans=0;
	bool flag;
	rrep(i,1,h-2)
	{
		rrep(j,1,w-2)
		{
			rep(k,8)if(s[i+dx[k]][j+dy[k]]=='.')a[i][j]++;
			if(s[i][j]!='.'&&s[i][j]-'0'<=a[i][j])f[now].pb(mp(i,j));
		}
	}
	while(1)
	{
		flag=false;
		now=!now;
		pre=!pre;
		f[now].clear();
		rep(i,f[pre].size())
		{
			P p=f[pre][i];
			if(s[p.fi][p.se]!='.'&&s[p.fi][p.se]-'0'<=a[p.fi][p.se])
			{
				flag=true;
				s[p.fi][p.se]='.';
				rep(j,8)
				{
					int tx=p.fi+dx[j];
					int ty=p.se+dy[j];
					if(tx<=0||tx>=h-1||ty<=0||ty>=w-1)continue;
					a[tx][ty]++;
					if(s[tx][ty]!='.'&&s[tx][ty]-'0'==a[tx][ty])f[now].pb(mp(tx,ty));
				}
			}
		}
		if(flag)ans++;
		else break;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

int main() {
	int n;
	while(cin >> n, n) {
		int w, h;
		cin >> w >> h;
		int sum[100][100] = {};
		rep(i, n) {
			int x, y;
			cin >> x >> y;
			sum[x-1][y-1] = 1;
		}
		int s, t;
		cin >> s >> t;

		for(int y=h-2; y>=0; y--) {
			sum[w-1][y] += sum[w-1][y+1];
		}
		for(int x=w-2; x>=0; x--) {
			sum[x][h-1] += sum[x+1][h-1];
		}

		for(int y=h-2; y>=0; y--) {
			for(int x=w-2; x>=0; x--) {
				sum[x][y] = sum[x+1][y] + sum[x][y+1] - sum[x+1][y+1] + sum[x][y];
			}
		}
		rep(y, h+1) sum[w][y] = 0;
		rep(x, w+1) sum[x][h] = 0;

		int maxi = 0;
		for(int y=0; y<=h-t; y++) {
			for(int x=0; x<=w-s; x++) {
				maxi = max( maxi, sum[x][y]-sum[x+s][y]-sum[x][y+t]+sum[x+s][y+t] );
			}
		}
		cout << maxi << endl;
	}
	return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll wf[51][51];
int n;
int a[50], b[50];

void floyd_warshall(set<int> st){
    fill((ll *)wf[0], (ll *)wf[51], LLONG_MAX);

    for(int k: st){
        repp(n, 51){
            wf[n][n%k] = 1LL;
        }
    }

    repp(k, 51){
        repp(i, 51){
            repp(j, 51){
                wf[i][j] = min(wf[i][j], (wf[i][k]|wf[k][j]));
            }
        }
    }
}

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

    cin >> n;
    rep(n) cin >> a[i];
    rep(n) cin >> b[i];

    int same = 1, max_a = -1, max_b = -1;
    rep(n){
        if(a[i] != b[i]) same = 0;
        max_a = max(max_a, a[i]);
        max_b = max(max_b, b[i]);
    }

    /* 操作の必要なし */
    if(same){
        cout << 0 << endl;
        return 0;
    }
    /* bの要素がすべて0 (=1で剰余とっておしまい) */
    if(max_b == 0){
        cout << 2 << endl;
        return 0;
    }

    set<int> st;
    reppp(i, 1, 51) st.insert(i);
    
    int use = 0;
    ll ans = 0LL;
    floyd_warshall(st);
    rep(n){
        if(wf[a[i]][b[i]] == LLONG_MAX){
            use = 1;
            break;
        }
    }
    if(use){
        cout << -1 << endl;
        return 0;
    }

    for(int l=50;l>=1;l--){
        int use = 0;
        st.erase(l);
        floyd_warshall(st);
        rep(n){
            if(wf[a[i]][b[i]] == LLONG_MAX){
                use = 1;
                break;
            }
        }
        if(use){
            ans |= 1LL << l;
            st.insert(l);
        }
    }

    cout << (ans?ans:-1) << endl;
}


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

int main() {
  int N;
  string S;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == "Y"){
      cout << "Four" << endl;
    break;
    }
    else{
      if(i == N - 1)
        cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256
w,h,n = map(int,input().split())
d = [0,w,0,h]
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1 :
        d[0] = max(d[0],x)
    elif a == 2:
        d[1] = min(d[1],x)
    elif a == 3:
        d[2] = max(d[2],y)
    else:
        d[3] = min(d[3],y)
print(max(0,(d[1]-d[0]))*max(0,(d[3]-d[2])))

Measured memory_bytes: 3064
fun main(args: Array<String>) = agc043a()

fun agc043a() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val board = Array(h) { readLine()!!.map { it == '.' } }

    val dp = Array(h) { IntArray(w) { Int.MAX_VALUE / 100 } }
    dp[0][0] = if (board[0][0]) 0 else 1

    for (y in 0 until h) {
        for (x in 0 until w) {
            around.map { Pos(it.first + y, it.second + x) }
                .filter { it.y in 0 until h && it.x in 0 until w }
                .forEach {
                    val border = if (board[y][x] == board[it.y][it.x]) 0 else 1
                    dp[it.y][it.x] = Math.min(dp[it.y][it.x], dp[y][x] + border)
                }
        }
    }

    val answer = Math.ceil(dp.last().last().toDouble() / 2).toInt()

    println(answer)
}

private val around = listOf(1 to 0, 0 to 1)

private data class Pos(val y: Int, val x: Int)


Measured memory_bytes: 43084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  
  cout <<(c+max(a,b)-1)/max(a,b) << endl;
  
}

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
vector<ll> v[100009];
ll vis[100009];
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    queue<ll> q;
    q.push(1);
    memset(vis,-1,sizeof vis);
    vis[1] = 0;
    while(!q.empty())
    {
        ll temp = q.front();
        q.pop();
        for(ll i=0;i<v[temp].size();i++)
        {
            if(vis[v[temp][i]]==-1)
            {
                q.push(v[temp][i]);
                vis[v[temp][i]] = temp;
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        if(vis[i]==-1)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(i=2;i<=n;i++)
        cout<<vis[i]<<endl;
    cout<<endl;
    return 0;
}



Measured memory_bytes: 13068
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  ll N,K,X;
  cin>>N>>K>>X;
  ll ans=(N+K)*X/2;


  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using    namespace std;
#define  ll        long long
#define  pb        push_back
#define  ff        first
#define  ss        second
#define  mk        make_pair
#define  all(v)    v.begin(),v.end()
#define  allr(v)   v.rbegin(),v.rend()
#define  sz        size()
#define  Tanmoy    ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0)

const int MOD=1e9+7;
/*
for(ll i=0; i<n; i++)      **I Want To Be The Best**
for(ll i=n-1; i>=0; i--)
*/

int main()
{
     Tanmoy;

     ll n,r=0,ans=0; cin>>n;
     string s; cin>>s;

     bool ok=false;
     for(ll i=0; i<n; i++){

        if(s[i]=='R')r++;
     }

     for(ll i=0; i<r; i++){
        if(s[i]=='W')ans++;
     }

     cout<<ans;

  return 0;
}






Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#define pii pair<int,int>
#define pb push_back
using namespace std;


int main(){
  int a,b;
  cin>>a>>b;

  int x=b-a-1;
  //cout<<x<<endl;
  cout<<x*(x+1)/2 - a<<endl;
  return 0;
}



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

int main() {
   int n;
   cin >> n;
   string s;
   cin >> s;
   vector<int> left(n+1);
   vector<int> right(n+1);

   for (int i=0; i<n; i++) {
      left[i+1]=( left[i] | (1<<(s[i]-'a')) );  
      right[n-i-1]=( right[n-i] | (1<<(s[n-i-1]-'a')) );
   }
   int ans=0;
   for (int i=0; i<n; i++) {
      int x=left[i] & right[i];
      ans=max(ans,__builtin_popcount(x));
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 101;

int b[N];

int main()
{
	fio;
	int n;
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> b[i];
	vector<int> ans;
	int sz = n;
	for(int c=0; c<n; c++)
	{
		int x = -1;
		for(int i=1; i<=sz; i++)
			if(b[i] == i)
				x = i;
		if(x == -1)
			break;
		ans.pb(x);
		for(int i=x; i<sz; i++)
			b[i] = b[i+1];
		sz--;
	}
	if(ans.size() == n)
	{
		reverse(ans.begin(), ans.end());
		for(int it : ans)
			cout << it << endl;
	}
	else
		cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int p=0;//パーの残弾

int main(){
    string s;
    cin >> s;
    int n=s.size();
    int ans=0;
    rep(i,n){
        if(s[i]=='g'){
            if(p>0){
                p--;
                ans++;
            }else{
                p++;
            }
        }else{
            if(p>0){
                p--;
            }else{
                p++;
                ans--;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
h, w = list(map(int, input().split()))
s = [list(input()) for i in range(h)]
ss = [["." for i in range(w+2)] for j in range(h+2)]

for i in range(h):
    for j in range(w):
        ss[i+1][j+1]=s[i][j]

flag = 1

for i in range(h):
    for j in range(w):
        if ss[i+1][j+1]=="#":
            if ss[i][j+1]=="." and ss[i+2][j+1]=="." and ss[i+1][j]=="." and ss[i+1][j+2]==".":
                flag = 0
                break
                
if flag==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u64 = read();
    let mut h: i64 = read();
    let mut ai: Vec<u64> = Vec::new();
    let mut bi: Vec<u64> = Vec::new();

    for _ in 0..n {
        ai.push(read());
        bi.push(read());
    }
    bi.sort();
    bi.reverse();

    let (_, &a_max) = ai.iter().enumerate().max_by_key(|&(_, &a)| a).unwrap();

    let mut ans: u64 = 0;
    for b in bi {
        if b > a_max {
            ans += 1;
            h -= b as i64;
        }
        if h <= 0 {
            break;
        }
    }
    if h > 0 {
        ans += h as u64 / a_max + 1;
        if h as u64 % a_max == 0 {
            ans -= 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
s,e = map(int,input().split())
count=0

for n in range(s,e+1):
    s=str(n)
    frag=0
    for m in range(len(s)//2): 
        if s[m]!=s[-m-1]:
            frag=1
    if frag==0:
        count+=1

print(count)

Measured memory_bytes: 3060
#!/usr/bin/env python

def main():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    A = [[] for _ in range(N)]
    for i in range(N):
        A[i] = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        tmp = 0
        for j in range(M):
            tmp += A[i][j] * B[j]
        if tmp + C > 0:
            ans += 1

    return ans

if __name__ == '__main__':
    print(main())



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

int main() {
  int tm[3];
  for (int i = 0; i < 3; i++) {
    cin >> tm[i];
  }
  sort(tm, tm + 3);

  cout << tm[0] + tm[1] << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int x, n, a, mi = 9999, ans;
	scanf("%d %d", &x, &n);
	bool b[102];
	fill(b, b + 102, false);
	for (int i = 0; i < n; i++){
		scanf("%d", &a);
		b[a] = true;
	}
	for (int i = 0; i <= 101; i++){
		if (b[i]) continue;
		if (abs(x - i) < mi){
			mi = abs(x - i);
			ans = i;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
	
}



Measured memory_bytes: 256
N=int(input())
s=[]
for _ in range(N):
    s.append(int(input()))

s=sorted(s)
import sys
if sum(s)%10!=0:
    print(sum(s))
    sys.exit()
else:
    ans=sum(s)
    for i in range(len(s)):
        if s[i]%10==0:
            pass
        else:
            ans-=s[i]
            print(ans)
            sys.exit()
print(0)
        

Measured memory_bytes: 3060
def make_factorial_table(n):
    result = [0] * (n + 1)
    result[0] = 1
    for i in range(1, n + 1):
        result[i] = result[i - 1] * i % m
    return result


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


m = 1000000007

S = int(input())

fac = make_factorial_table(S + 10)

result = 0
for i in range(1, S // 3 + 1):
    result += mcomb(S - i * 3 + i - 1, i - 1)
    result %= m
print(result)


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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;
map<pa,int>mp;
const int N=2e5+100;
int n,m;
int a[2000],b[2000],c[2000];
int path[202][202];
void floyd()
{
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                path[i][j]=min(path[i][j],path[i][k]+path[k][j]);
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) path[i][j]=0;
            else path[i][j]=1e9;
        }
    }
    for(int i=1;i<=m;i++){
        cin>>a[i]>>b[i]>>c[i];
        path[a[i]][b[i]]=path[b[i]][a[i]]=c[i];
    }
    floyd();
    int ans=0;
    for(int i=1;i<=m;i++){
        int f=1;
        for(int j=1;j<=n;j++){
            if(path[j][a[i]]+c[i]==path[j][b[i]]){
                f=0;
            }
        }
        if(f) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3680