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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v) for_each((v).begin(), (v).end(), [](int& a) { cout << a << " "; }); cout << endl;

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

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int k;
V<int> v;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int x;
    REP(i, 5) {
        cin >> x;
        v.push_back(x);
    }
    cin >> k;

    REP(i, 5) {
        for(int j = i; j < 5; j++) {
            if(std::abs(v[i] - v[j]) > k) {
                cout << ":(" << "\n";
                return 0;
            }
        }
    }
    cout << "Yay!" << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x , y, z, ans = 0;
    scanf("%d %d %d", &x, &y, &z);
    x -= z;
    while ( 1 ) {
        x -= (y + z);
        if ( x < 0)break;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;

#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)

int cot ;
void permute(int index , int &n)
{
	if(index == 3)
	{
		++cot ; return ;
	}
	for(int i = 1 ; i <= n ; ++i)
	{
		permute(index + 1 , n);
	}	
	return ; 
}

int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n ; 
	cin >> n ; 
	int b[n] , a[n+1];
	for(int i = 1 ; i < n ; ++i)
		cin >> b[i] ;
	a[1] = a[2] = b[1] ;
	for(int i = 2 ; i < n ; ++i)
	{
		if(b[i] >= b[i - 1]) a[i + 1] = b[i];
		else
		{
		 	a[i] = b[i];
		 	a[i+1] = b[i];
		}
	}

	int ans = 0;
	for(int i = 1 ; i <= n ; ++i)
		ans += a[i];
		cout << ans;
	return 0;
}

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

using namespace std;
#define ll long long
const int N = 2e5 + 5;
ll a[N], b[N], ac[N];
int n;

bool check(int x, ll m) {
    ll res = 0;
    for (int i = 0; i < n; i++) {
        int y = max(0LL, x - a[i]);
        res += b[y];
    }
    return res >= m;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i],b[a[i]]++;
    sort(a, a + n);
    reverse(a, a + n);
    for (int i = N - 5; i >= 0; i--) {
        ac[i] = i * 1LL * b[i];
        ac[i] += ac[i + 1];
        b[i] += b[i + 1];
    }
    int s = 2, e = 2e5, mn = 1;
    while (s <= e) {
        int mid = s + e >> 1;
        if (check(mid, m)) s = mid + 1, mn = mid + 1;
        else e = mid - 1;
    }
    ll res = 0;
    for (int i = 0; i < n && m > 0; i++) {
        int y = max(0LL, mn - a[i]);
        ll cnt = min(b[y], m);
        res += (a[i] * cnt) + ac[y];
        m -= cnt;
    }
    cout << res + (m * 1LL * (mn - 1)) << endl;
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N, K;
    string S;
    cin >> N >> S >> K;

    char c = S[K-1];
    for (int i = 0; i < N; i++) {
        if (S[i] != c) {
            S[i] = '*';
        }
    }

    cout << S << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int main() {
  
  int L = 0;
  int N, K;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    if(x <= K - x){
      L = L + x*2;
    }
    if(x > K -x){
      L = L + (K -x)*2;
    }
  }
  cout << L << endl;
      

}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_BIT = (int)(5e3 + 5);

int n, m;

vector<ll> as;
vector<int> cs;

ll memo[MAX_BIT];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    ll a;
    int b;
    scanf("%lld %d", &a, &b);
    as.push_back(a);

    int empty_bit = 0;
    cs.push_back(empty_bit);

    for (int j = 0; j < b; ++j) {
      int c;
      scanf("%d", &c);

      cs.back() |= (1 << (c - 1));
    }
  }

  for (int i = 0; i < MAX_BIT; ++i) {
    memo[i] = INF;
  }

  priority_queue<pair<ll, int>> pq;

  int empty_bit = 0;
  pq.push(make_pair(0L, empty_bit));
  memo[empty_bit] = 0L;

  while (!pq.empty()) {
    auto cur = pq.top();
    pq.pop();

    for (int i = 0; i < cs.size(); ++i) {
      int new_bit = cur.second;

      new_bit |= cs[i];

      if (memo[new_bit] > cur.first + as[i]) {
        memo[new_bit] = cur.first + as[i];
        pq.push(make_pair(memo[new_bit], new_bit));
      }
    }
  }

  int key = 0;
  for (int i = 0; i < n; ++i) {
    key |= (1 << i);
  }

  if (memo[key] == INF) {
    printf("%lld\n", -1L);
  } else {
    printf("%lld\n", memo[key]);
  }

  return 0;
}


Measured memory_bytes: 384
#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;


const int MAXN = 1005;

int main() {
  int n;
  cin>>n;
  deque<int> a[n];
  rep(i,n)rep(j,n-1){
    int temp;
    cin>>temp;
    temp--;
    a[i].push_back(temp);
  }
  vector<P>q;
  auto check=[&](int i){
    if (a[i].size()==0)return;
    int j=a[i].front();
    if (a[j].front()==i){
      if (i>j)swap(i,j);
      q.push_back(make_pair(i,j));
    }
  };

  int ans=0;
  rep(i,n){
    check(i);
  }
  while (q.size()>0){
    ans++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P>prev;
    swap(q,prev);
    for(P p : prev){
      int f=p.first;
      int s=p.second;
      a[f].pop_front();
      a[s].pop_front();

    }
    for(P p : prev){
      check(p.first);
      check(p.second);
  }
}
rep(i,n){
  if (a[i].size()>0) ans=-1;
}
 cout<<ans;




}


Measured memory_bytes: 4736
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  cout << a+b/2;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)

using namespace std; 
int main() 
{
  int n;
  cin>>n;
  int ans=0;
  if(n&1){
  while(n>=0)
  {
     ans++;
      n-=2;
  }
     cout<<ans<<"\n";
     return 0;
}
else 
{
    while(n)
  {
     ans++;
      n-=2;
  }
     cout<<ans<<"\n";
}
	return 0;
}

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

template <typename T,typename E,typename F,typename G>
struct SegmentTree{
  int n;
  F f;
  G g;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T ti):
    f(f),g(g),ti(ti){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }

  int find(int a,int b,function<bool(T)> &check,int k,int l,int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n-1) return k-(n-1);
    int m=(l+r)>>1;
    int vl=find(a,b,check,k*2+1,l,m);
    if(~vl) return vl;
    return find(a,b,check,k*2+2,m,r);
  }
  
  int find(int a,int b,function<bool(T)> &check){
    return find(a,b,check,0,0,n);
  }
  
};

//INSERT ABOVE HERE
signed main(){
  int n,l;
  scanf("%d %d",&n,&l);
  vector<int> v(n);
  for(int i=0;i<n;i++) scanf("%d",&v[i]);
  const int INF = 1e9+1;
  auto f=[](int a,int b){return min(a,b);};
  SegmentTree<int, int, decltype(f), decltype(f)> seg(n,f,f,INF);  
  seg.build(n,v);
  vector<int> ans(n-l+1);
  for(int i=0;i+l<=n;i++) ans[i]=seg.query(i,i+l);
  for(int i=0;i+l<=n;i++){
    if(i) printf(" ");
    printf("%d",ans[i]);
  }
  puts("");
  return 0;
}



Measured memory_bytes: 18984
using System;
using System.Collections.Generic;
using System.Linq;

class Program {

    static int Main(string[] args) {
        List<int> list = new List<int>();

        string v = Console.ReadLine();
        string[] vs = v.Split(' ');

        for (int i = 0; i < vs.Length; i++) {
            list.Add(int.Parse(vs[i]));
        }

        list.Sort();
        for (int i = list.Count - 1; i >= 0; i--) {
            if (i > 0) {
                Console.Write(list[i]);
                Console.Write(" ");
            }
            else {
                Console.WriteLine(list[i]);
            }
        }

        return 0;
    }
}



Measured memory_bytes: 9368
import sys
#input = sys.stdin.buffer.readline

def main():
    N = int(input())
    s = input()
    ans = s.count(".")
    count = ans
    for st in s:
        if st == "#":
            count += 1
        else:
            count -= 1
        ans = min(ans,count)
        
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
int dis[100009],vis[100009],n,l,r;
int main()
{
    dis[1]=1;
    for (int i=2;i<=100000;i++)
    {
        for (int j=2*i;j<=100000;j=j+i)
            dis[j]=1;
    }
    dis[2]=0;
    for (int i=1;i<=100000;i++)
    {
        if(dis[i]==0&&dis[(i+1)/2]==0&&i!=2)
        {
            vis[i]=vis[i-1]+1;
        }
        else 
        {
            vis[i]=vis[i-1];
        }
    }
    cin>>n;
    while(n--)
    {
        cin>>l>>r;
        cout<<vis[r]-vis[l-1]<<endl;
    }
}

Measured memory_bytes: 1408
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int aka = 0;
		int ao = 0;
		String akaka = "R";
		for(int i = 0; i < n; i++){
			if(akaka.equals(s.substring(i,i+1))){
				aka++;
			}else{
				ao++;
			}
		}
		System.out.print(aka>ao?"Yes":"No");
	}
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;  cin>>n;
    int height[n+2];
    for(int i=1;i<=n;i++) cin>>height[i];
    int min_cost[n+2];
    min_cost[1]=0;min_cost[2]=abs(height[2]-height[1]);
    for(int i=3;i<=n;i++){
        min_cost[i] = min(abs(height[i]-height[i-1])+min_cost[i-1],abs(height[i]-height[i-2])+min_cost[i-2]);
    }
    cout<<min_cost[n];
}

Measured memory_bytes: 1024
#include <stdio.h>
#define max 100

int bubbleSort(int*,int);

int main(){
    int n,num[max],count;

    scanf("%d",&n);

    for(int i = 0;i<n;i++){
        scanf("%d",&num[i]);
    }

    count = bubbleSort(num,n);

    for(int i = 0;i < n;i++){
        printf("%d",num[i]);
        if(i < n-1)printf(" ");
    }

    printf("\n%d\n",count);

    return 0;
}

int bubbleSort(int *num,int n){
    int tmp;
    int count = 0;
    int flog = 1;
    int i = 0;

    while(flog){
        flog = 0;
        for(int j = n-1;j > i;j--){
            if(num[j] < num[j-1]){
                tmp = num[j];
                num[j] = num[j-1];
                num[j-1] = tmp;
                count++;
                flog = 1;
            }
        }
        i++;
    }

    return count;
}


Measured memory_bytes: 2124
// OBïÄh2011 Day4 H : Ïõ·Ì

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

// 2ªTõÅp[L] < t < p[L+1]ð½·LðT·
int getIdx(vector<int> &p, int t){
	int L = 0, R = p.size();
	while(R-L>1){
		int mid = (L+R)/2;
		if(p[mid] < t && t < p[mid+1]) return mid;
		if(t < p[mid]) R = mid;
		if(p[mid+1] < t) L = mid;
	}
	return L;
}

long long calc(vector<int> &s, vector<int> &t, vector<int> &p){
	long long sumA[100001];
	long long sumB[100001];
	// sumA : ôÔÚÌæÔÌa
	sumA[0] = p[1]-p[0]; 
	for(int i=1;i+1<p.size();i++){
		sumA[i] = sumA[i-1];
		if(i%2==0) sumA[i] += p[i+1]-p[i];
	}
	// sumA : ïÔÚÌæÔÌa
	sumB[0] = 0;
	for(int i=1;i+1<p.size();i++){
		sumB[i] = sumB[i-1];
		if(i%2==1) sumB[i] += p[i+1]-p[i];
	}
	int N = s.size();
	long long res = 0;
	for(int i=0;i<N;i++){
		// n_ÀW < I_ÀW ÌàÌ¾¯ðl¶ 
		if(s[i] > t[i]) continue;
		int L = getIdx(p, s[i]);
		int R = getIdx(p, t[i]);
		// Ìn_EI_ª¯êæÔÉ¶Ý
		if(L==R) res += t[i]-s[i];
		else {
			// Ìn_©çÅÌj_ÜÅÌ·³
			res += p[L+1]-s[i];
			// rÌæÔÌ·³ÌaðÁ¦é
			if(L+1<R-1){
				if(L%2==0) res += sumA[R-1]-sumA[L+1];
				else       res += sumB[R-1]-sumB[L+1];
			}
			// ÅãÌj_©çÌI_ÜÅÌ·³
			if(L%2==R%2) res += t[i]-p[R];
		}
	}
	return res;
}

int main(){
	int N, M;
	while(cin >> N >> M){
		vector<int> s(N), t(N), p(M+2);
		for(int i=0;i<N;i++) scanf("%d %d", &s[i], &t[i]);
		// j_É\ª¢_ðÁ¦Ä¨­
		p[0]   = -1000000007;
		p[M+1] =  1000000007;
		for(int i=1;i<M+1;i++) scanf("%d", &p[i]);
		// 2ªTõ·éÌÅ\[g
		sort(p.begin(), p.end());
		long long res = 0;
		res += calc(s, t, p);
		// _ÌÀÑðtÉµÄà¤êxvZ
		reverse(p.begin(), p.end());
		for(int i=0;i<N;i++) s[i] = -s[i], t[i] = -t[i];
		for(int i=0;i<p.size();i++) p[i] = -p[i];
		res += calc(s, t, p);
		cout << res << endl;
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int maxn = 4e5 + 7;
const int somod = 1e9 + 7;
int n, le[maxn], ri[maxn], m, BIT[maxn];
pair<int, int> p[maxn];

vector<int> val = {0};
vector<pair<int, int>> val1;
void add(int &a, int b)
{
   a += b;
   if(a >= somod) a -= somod;
}

int Find(int x)
{
   return (int)(lower_bound(val.begin(), val.end(), x) - val.begin());
}

void Update(int pos, int val)
{
   for(; pos < maxn; pos += pos & -pos)
   {
      add(BIT[pos], val);
   }
}

int Query(int pos)
{
   int ans = 0;
   for(; pos > 0; pos -= pos & -pos)
   {
      add(ans, BIT[pos]);
   }
   return ans;
}

int32_t main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
   cin >> n >> m;
   for(int i = 1; i <= n; i++)
   {
      cin >> p[i].first;
      p[i].second = 1;
   }
   for(int i = n + 1; i <= n + m; i++)
   {
      cin >> p[i].first;
      p[i].second = 0;
   }
   n += m;
   sort(p + 1, p + n + 1);
   int cur = -1;
   for(int i = 1; i <= n; i++)
   {
      if(p[i].second == 0) cur = p[i].first;
      else
      {
         if(cur != -1) le[i] = p[i].first - cur;
      }
   }
   cur = -1;
   for(int i = n; i >= 1; i--)
   {
      if(p[i].second == 0) cur = p[i].first;
      else
      {
         if(cur != -1) ri[i] = -(p[i].first - cur);
      }
      if(ri[i] && le[i])
      {
         val.push_back(ri[i]);
         val1.emplace_back(le[i], ri[i]);
      }
   }
   sort(val.begin(), val.end());
   sort(val1.begin(), val1.end(), [](const pair<int, int> &x, const pair<int, int> &y)
   {
      if(x.first == y.first) return x.second > y.second;
      return x.first < y.first;
   });
   val.erase(unique(val.begin(), val.end()), val.end());
   val1.erase(unique(val1.begin(), val1.end()), val1.end());
   Update(1, 1);
   for(auto i: val1)
   {
      i.second = Find(i.second);
      Update(i.second + 1, Query(i.second));
   }
   cout << Query(maxn - 1);
}

Measured memory_bytes: 15080
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String a = in.next();
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < a.length(); i++) {
            if(a.charAt(i)=='1')s.append(a.charAt(i));
            else if (a.charAt(i)=='0')s.append(a.charAt(i));
            else {
                if(s.length()!=0){
                    s.deleteCharAt(s.length()-1);
                }
            }
        }
        System.out.println(s);
    }
}


Measured memory_bytes: 26932
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

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

void Main(){
    int N;
    cin >> N;
    vec<int> a(N+1);
    int sum = 0;
    int mn = INT_MAX;
    REP(i, N){
        cin >> a[i];
        sum += a[i];
        if(a[i]%10 != 0){
            chmin(mn, a[i]);
        }
    }
    if(sum%10 != 0){
        cout << sum << el;
        return;
    }
    if(mn == INT_MAX){
        cout << 0 << el;
        return;
    }
    cout << sum-mn << el;
}



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

#define ll long long

ll modVal = 998244353;

ll mPow(ll a, ll b) {
  ll r = 1;
  while (b--) {
    r *= a;
    r %= modVal;
  }
  return r;
}

int main() {
  int n;
  cin >> n;
  int maxVal = 0;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    maxVal = max(maxVal, v[i]);
    if (i != 0 && v[i] == 0) {
      cout << 0;
      return 0;
    }
  }
  if (v[0] != 0) {
    cout << 0;
    return 0;
  }
  vector<int> mult(maxVal+1, 0);
  for (int m : v) {
    mult[m]++;
  }
  ll r = 1;
  for (int i = 1; i < mult.size(); i++) {
    r = (r * mPow(mult[i-1], mult[i])) % modVal;
  }
  cout << r;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  std::reverse(a, a + n);
  for (int i = 0; i < n; i++) {
    i == n - 1 ? std::cout << a[i] << std::endl : std::cout << a[i] << " ";
  }
  return 0;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;


LL dp[3001][3001];

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

  for (int j = 0; j < N; ++j) {
    dp[0][j] = 1;
  }

  for (int i = 1; i < N; ++i) {
    if (S[i-1] == '<') {
      dp[i][0] = dp[i-1][0];
      for (int j = 1; j < N - i; ++j) {
        dp[i][j] = dp[i][j-1] + dp[i-1][j];
        dp[i][j] %= kMod;
      }
    } else {  // '>'
      dp[i][N-i-1] = dp[i-1][N-i];
      for (int j = N-i-2; j >= 0; --j) {
        dp[i][j] = dp[i][j+1] + dp[i-1][j+1];
        dp[i][j] %= kMod;
      }
    }
  }

#if DEBUG
  std::cout <<" :";
  for (int j = 0; j < N; ++j) std::cout << dp[0][j] << "\t";
  std::cout << std::endl;
  for (int i = 1; i < N; ++i) {
    std::cout << S[i-1] << ":";
    for (int j = 0; j < N - i; ++j) std::cout << dp[i][j] << "\t";
    std::cout << std::endl;
  }
#endif
  std::cout << dp[N-1][0] << std::endl;
}


Measured memory_bytes: 70016
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ????????????????????????????\???????????????¨????????°
		final int VERTICALLIMIT = 12;
		final int SIDELIMIT = 12;

		Scanner in = new Scanner(System.in);
		String[][] land = new String[VERTICALLIMIT][SIDELIMIT];
		int count = 0;
		ArrayList<Integer> islandCount = new ArrayList<>();

		while (in.hasNext()) {

			for (int verticalNum = 0; verticalNum < VERTICALLIMIT; verticalNum++) {

				String worldMap = in.next();

				for (int sideNum = 0; sideNum < SIDELIMIT; sideNum++) {

					// b = a.charAt(j);
					// int c = Integer.parseInt(b + "");
					land[verticalNum] = worldMap.split("");

				}
			}

			for (int verticalNum = 0; verticalNum < VERTICALLIMIT; verticalNum++) {

				for (int sideNum = 0; sideNum < SIDELIMIT; sideNum++) {

					if (land[verticalNum][sideNum].equals("1")) {

						island(land, verticalNum, sideNum);

						count++;

					}
				}
			}

			islandCount.add(count);
			count = 0;

		}

		for(int result: islandCount) {

			System.out.println(result);

		}

	}

	private static void island(String[][] land, int verticalNum, int sideNum) {

		// ????????????????????????????\???????????????¨????????°
		final int VERTICALZERO = 0;
		final int VERTICALLIMIT = 11;
		final int SIDEZERO = 0;
		final int SIDELIMIT = 11;

		if (land[verticalNum][sideNum].equals("1")) {

			land[verticalNum][sideNum] = "0";

			if (verticalNum > VERTICALZERO) {

				island(land, verticalNum - 1, sideNum);

			}

			if (verticalNum < VERTICALLIMIT) {

				island(land, verticalNum + 1, sideNum);

			}

			if (sideNum > SIDEZERO) {

				island(land, verticalNum, sideNum - 1);

			}

			if (sideNum < SIDELIMIT) {

				island(land, verticalNum, sideNum + 1);

			}

		} else {

			return;

		}
	}
}


// ==============================?????°???????????????=======================================

  /*if(land[i + 1][j] == 0 && land[i - 1][j] == 0 && land[i][j + 1] == 0 && land[i][j - 1] == 0) {

	  land[i][j] = 0;

  } else if(land[i + 1][j] == 1 || land[i - 1][j] != 0 || land[i][j + 1] != 0 || land[i][j - 1] != 0){

	  island(land, i + 1, j);

  } else if(land[j + 1][j] == 1 && land[i + 1][j] == 0 || land[i - 1][j] != 0 || land[i][j - 1] != 0) {

	  island(land, i, j + 1);

  } else if(land[i][j - 1] == 1 && land[i + 1][j] == 0 || land[i - 1][j] != 0 || land[i][j - 1] != 0){

	  island(land, i, j - 1);

  } else if(land[i][i - 1] == 1 && land[i + 1][j] == 0 || land[i][j + 1] != 0 || land[i][j - 1] != 0){

	  island(land, i - 1, j);

  }

  	land[i][j] = 0;*/

Measured memory_bytes: 30164
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main()
{
    int n , k; cin >> n >> k; int a[n]; int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] >= k) cnt++;
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 640
X = int(input())

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

#print(primes(1000000)[:X])
for i in primes(1000000):
    if i >= X:
        print(i)
        break

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong H, W, M;
  vector<llong> bh;
  vector<llong> bw;
  map<llong, llong> mh, mw;
  set<lpair> s;

  cin >> H >> W >> M;
  bh.resize(M);
  bw.resize(M);
  for (int i = 0; i < M; i++) {
    cin >> bh[i] >> bw[i];
    mh[bh[i]]++;
    mw[bw[i]]++;
    s.insert(lpair(bh[i], bw[i]));
  }

  llong ah = 0, aw = 0;
  vector<llong> ch, cw;
  for (auto it: mh) {
    if (ah < it.second) {
      ch.clear();
      ah = it.second;
    }
    if (ah == it.second) {
      ch.push_back(it.first);
    }
  }
  for (auto it: mw) {
    if (aw < it.second) {
      cw.clear();
      aw = it.second;
    }
    if (aw == it.second) {
      cw.push_back(it.first);
    }
  }

  llong ans = ah + aw;
  llong same = 1;
  for (auto &h: ch) {
    if (same == 0) break;
    for (auto &w: cw) {
      if (!s.count(lpair(h, w))) {
        same = 0;
        break;
      }
    }
  }

  cout << ans - same << endl;

  return 0;
}

Measured memory_bytes: 72592
import sys
for line in sys.stdin.readlines():
    a, b, c, d, e, f  = map(float, line.strip().split())
    y = ((c * d) - (a * f)) / ((b * d) - (a * e))
    x = (c - (b * y)) / a
    print "{0:.3f}".format(x),
    print "{0:.3f}".format(y)

Measured memory_bytes: 4216
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

bool check(long long b, long long n, long long s){
    if(b < 2) return 0;

    long long sum = 0;
    while(n != 0){
        sum += n % b;
        n /= b;
    }
    return sum == s;
}

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

    range(i,2,sqrt(n) + 1){
        if(check(i,n,s)){
            cout << i << endl;
            return 0;
        }
    }

    long long ans = LLONG_MAX;
    if(n == s) ans = n + 1;
    range(i,1,sqrt(n) + 1){
        if(check((n - s) / i + 1, n, s)){
            ans = min(ans, (n - s) / i + 1);
        }
    }
    cout << (ans == LLONG_MAX ? -1 : ans) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define minus djsf
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

const int mod = 998244353;

int pw(int x, int y) {
    
    ll ans = 1;
    ll deg = x;
    for (int i=0; i < 30; ++i){
        int ba = (1LL<<i)&y;
        if (ba != 0){
            ans *= deg;
            ans %= mod;
        }
        deg *= deg;
        deg %= mod;
    }
    
	return ans;
}

const int N = 10000007;

int fact[N], rev[N];

int C(int n, int k) {
	int A = fact[n];
	int B = ((ll) rev[k] * rev[n-k]) % mod;
	return ((ll) A * B) % mod;
}
 
signed main()
{
#ifdef LOCAL
	freopen("N_input.txt", "r", stdin);
	//freopen("P_output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    fact[0] = 1;
    for (int i=1; i < N; ++i) fact[i] = ((ll) fact[i-1] * i) % mod;
    for (int i=0; i < N; ++i) rev[i] = pw(fact[i], mod-2);

    	//cout << pw(2, 5) << endl;
    

    int n;
    cin >> n;

    int ans = pw(3, n);

    for (int i=n/2+1; i <= n; ++i) {
    	int T = (2*C(n, i)) % mod;
    	T = ((ll) T * pw(2, n - i)) % mod;
    	ans = (ans - T + mod) % mod;
    }

    cout << ans;


	
}

Measured memory_bytes: 78464
#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) { pc('0'); return; }
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}

void sout(char *s) { while (*s) pc(*s++); }

typedef struct { int parent; int depth; int k; int *c; } TREE;
TREE tbl[100002];

void calc_depth(int node, int d)
{
	int i;
	tbl[node].depth = d;
	for (i = 0; i < tbl[node].k; i++) calc_depth(tbl[node].c[i], d+1);
}

int main()
{
	int n, i, j, k, id;
	int root;

	n = in();
	for (i = 0; i < n; i++) {
		id = in(), tbl[id].k = k = in();
		tbl[id].c = malloc(k << 2);
		for (j = 0; j < k; j++) {
			int _c = in();
			tbl[_c].parent = id+1;
			tbl[id].c[j] = _c;
		}
	}
	for (root = 0; root < n; root++) {
		if (tbl[root].parent == 0) break;
	}
	calc_depth(root, 0);

	for (i = 0; i < n; i++) {
		sout("node "), out(i);
		sout(": parent = ");
		if (i == root) sout("-1");
		else out(tbl[i].parent - 1);
		sout(", depth = "), out(tbl[i].depth);
		sout(", ");
		if (i == root)          sout("root");
		else if (tbl[i].k == 0) sout("leaf");
		else                    sout("internal node");
		sout(", [");
		if (tbl[i].k > 0) {
			out(tbl[i].c[0]);
			for (j = 1; j < tbl[i].k; j++) {
				pc(','), pc(' '), out(tbl[i].c[j]);
			}
		}
		sout("]\n");
	}
	return 0;
}



Measured memory_bytes: 7404
up_row = [int(a) for a in input().split(' ')]
middle_row = [int(a) for a in input().split(' ')]
down_row = [int(a) for a in input().split(' ')]
numbers_count = int(input())

bingo_mat = [up_row, middle_row, down_row]
selected_mat = [[False, False, False], [False, False, False], [False, False, False]]


for i in range(numbers_count):
    selected = int(input())
    for row in range(3):
        for col in range(3):
            if bingo_mat[row][col] == selected:
                selected_mat[row][col] = True

for col in range(3):
    if selected_mat[0][col] and selected_mat[1][col] and selected_mat[2][col]:
        print("Yes")
        exit()

for row in range(3):
    if selected_mat[row][0] and selected_mat[row][1] and selected_mat[row][2]:
        print("Yes")
        exit()

if selected_mat[0][0] and selected_mat[1][1] and selected_mat[2][2]:
    print("Yes")
    exit()

if selected_mat[0][2] and selected_mat[1][1] and selected_mat[2][0]:
    print("Yes")
    exit()

print("No")

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

struct Card { char value, suit; };

void show(struct Card cards[], int n) {
    for (int k = 0; k < n; ++k) {
        if( k == n - 1) {
            cout << cards[k].suit << cards[k].value;
        } else {
            cout << cards[k].suit << cards[k].value << " ";
        }
    }
    cout << endl;
}

void bubble_sort(Card cards[], int n) {
    int flag = 1;
    for (int i = 0; flag; ++i) {
       flag = 0;
        for (int j = n - 1; j >= i + 1; --j) {
            if(cards[j].value < cards[j - 1].value) {
                Card temp = cards[j];
                cards[j] = cards[j - 1];
                cards[j - 1] = temp;
                flag = 1;
            }
        }
    }
    show(cards, n);
}

void select_sort(Card cards[], int n) {
    for (int i = 0; i < n; ++i) {
        int min = i;
        for (int j = i; j < n; ++j) {
            if(cards[j].value < cards[min].value) {
                min = j;
            }
        }
        if(i != min) {
            Card temp = cards[i];
            cards[i] = cards[min];
            cards[min] = temp;
        }
    }
    show(cards, n);
}

bool is_stable(struct Card C1[], struct Card C2[], int n) {
    for (int i = 0; i < n; ++i) {
        if (C1[i].suit != C2[i].suit) {
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    Card C1[n];
    Card C2[n];
    for (int i = 0; i < n; ++i) {
        cin >> C1[i].suit >> C1[i].value;
    }
    for (int j = 0; j < n; ++j) {
        C2[j] = C1[j];
    }
    bubble_sort(C1, n);
    cout << "Stable" << endl;
    select_sort(C2, n);
    if(is_stable(C1, C2, n)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    return 0;
}

Measured memory_bytes: 3084
import java.io.*;
import java.util.*;
public class Main {
	public static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
	}

	public static int abs(int x) { if (x < 0) return -x; return x; }

	public static void main(String[] args) {
		FS in = new FS();
	
		int n = in.nextInt();
		char[] A = in.next().toCharArray();
		char[] B = in.next().toCharArray();
		char[] C = new char[n << 1];
		for (int i = 0; i < n; i++)
			C[2 * i] = A[i];
		for (int i = 0; i < n; i++)
			C[2 * i + 1] = B[i];
		System.out.println((new String(C)));
	}
}


Measured memory_bytes: 22868
#include "bits/stdc++.h"
using namespace std;

using MatrixTy = vector<vector<int>>;

int main(int argc, char **argv) {
  int i;
  int A, B;
  cin >> A >> B;
  if (1 > A || A > 9) {
    cout << -1 << endl;
  } else if (1 > B || B > 9) {
    cout << -1 << endl;
  } else {
    cout << A*B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> p(n),q(n);
    for(int i=0;i<n;i++)cin>>p[i];
    for(int j=0;j<n;j++)cin>>q[j];
    vector<int> a(n);
    for(int i=0;i<n;i++)a[i]=i+1;
    map<vector<int>,int> mp;
    do{
        mp[a]=mp.size();
    }while(next_permutation(a.begin(),a.end()));
    int ans=abs(mp[p]-mp[q]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5248
def main():
    N, D = map(int, input().split())
    d2 = D * D
    ans = 0
    for _ in range(N):
        X, Y = map(int, input().split())
        if X*X + Y*Y <= d2:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9064
h, w = map(int,input().split())

mList = []
mList.append('-'*(w+2))

for i in range(h):
  mList.append(list('-'+input()+'-'))

resultMap = []
mList.append('-'*(w+2))
bomb = 0
for i in range(1,h+1):
  for j in range(1,w+1):
    if mList[i][j] == '.':
      for k in range(-1,2,1):
        for l in range(-1,2,1):
          if k == 0 and l == 0:
            pass
          elif mList[i+k][j+l] =="#":
            bomb+=1
      print(bomb,end='')
      bomb = 0
    else:
      print("#",end='')
  print()



Measured memory_bytes: 3444
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>

#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;


int main() {
	const string NOANS = "UNRESTORABLE";
	string S, T;
	cin >> S >> T;

	int N = S.size();
	int size = T.size();

	int isOK = 0;
	int lastOK = -1;
	for (int i = 0; i <= N - size; i++) {
		if (S[i] == T[0] || S[i] == '?') {
			isOK = 1;
			for (int j = 0; j < size; j++) {
				if (S[j+i] == T[j] || S[j+i] == '?') {
					continue;
				}
				else {
					isOK = 0;
					break;
				}
			}
			if (isOK == 1) {
				lastOK = max(lastOK, i);
			}
		}
	}

	if (lastOK == -1) {
		cout << NOANS;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (i != lastOK) {
			if (S[i] == '?')
				cout << 'a';
			else {
				cout << S[i];
			}
		}
		else {
			cout << T;
			i += T.size() - 1;
		}

	}

	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int x, y;
  cin >> x >> y;

  bool ans = false;
  // 亀がi匹
  for (int i = 0; i <= x; ++i) {
    if (i * 4 + (x - i) * 2 == y) {
      ans = true;
      break;
    }
  }

  if (ans) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int a,b,c;
  cin>>a>>b>>c;

  if(a==b&&b==c){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

 

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int x[3];
	int itmp;

	cin >> x[0] >> x[1] >> x[2];

	for(int i = 0; i < 2; i++)
	{
		for(int j = 0; j < 2; j++)
		{
			if(x[j] > x[j+1])
			{
				itmp = x[j+1];
				x[j+1] = x[j];
				x[j] = itmp;
			}
		}
	}

	cout << x[0] << " " << x[1] << " " << x[2] << endl;

	return 0;
}

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

using ll=long long; 

bool hantei(int x){
	vector<int>keta;
	while(x>0){
		keta.push_back(x%10);
		x/=10;
	}
	for(int i=0; i<keta.size(); i++){
		if(keta[i]!=keta[int(keta.size())-1-i]){
			return false;
		}
	}
	return true;
}

void solve(){
	int a,b;
	cin>>a>>b;
	int cnt=0;
	for(int i=a; i<=b; i++){
		if(hantei(i))cnt++;
	}
	cout<<cnt<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------


int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int tmp = h*W + w*H - h*w;
    int ans = H*W - tmp;
    cout << ans << endl;
}

Measured memory_bytes: 256
H,W,K=map(int,input().split())

fibonacchi=[1 for i in range(0,W+1)]
for i in range(0,W+1):
    if i>=2:
        fibonacchi[i]=fibonacchi[i-1]+fibonacchi[i-2]

dp=[[[0 for i in range(0,W+1)] for j in range(0,W+1)] for k in range(0,H+1)]
for i in range(1,H+1):
    for j in range(1,W+1):
        for k in range(1,W+1):
            if i==1:
                if j==k:
                    dp[i][j][k]=fibonacchi[j-1]*fibonacchi[W-k]
                elif j==k-1:
                    dp[i][j][k]=fibonacchi[j-1]*fibonacchi[W-k]
                elif j==k+1:
                    dp[i][j][k]=fibonacchi[k-1]*fibonacchi[W-j]
            else:
                ans=0
                if k>=2:
                    ans+=dp[i-1][j][k-1]*dp[1][k-1][k]
                if W-1>=k:
                    ans+=dp[i-1][j][k+1]*dp[1][k+1][k]
                ans+=dp[i-1][j][k]*dp[1][k][k]
                dp[i][j][k]=ans

print(dp[H][1][K]%(10**9+7))


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

int main()
{
	int a, b, c, x,ans=0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; ++i)
	{
		for (int u = 0; u <= b; ++u)
		{
			for (int y = 0; y <= c; ++y)
			{
				if ((500 * i + 100 * u + 50 * y) == x) ans++;
			}
		}
	}
	cout << ans << endl;
	fflush(stdin);
	getchar();
	fflush(stdin);
	getchar();
	return 0;

}

Measured memory_bytes: 256
S = input()
N = len(S)
num = [0] * N
left = 0
while left < N:
    mid = S.find('L', left)
    right = S.find('R', mid)
    if right == -1:
        right = N
    num[mid] = (right - left) // 2
    num[mid-1] = (right - left) // 2
    if (right - left) % 2 == 1:
        if (mid - left) % 2 == 0:
            num[mid] += 1
        else:
            num[mid-1] += 1
    left = right
print(' '.join(map(str, num)))


Measured memory_bytes: 10484
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll gcd(ll a,ll b){
	if(b==0LL)return a;
	return gcd(b,a%b);
}

class segtree{
public:
	static const int N=1<<17;
	ll dp[1<<18];
	segtree(){
		for(int i=0;i<(1<<18);i++){
			dp[i]=1;
		}
	}
	void update(int k,ll v){
		k+=N-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=(dp[k*2+1]*(dp[k*2+2]/gcd(dp[k*2+1],dp[k*2+2])));
		}
	}

	ll query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return 1;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		ll vl=query(a,b,k*2+1,l,mid);
		ll vr=query(a,b,k*2+2,mid,r);
		return (vl*(vr/gcd(vl,vr)));
	}
};

segtree seg;

int n,q;
int p[100005];
ll len[100005];
ll loopsum[100005];
ll sum[41][100005];

int main(void){
	scanf("%d%d",&n,&q);
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
		p[i]--;
	}
	for(int i=0;i<n;i++){
		int cnt=1;
		int v=p[i];
		loopsum[i]=v+1;
		while(v!=i){
			v=p[v];
			loopsum[i]=(loopsum[i]+v+1LL)%MOD;
			cnt++;
		}
		len[i]=cnt;
		seg.update(i,len[i]);
		sum[len[i]][i+1]+=loopsum[i];
		sum[len[i]][i+1]%=MOD;
	}
	for(int i=1;i<=40;i++){
		for(int j=0;j<n;j++){
			sum[i][j+1]+=sum[i][j];
			sum[i][j+1]%=MOD;
		}
	}
	for(int i=0;i<q;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		l--;
		ll loopsize=seg.query(l,r);
		ll ans=0;
		for(ll j=1;j<=40;j++){
			if(loopsize%j==0LL){
				ll vk=(loopsize/j)%MOD;
				ans+=(sum[j][r]-sum[j][l]+MOD)*vk%MOD;
				ans%=MOD;
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 38496
import java.util.Scanner;

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

        int tmp = N % 500;
        if(N % 500 <= A) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21076
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll n,k;
    string s, t;
    ll ans;
    double dans;
    string sans;
    ll a[20], b[20], c[19];


    cin  >> s >> t;

    ans = 0;

    rep(i,3){
        if(s[i] == t[i]) ans++;
    }

    std::cout << ans << endl; 
    // std::cout << sans << endl; 
    
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, S;
  cin >> N >> K;
  S = 1;
  for(int i = 0;i < N;i++){
   if(S > K){
     S = S + K;
   }
   else{
     S *= 2;
  }
  }
  cout << S << endl;
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    //if(n < 999) { cout << "0\n"; return 0; }
    //int res = n - 999;
    if(n <= 999)
    {
        cout << "ABC\n";
    }
    else {
        cout << "ABD\n";
    }
    //cout << res <<endl;
    return 0;
}


Measured memory_bytes: 256
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
a,n=map(int,input().split())
print(len(str(Base_10_to_n(a, n))))

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>


int main() {
	long long a, b, c, d, e;

	std::cin >> a >> b >> c >> d >> e;

	long long s_min = a * 60 + b; // 起床時間(分)
	long long e_min = c * 60 + d; // 就寝時間(分)

	std::cout << (e_min - s_min) - e << std::endl;

	return 0;
}


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

using namespace std;

int main() {
    int a, b, c;
    int min_sum;

    cin >> a >> b >> c;

    min_sum = a+b;
    min_sum = min(min_sum, a+c);
    min_sum = min(min_sum, b+c);

    cout << min_sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
int main(){
	long long n,t,ans;
	cin>>n>>t;
	long long p[n+1];
	ans=0;
	for(int i=0;i<n;i++)cin>>p[i];
	for(int i=1;i<n;i++){
		ans+=min(t,p[i]-p[i-1]);
	}
  ans+=t;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define mk make_pair
#define pb push_back
#define pa pair<int,int>
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<"\n"
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-') w=-1;ch=getchar();} while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();} return w*s;}
int n,m,dis[1010][1010];
queue<pa> q;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
char s[1010];
int main()
{	
	n=read(),m=read();
	memset(dis,0x3f,sizeof(dis));
	for(rint i=1;i<=n;++i)
	{	scanf("%s",s+1);
	for(rint j=1;j<=m;++j){
		if(s[j]=='#'){
			dis[i][j]=0;
			q.push(mk(i,j));
		}
	}
	}
	while(!q.empty()){
		pa tmp=q.front();
		q.pop();
		int x=tmp.first,y=tmp.second;
		for(rint k=0;k<4;++k) {
			int nwx=x+dx[k],nwy=y+dy[k];
			if(nwx<1||nwy<1||nwx>n||nwy>m) continue;
			if(dis[nwx][nwy]>1e8){
				dis[nwx][nwy]=dis[x][y]+1;
				q.push(mk(nwx,nwy));
			}
		}
	}int Ans=0;
	for(rint i=1;i<=n;++i) for(rint j=1;j<=m;++j) Ans=max(Ans,dis[i][j]);
	cout<<Ans;
	return 0;
}	

Measured memory_bytes: 12432