akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
 
int main() {
    char a[25], i;
    scanf("%s", &a);
    for(i=strlen(a)-1;i>=0;i--){
       printf("%c", a[i]);                         
                             
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 1096
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>n;
    if(n%2==0) cout<<n<<endl;
    else cout<<n*2<<endl;
    return 0;
}


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

int main() {
    int64_t N,K;
    cin >> N >> K;
    vector<int64_t> A(N);
    for ( int64_t i = 0; i < N; ++i){
        int64_t a;
        cin >> a;
        --a;
        A[i] = a;
    }
    
    vector<int64_t> reached(N,-1);
    int64_t pos = 0;
    reached[0] = 0;
    int64_t roop = 0;
    int64_t rooppos = -1;
    for ( int64_t i = 1; i <= 2*N; ++i){
        int64_t nextpos = A[pos];
        if ( reached[nextpos] != -1 ){
            roop = i - reached[nextpos];
            rooppos = nextpos;
            break;
        }
        reached[nextpos] = i;
        pos = nextpos;
    }
    
    //cout << "roop" << roop << endl;
    
    int64_t b;
    if ( K > 2*N ){
        b = ( K - 2*N ) % roop;
        K = b + 2*N;
    }
    
    pos = 0;
    for ( int64_t i = 1; i <= K; ++i){
        pos = A[pos];
    }
    
    cout << pos+1 << endl;
    
    
    return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N,M; cin >> N >> M;
    vector <P> A(M);
    rep(i,M) cin >> A[i].first >> A[i].second;
    A.erase(unique(A.begin(),A.end()),A.end());
    
    vector <int> C(N+1,0);
    for (int i=0; i<A.size(); i++){
        if (A[i].first==1) C[A[i].second]++;
        if (A[i].second==N) C[A[i].first]++;
    }
    
    for (int i=1; i<=N; i++){
        if (C[i]==2){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }

    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }

    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

template <typename T>
T MODpow(T x, T n, T MOD = 1000000007) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

Mint<> C(int n, int k) {
    Mint<> res = 1;
    for(int i = 0; i < k; i++){
        res *= n - i;
    }
    for(int i = 1; i <= k; i++){
        res /= i;
    }
    return res;
}

signed main(){
    ll n;
    int a,b;
    cin >> n >> a >> b;
    cout << Mint<>(2).pow(n) - Mint<>(1) - C(n, a) - C(n, b) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i+1, N):
        if L[i] == L[j]:
            continue
        for k in range(j+1, N):
            if L[i] == L[k] or L[j] == L[k]:
                continue
            if L[i] < L[j] + L[k] and L[j] < L[i] + L[k] and L[k] < L[j] + L[i]:
                ans += 1
print(ans)

Measured memory_bytes: 68184
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 1000005
//<<fixed << setprecision(9)

void err(int x)
{
    if(x) cout<<"setwise coprime";
    else cout<<"not coprime";
    exit(0);
}
int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int arr[n];
    rep(i,0,n)
    {
        cin>>arr[i];
    }

    bool f=0;
    int g=arr[0];
    rep(i,1,n) g=__gcd(arr[i],g);
    if(g==1) f=1;

    bool seen[space]={0};
    for(i=n-1;i>=0;i--)
    {
        for(j=2;j*j<=arr[i];j++)
        {
            if(arr[i]%j==0)
            {
                if(seen[j]) err(f);
                seen[j]=1;
                while(arr[i]%j==0) arr[i]/=j;
            }
        }
        if(arr[i]!=1)
        {
            if(seen[arr[i]]) err(f);
            seen[arr[i]]=1;
        }
    }
    cout<<"pairwise coprime";

    return 0;
}

Measured memory_bytes: 8448
n,k=map(int,input().split())
ok=False
for x in range(n+1):
    for y in range(n-x+1):
        z=n-x-y
        if z<0:
            break
        if 10000*x+5000*y+1000*z==k:
            print("{} {} {}".format(x,y,z))
            exit()

print("{} {} {}".format(-1,-1,-1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef pair<int,int> P;
int H,W,K;
string s[800];
int d[800][800];
int inf = 1e8;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
bool is(int x,int y){
	return 0<=x&&x<H&&0<=y&&y<W&&s[x][y]!='#';
}
int main(){
	cin>>H>>W>>K;
	rep(i,H) cin>>s[i];
	int sx=-1,sy=-1;
	rep(i,H) rep(j,W) if(s[i][j]=='S') sx=i,sy=j;
	rep(i,H) rep(j,W) d[i][j]=inf;
	d[sx][sy]=0;
	queue<P> que;
	que.push(P(sx,sy));
	while(!que.empty()){
		P p = que.front();que.pop();
		int x = p.fs, y = p.sc;
		rep(di,4){
			int nx = x+dx[di], ny = y+dy[di];
			if(is(nx,ny)&&d[nx][ny]==inf){
				d[nx][ny]=d[x][y]+1;
				que.push(P(nx,ny));
			}
		}
	}
	int ans = inf;
	rep(i,H) rep(j,W) if(d[i][j]<=K){
		int dis = inf;
		chmin(dis,i);
		chmin(dis,H-1-i);
		chmin(dis,j);
		chmin(dis,W-1-j);
		chmin(ans,1+(dis+K-1)/K);
	}
	cout<<ans<<endl;
}


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

typedef pair<long long,long long> P;

int main(){
    long long N; cin >> N;
    long long divisor;

    for(long long i = 1;i*i <= N;i++){
        if(N % i != 0) continue;
        divisor = i;
    }
    long long ans = (N/divisor-1) + (divisor - 1);
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

var jobs [][]int

func main() {
	N, M := ReadInt(), ReadInt()

	m := make(map[int][]int)
	jobs = make([][]int, N)
	for i := 0; i < N; i++ {
		a, b := ReadInt(), ReadInt()
		jobs[i] = []int{a, b}
		m[a] = append(m[a], i)
	}

	ans := 0
	heapq := Heap{}
	for i := 1; i <= M; i++ {
		for _, job := range m[i] {
			heapq.push(job)
		}
		if len(heapq) > 0 {
			j := heapq.pop()
			ans += jobs[j][1]
		}
	}
	fmt.Println(ans)
}

type HeapElement = int
type Heap []HeapElement

func (h Heap) Less(i, j int) bool    { return jobs[h[i]][1] > jobs[h[j]][1] }
func (h Heap) Len() int              { return len(h) }
func (h Heap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *Heap) Push(x interface{})   { *h = append(*h, x.(HeapElement)) }
func (h *Heap) Pop() (x interface{}) { *h, x = (*h)[:len(*h)-1], (*h)[len(*h)-1]; return }
func (h *Heap) push(v HeapElement)   { heap.Push(h, v) }
func (h *Heap) pop() HeapElement     { return heap.Pop(h).(HeapElement) }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 17876
package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	ans := 0
	sc.Scan()
	input := sc.Text()
	for _, char := range input{
		if char-'0' == 1{
			ans++
		}
	}
	fmt.Println(ans)
}

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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 10000000
int main()
{
    int h,w;
    cin >> h >> w;
    Graf c(10,vector<int>(10));
    Graf a(h,vector<int>(w));
    Graf dj(10,vector<int>(10));
    vector<bool> flag(10);
    vector<int> count(10,0);
    rep(i,10){
        rep(j,10){
            cin >> c[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    rep(i,10){
        rep(j,10){
            dj[i][j]=MAX;

        }
    }

    FOR(i,10,0){
        rep(j,10){
            flag[j]=false;
        }
        int min_val=0;
        int min_j=i;
        flag[i]=true;
        if(i!=1)
            dj[i][i]=MAX;
        else{
            dj[i][i]=0;
        }
        while(!flag[1]){
            
            rep(l,10){
                if(flag[l]==false){
                    dj[i][l]=min(dj[i][l],c[min_j][l]+min_val);
                }
            }
            int tmp_min=MAX;
            int tmp_j;
            rep(l,10){
                if(!flag[l])
                    if(tmp_min>dj[i][l]){
                        tmp_min=dj[i][l];
                        tmp_j=l;                    
                    }
                
            }

            min_val=tmp_min;
            min_j=tmp_j;
            flag[min_j]=true;
        }
    }

    rep(i,h){
        rep(j,w){
            if(a[i][j]!=-1){
                count[a[i][j]]++;
            }
        }
    }
    int ans=0;
    rep(i,10){
        ans+=count[i]*dj[i][1];
    }
    cout << ans << endl;
}

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

int main()
{
    int n, a[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a, a + n);
    a[n] = 1 << 30;

    int t = a[0], ans = 0, cnt = 0;
    for (int i = 0; i < n + 1; i++) {
        if (a[i] == t) {
            cnt ++;
        }
        else {
            if (cnt < t) {
                ans += cnt;
            }
            else if (cnt > t) {
                ans += cnt - t;
            }
            cnt = 1;
            t = a[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;


#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, l;
	string s;
	vector<string> alls;

	cin >> n >> l;

	for (int i = 0; i < n; ++i) {
		cin >> s;
		alls.push_back(s);
	}
	

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

	for (std::vector<string>::iterator i = alls.begin(); i != alls.end(); ++i) {
		cout << *i;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char dn[1400000], * di = dn;
int keta1 = 1, keta2;
char C1[10] = { '1', '0', '0', '0', '0', '0' };
char C2[10] = { '0', '0', '0', '0', '0', '0' };

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


	int N, M;
	scanf("%d %d", &N, &M);

	if (N % 2) {
		int n = N - 1;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}

		rep1(i, M) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (keta1 <= tmp) keta1 = tmp + 1;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}
	else {
		int n = N;
		keta2 = 0;
		while (n) {
			*(C2 + keta2) = '0' + n % 10;
			n /= 10;
			keta2++;
		}
		rep1(i, (M + 1) / 2) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (keta1 <= tmp) keta1 = tmp + 1;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
		C2[0]--;
		int tmp = 0;
		while (C2[tmp] < '0') {
			C2[tmp++] += 10;
			C2[tmp]--;
			if (C2[keta2 - 1] == '0') keta2--;
		}
		for (int i = (M + 1) / 2 + 1; i <= M; i++) {
			for (int i = keta1 - 1; i >= 0; i--)* di++ = (*(C1 + i));
			*di++ = ' ';
			for (int i = keta2 - 1; i >= 0; i--)* di++ = (*(C2 + i));
			*di++ = '\n';

			C1[0]++;
			int tmp = 0;
			while (C1[tmp] > '9') {
				C1[tmp++] -= 10;
				C1[tmp]++;
				if (keta1 <= tmp) keta1 = tmp + 1;
			}
			C2[0]--;
			tmp = 0;
			while (C2[tmp] < '0') {
				C2[tmp++] += 10;
				C2[tmp]--;
				if (C2[keta2 - 1] == '0') keta2--;
			}
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 2732
#include <stdio.h>
#include <string.h>

int main(){
  char S[12],T[12],U[12];
  int A,B;
  
  scanf("%s %s\n",S,T);
  scanf("%d %d\n",&A,&B);
  scanf("%s",U);
  
  if(strcmp(S,U)==0) A--;
  if(strcmp(T,U)==0) B--;
  
  printf("%d %d\n",A,B);
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
  
#define MAX 1000
#define N 100
  
int G[MAX][MAX];
int d[MAX],Q[N];
int n;
int max=0;
int min=0;
  
void en(int q){
  Q[max] = q;
  max++;
}
  
int de(){
  min++;
  return Q[min-1];
}
  
int size(){
  return max-min;
}
  
void bfs(int i){
  int a;
  for(a = 0; a < n; a++){
    if(G[i][a] == 1 && d[a] == -1){
      d[a] = d[i]+1;
      en(a);
    }
  }
}
  
int main(){
  int i,j,u,k,c;
  
  scanf("%d",&n);
  
  for(i=0;i<MAX;i++){
    d[i]=-1;
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      G[u-1][c-1]=1;
    }
  }
  d[0]=0;
  bfs(0);
  
  while(size()!=0){
    bfs(de());
  }
  
  for(i=0;i<n;i++){
    printf("%d ",i+1);
    printf("%d\n",d[i]);
  }
  
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string A[105];
string B[105];

int main() {
    ll N, M;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    cin >> M;
    REP(i, M) {
        cin >> B[i];
    }

    ll ans = 0;
    REP(i, N) {
        ll s = 0;
        REP(j, N) {
            if (A[i] == A[j])
                s++;
        }
        REP(j, M) {
            if (B[j] == A[i])
                s--;
        }
        ans = std::max(ans, s);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>
#include <cstring>
#include <set>
#include <map>

#define rep(i, l, r) for(int i=l; i<=r; i++)
#define dow(i, l, r) for(int i=l; i>=r; i--)
#define clr(x, c) memset(x, c, sizeof(x))
#define travel(x) for(edge *p=fir[x]; p; p=p->n)
#define all(x) (x).begin,(x).end
#define pb push_back
#define fi first
#define se second
#define l(x) Left[x]
#define r(x) Right[x]
#define lowbit(x) (x&-x)
#define pi acos(-1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

inline int read()
{
    int x=0; bool f=0; char ch=getchar();
    while (ch<'0' || '9'<ch) f|=ch=='-', ch=getchar();
    while ('0'<=ch && ch<='9') x=x*10+ch-'0', ch=getchar();
    return f?-x:x;
}

#define maxn 200009

ll k[maxn], A; int n, K, a[maxn];
struct node{ll x; int y;} q[maxn];
bool cmp(node a, node b){return a.x<b.x || (a.x==b.x && a.y<b.y);}

inline void Que(int x)
{
	while (x) A+=a[x], x-=lowbit(x);
}

inline void Add(int x)
{
	while (x<=n+1) a[x]++, x+=lowbit(x);
}

int main()
{
	n=read(), K=read();
	rep(i, 1, n) k[i]=read()-K;
	rep(i, 1, n) k[i]+=k[i-1];
	rep(i, 0, n) q[i].x=k[i], q[i].y=i+1; sort(q, q+1+n, cmp);
	rep(i, 0, n) Que(q[i].y-1), Add(q[i].y);
	printf("%lld\n", A);
	return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();

        int red = 0;
        int blue = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 'R') {
                red++;
            }  else {
                blue++;
            }
        }
        System.out.println(red > blue ? "Yes" : "No");
    }
}


Measured memory_bytes: 23124
M=10**9+7
r1,c1,r2,c2=map(int,input().split())
n=r2+c2+2
fac=[0]*(n+1)
fac[0]=val=1
for i in range(1,n+1):fac[i]=val=val*i%M
pr1=pow(fac[r1],M-2,M)
pc1=pow(fac[c1],M-2,M)
pr2=pow(fac[r2+1],M-2,M)
pc2=pow(fac[c2+1],M-2,M)
a=fac[r2+c2+2]*pr2*pc2
a-=fac[r2+c1+1]*pr2*pc1
a-=fac[r1+c2+1]*pr1*pc2
a+=fac[r1+c1]*pr1*pc1
print(a%M)

Measured memory_bytes: 55660
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(MI())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n = I()
    a1 = LI()
    a2 = LI()

    max = 0
    for i in range(n):
        candy = sum(a1[0 : i + 1]) + sum(a2[i:n])
        if candy > max:
            max = candy
    print(max)
    pass


if __name__ == "__main__":
    main()



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    string a, b, c;
    char turn = 'a';
    cin >> a >> b >> c;
    while (1) {
        if (turn == 'a') {
            if (a.empty()) {
                cout << "A" << endl;
                break;
            }
            turn = a.front();
            a = a.substr(1, a.size() - 1);
        }
        else if (turn == 'b') {
            if (b.empty()) {
                cout << "B" << endl;
                break;
            }
            turn = b.front();
            b = b.substr(1, b.size() - 1);
        }
        else {
            if (c.empty()) {
                cout << "C" << endl;
                break;
            }
            turn = c.front();
            c = c.substr(1, c.size() - 1);
        }
    }
    return 0;
}

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

int main(void)
{
    ll N, K; scanf("%lld%lld", &N, &K);
    if (N == K)
    {
        puts("0");
        return 0;
    }
    if (N > K)
    {
        ll t1 = N % K;
        ll t2 = K - t1;
        printf("%lld\n", min(t1, t2));
        return 0;
    }
    ll t1 = N;
    ll t2 = K - N;
    printf("%lld\n", min(t1, t2));
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <set>
#include <queue>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define pb(x) push_back(x)
typedef long long LL;
typedef unsigned long long ull;
const int mod=1e9+7;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=2e4+5;
int main()
{
    int T,x;
    while(~scanf("%d%d",&T,&x))
    {
        if(x>=T) puts("0");
        else printf("%d\n",T-x);
    }
    return 0;
}


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

int main(){
  int n,l,ans,appleSUM,absMIN;
  cin >> n >> l;
  ans = 0; appleSUM = 0; absMIN = 101;
  vector<int> appleP(n);
  for(int i = 0;i < n;i++){
    appleP.at(i) = l+i;
    appleSUM += appleP.at(i);
  }

  for(int j = 0; j < n;j++){
    if(absMIN > abs(appleP.at(j))){
      absMIN = abs(appleP.at(j));
      ans = appleP.at(j);
    }
   }
   ans = appleSUM - ans;  
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();


		System.out.println(n < m ? 0 : 10);
	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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

struct PointM
{
    int x;
    int y;
    bool operator < (const PointM& b) const {
        if(x != b.x) return x < b.x;
        else return y < b.y;
    }
};

int main(void)
{
    int H, W, N;

    cin >> H >> W >> N;

    map<PointM, int> m{};

    for(int i = 0; i < N; ++i)
    {
        int a, b;
        cin >> a >> b;

        for(int p = 0; p < 3; ++p)
        {
            for(int q = 0; q < 3; ++q)
            {
                if(a-p > 0 && b-q > 0 && a-p+2 <= H && b-q+2 <= W )
                {
                    PointM TP;
                    TP.x = a-p;
                    TP.y = b-q;
                    ++m[TP];
                }
            }
        }
    }

    vector<unsigned long long int> ans(10,0);

    ans[0] = (unsigned long long int)(H-2)*(unsigned long long int)(W-2);
    for (auto iter = m.begin(); iter != m.end(); iter++) 
    {
        ++ans[iter->second];
        --ans[0];
    }

    for(int i = 0; i < 10; ++i)
    {
        cout << ans[i] << endl;
    }

    return 0;
}



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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/
int n;
string s[200];

int col[200];
bool ok;

void dfs(int v, int c){
  if(col[v] != -1){
    if(col[v] != c){
      ok = false;
    }
    return;
  }
  col[v] = c;

  rep(i, 0, n){
    if(s[v][i] == '1'){
      dfs(i, (c+1)%2);
    }
  }
}

signed main(){
  cin >> n;
  rep(i, 0, n) cin >> s[i];

  ok = true;
  memset(col, -1, sizeof(col));
  dfs(0, 0);
  if(!ok){
    cout << -1 << endl;
    return 0;
  }

  vvi d(n, vi(n, inf));
  rep(i, 0, n) rep(j, 0, n){
    if(i == j) d[i][j] = 0;
    else if(s[i][j] == '1'){
      d[i][j] = 1;
    }
  }

  rep(k, 0, n) rep(i, 0, n) rep(j, 0, n){
    chmin(d[i][j], d[i][k] + d[k][j]);
  }

  int ans = 0;
  rep(i, 0, n) rep(j, 0, n){
    chmax(ans, d[i][j]);
  }
  
  cout << ans+1 << endl;

  return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        int count = 0;
        for(int i=0; i<s.length()-2; i++) {
            String ss = s.substring(i, i+3);
            if("ABC".equals(ss)) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
vector<ll> V;
ll pre[maxn];
int main() {
    int k,n;cin>>k>>n;
    for(int i=1;i<=n;i++) cin>>pre[i];
    ll ans=k-(pre[1]-pre[n]+k)%k;
    for(int i=2;i<=n;i++){
        ans=min(k-(pre[i]-pre[i-1]),ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

char s[100001];
char t[100001];
int a[100001];
int b[100001];
int main(void){
	int m=nextstr(s);
	int n=nextstr(t);
	int q=nextint();
	for(int i=0; i<m; i++){
		a[i+1]=a[i]+s[i]-64;
	}
	for(int i=0; i<m; i++){
		b[i+1]=b[i]+t[i]-64;
	}
	for(; q>0; q--){
		int s1=nextint();
		int s2=nextint();
		int t1=nextint();
		int t2=nextint();
		if((a[s2]-a[s1-1])%3==(b[t2]-b[t1-1])%3){
			puts("YES");
		}else{
			puts("NO");
		}
	}
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

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

	int ans = max(a,b);
	if(a>b) --a;else --b;
	ans += max(a,b);
	ote(ans);
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);


        int n = sc.nextInt();

        int a[] = new int[n];

        for (int i=0; i<n; i++) a[i] = sc.nextInt();

        int ans[] = new int[n];



        int max1 = 0;
        int max2 = 0;

        for (int num: a){
            if (num>max1){
                max2 = max1;
                max1 = num;
            }else if (num>max2){
                max2 = num;
            }
        }

        for (int i=0; i<n; i++){
            if (a[i]==max1){
                ans[i] = max2;
            }else{
                ans[i] = max1;
            }
        }


        for (int i=0; i<n; i++)
        {
            System.out.println(ans[i]);
        }

    }
}


Measured memory_bytes: 87284
a,b,n=map(int,input().split())
ans=a*n//b-a*(n//b)
if b>=10**6:
    if n>=b-1:
        ans=max(ans,a*(b-1)//b)
else:
    for i in range(1,min(b,n)+1):
        ans=max(ans,a*i//b-a*(i//b))
print(ans)

Measured memory_bytes: 63324
def slove():
    import sys
    import heapq
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    a = [- i for i in list(map(int, input().rstrip('\n').split()))]
    heapq.heapify(a)
    for i in range(m):
        heapq.heappush(a, -(-heapq.heappop(a) // 2))
    print(-sum(a))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 69160
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    set<string> st;
    rep(i,n){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 19224
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<29)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    ll n, p;
    cin >> n >> p;
    vector<ll> t;
    for (int i = 2; i <= sqrt(p); i++) {
        int count = 0;
        while (p % i == 0) {
            p /= i;
            count++;
        }
        if (count >= n) {
            for (int j = 0; j < count / n; j++)t.PB(i);
        }
    }
    if(p!=1&&n==1)t.PB(p);
    if (t.size() == 0)cout << 1 << endl;
    else {
        ll a = 1;
        for (int i = 0; i < t.size(); i++) {
            a *= t[i];
        }
        cout << a << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  for (const auto& c : s) {
    if (c == 'R') cnt++;
  }
  int ans = 0;
  for (int i = 0; i < cnt; i++) {
    if (s[i] == 'W') ans++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3752
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
using namespace std;

using LL = long long;
const int N = 505;

int p[N * N];
int vis[N][N];
int dis[N][N];
bool mk[N][N];

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


void dij(int x, int y, int f) {
    ans += dis[x][y];
    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> que;
    que.push({dis[x][y], {x, y}});
    mk[x][y] = true;
    while (!que.empty()) {
        auto [d, p] = que.top();
        auto [x, y] = p;
        que.pop();
        if (vis[x][y] == f) continue;
        vis[x][y] = f;
        for (int i = 0; i < 4; i++) {
            int xx =  x + dx[i], yy = y + dy[i];
            if (xx <0 || yy < 0 || xx >= n || yy >= n) continue;
            int v = d + !mk[x][y];
            if (v < dis[xx][yy]) {
                dis[xx][yy] = v;
                que.push({v, {xx, yy}});
            }
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n;
    
    for (int i = 0; i < n * n; i++) cin >> p[i];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dis[i][j] = min(min(i, j), min(n - i - 1, n - j - 1));
        }
    }
    for (int i = 0; i < n * n; i++) {
        int t = p[i] - 1;
        dij(t  / n, t % n, i + 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    long N;cin>>N;
    long dp[N+1];
    long monster[N+1];
    long yusha[N];
    for(int i=0;i<N+1;i++){
        long j;cin>>j;
        monster[i]=j;
    }
    for(int i=0;i<N;i++){
        long j;cin>>j;
        yusha[i]=j;
    }
    dp[0]=min(monster[0],yusha[0]);
    yusha[0]-=dp[0];
    for(int i=1;i<N;i++){
        dp[i]=min(monster[i],yusha[i-1]+yusha[i]);
        yusha[i]=min(yusha[i]-dp[i]+yusha[i-1],yusha[i]);
    }
    dp[N]=min(monster[N],yusha[N-1]);

    long res=0;
    for(int i=0;i<N+1;i++)res+=dp[i];
    cout<<res<<endl;
}


Measured memory_bytes: 2560
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

#define INF 1000010
#define MAX_V 110

using namespace std;

int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int V;

int prim(){
    for(int i=0; i < V; ++i){
        mincost[i] = INF;
        used[i] = false;
    }
    mincost[0] = 0;
    int res = 0;

    while(true){
        int v = -1;
        for(int u=0; u < V; u++){
            if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
        }

        if(v == -1) break;
        used[v] = true;
        res += mincost[v];

        for(int u=0; u < V; u++){
            mincost[u] = min(mincost[u], cost[v][u]);
        }
    }
    return res;
}

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

        for(int i=0; i < MAX_V; i++) for(int j=0; j < MAX_V; j++) cost[i][j] = INF;

        V = n;
        int m;
        cin >> m;
        for(int i=0; i < m; i++){
            int a, b, c;
            scanf("%d,%d,%d", &a, &b, &c);
            cost[a][b] = c;
            cost[b][a] = c;
        }

        cout << prim()/100-n+1 << endl;
    }
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


// MOD
const int MOD = 1000000007;

// 入力
int H, W;
vector<string> a;

// DP テーブル
int dp[1100][1100] = {0};

// add
void add(int &a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
      cin >> H >> W;
      a.resize(H);
      for (int i = 0; i < H; ++i) cin >> a[i];
      dp[0][0] = 1;
      bool flag = false;
      rep(i,W) {
        if(a[0][i] == '#') flag = true;
        if(!flag) dp[0][i] = 1;
      }
      flag = false;
      rep(i,H) {
        if(a[i][0] == '#') flag = true;
        if(!flag) dp[i][0] = 1;
      }

      REP(i,1,H){
        REP(j,1,W){
          if(a[i][j] == '#') continue;
          add(dp[i][j], dp[i][j-1]);
          add(dp[i][j], dp[i-1][j]);
        }
      }
      print(dp[H-1][W-1]);
}

Measured memory_bytes: 5632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int idx = 1;
		String str;

		StringBuilder output = new StringBuilder();
		try {

			while(true){
				str = br.readLine();
				if (str.equals("0")) {
					break;
				} else {
					output.append("Case ").append(String.valueOf(idx))
							.append(": ").append(str).append("\n");
				}
				if (idx % 100 == 0) {
					System.out.print(output.toString());
					output.setLength(0);
				}
				idx++;
			}
			if (output.length() > 0) {
				System.out.print(output.toString());
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 25108
#include<stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x+r>W || x-r<0 ||y+r>H || y-r<0){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 584
a = int(input())
ar = list(map(int,input().split(" ")))
count = 0
for i in range(1,a-1):
  if ar[i] < ar[i-1] and ar[i] > ar[i+1]:
    count += 1
  elif ar[i] < ar[i+1] and ar[i] > ar[i-1]:
    count += 1
print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

ll N;
ll res = 0;

void func(ll cur) {
  if(cur > N) return;

  string s = to_string(cur);
  int is753 = 0b000;
  for(auto c:s) {
    if(c == '7') is753 |= 0b100;
    if(c == '5') is753 |= 0b010;
    if(c == '3') is753 |= 0b001;
  }
  if(is753 == 0b111) {++res;}

  func(cur*10+7);

  func(cur*10+5);

  func(cur*10+3);
}

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

  // 再帰による全探索
  // https://drken1215.hatenablog.com/entry/2019/04/03/125400
  cin>>N;
  func(0);
  cout << res << endl;

  return 0;
}


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

int main() {
    long long int money = 1000, kabu = 0; 
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    int b[n] = {0};

    if(a[0] < a[1]) b[0] = 1;
    b[n-1] = -1;
    for(int i = 1; i < n-1; ++i) {
        if(a[i-1] <= a[i] && a[i+1] < a[i]) {
            b[i] = -1;
        } else if(a[i-1] >= a[i] && a[i+1] > a[i]) {
            b[i] = 1;
        }
    }
    for(int i = 0; i < n; ++i) {
        if(b[i] == 1) {
            long long int canbuy = money/a[i];
            kabu += canbuy;
            money -= a[i]*canbuy;
        } else if(b[i] == -1) {
            money += kabu*a[i];
            kabu = 0;
        }
    }
    cout << money << '\n';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int R,G,B,N;
	cin>>R>>G>>B>>N;
	int nb = 0;
	for (int i = 0 ; i <= N ; i++)
	{
		for (int j = 0 ; j <= N ; j++)
		{
			int reste = N - (R * i) - (G * j);
			if (reste >= 0 && reste % B == 0)
			{
				nb++;
			}
		}
	}
	cout<<nb<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int N,M,X,Y;
  int maxx=-1000,miny=1000;
  cin >> N >> M >> X >> Y;
  int a,b;
  rep(i, N){
  cin >> a;
    maxx=max(maxx,max(a,X));
  }
  rep(i, M){
  cin >> b;
    miny=min(miny,min(Y,b));
  }
  if(maxx<miny)
    cout <<"No War" << endl;
  else
    cout << "War" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));


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

    int a,b,h,m;
    cin >> a >> b >> h >> m;
    h = h*30;
    double ans =h + m*0.5;
    m = m*6;
    ans = abs(ans - m);
    ans = a*a + b*b - 2.0*a*b*cos(PI*ans/180);
    cout << fixed << setprecision(18) << sqrt(ans) << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 4100
#include<cstdio>
#include<cmath>

using namespace std;

int main() {

    double r;

    scanf("%lf", &r);

    double S, L;
    S = r * r * M_PI;
    L = 2 * r * M_PI;

    printf("%lf %lf\n", S, L);

    return 0;
}


Measured memory_bytes: 2732
#include <stdio.h>

//sort(a, a + N, greater<int>());

int main(void){
	int a,b,x;
	scanf("%d %d %d",&a,&b,&x);
	if(a == x)
		printf("YES\n");
	else if(a < x){
		if(x-a <= b)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else
		printf("NO\n");
	
	
	
	
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll a[2001];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	multiset<ll> se;
	for(int i=1;i<=n;i++)
	{
		ll cnt=0;
		for(int j=i;j<=n;j++)
		{
			cnt+=a[j];
			se.insert(cnt);
		}
	}
	ll ans=0;
	for(int i=60;i>=0;i--)
	{
		multiset<ll> se2;
		multiset<ll>::iterator j;
		for(j=se.begin();j!=se.end();j++)
		{
			if(*j>>i&1)
			{
				se2.insert(*j);
			}
		}
		if(se2.size()>=k)
		{
			ans+=1ll<<i;
			se=se2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    long long fans = 0;
    long k;
    cin >> k;
    for (long i = 1; i<= k; i++)
        for (long j = 1; j <= k; j++)
            for (long l = 1; l <= k; l ++)
                fans += __gcd(i, __gcd(j, l));
    cout << fans;
    return 0;
}





Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  string S;cin>>S;
  
  
  if(N%2!=0){cout<<"No";return 0;}
  if(S.substr(0,N/2)==S.substr(N/2)){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  
}




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

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = int(5e5) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

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

    for (int i = min(a, b); i <= max(a, b); ++i)
    {
        if (i == c)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256