akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Main
{
    public static class Program
    {
        public static List<int> list = new List<int>();
 
        static void Main(string[] arg)
        {
            //int r = int.Parse(Console.ReadLine());
            var nm = GetIntList(Console.ReadLine());
            int answer = 0;
            //一致範囲を探る
            int LMax = 1;
            int RMin = nm[0];
            bool flag = true;

            for(int i = 0;i<nm[1];i++){
                var lr = GetIntList(Console.ReadLine());
                if(LMax < lr[0]){
                    if(RMin >= lr[0]){
                        LMax = lr[0];
                    }
                    else{
                        flag = false;
                        break;
                    }
                }
                if(RMin > lr[1]){
                    if(LMax <= lr[1]){
                        RMin = lr[1];
                    }
                    else{
                        flag = false;
                        break;
                    }
                }

            }
            if(flag){
                answer = RMin - LMax + 1;
            }

            //Console.WriteLine("lmax=" + LMax + "rmin" + RMin);
            Console.WriteLine(answer);
            Console.ReadLine();
 
        }
        
        #region libraries
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();
 
        }
        private static double[] GetDoubleList(string line)
        {
            return line.Split(' ').Select(x => double.Parse(x)).ToArray();
 
        }
        private static ulong[] GetUlongList(string line)
        {
            return line.Split(' ').Select(x => ulong.Parse(x)).ToArray();
        }
        private static long[] GetLongList(string line)
        {
            return line.Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        private static int SearchNearest(this IEnumerable<int> list, int target)
        {
            var min = list.Min(c => Math.Abs(c - target));
            return list.First(c => Math.Abs(c - target) == min);
        }
        public static bool IsOdd(int i)
        {
            return i % 2 == 1 ? true : false;
        }
        public static int Gcd(int a,int b)
        {
            if(a < b)
            {
                Gcd(b, a);
            }
            while (b != 0)
            {
                var rm = a % b;
                a = b;
                b = rm;
            }
            return a;
        }
        #endregion
    }
}


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

#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;


unordered_map<ll,ll> M;
string s;

ll dp(ll i, string prev){
    if(i == n)return 0;

    ll h = 0;
    rep(c1,0,prev.length()){
        h *= 12676;
        h += prev[c1];
    }
    h *= 11123845;
    h += i;
    if(M.find(h) != M.end())return M[h];

    string ss = "";
    ss += s[i];

    ll ans = -big;



    if(ss != prev){
        ans = max(ans, 1+dp(i+1,ss));
    }

    if(i < n-1){
        ss += s[i+1];
        if(ss != prev){
            ans = max(ans, 1+dp(i+2,ss));
        }
    }

   // cerr << i << " " << prev << "  " << ans << "\n";

    M[h] = ans;
    return ans;

}

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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);
    ll a,b,c,d;

   cin >> s;
   n = s.length();
   cout << dp(0,"") << "\n";

    return 0;
}


Measured memory_bytes: 45788
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,k;
  cin >> a >> b >> k;
  if(a>=k) {
    cout << a-k << " " << b << endl;
  }
  else {
    cout << 0 << " " << max(0LL,b-(k-a)) << endl;
  }
}



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

int n, q, a, b;

const int sz = 262144;
const ll inf = 1e18;
struct Seg{
	ll dat[2 * sz], ts;
	void ini(){ fill(dat + 1, dat + 2 * sz, inf); ts = 0; }
	void tupd(ll v){ ts += v; }
	void upd(int x, ll v){
		x += sz; dat[x] = v - ts;
		for(x /= 2; x; x /= 2) dat[x] = min(dat[2 * x], dat[2 * x + 1]);
	}
	ll get(int s, int e){
		ll ret = inf;
		for(s += sz, e += sz; s <= e; s /= 2, e /= 2){
			if(s % 2 == 1) ret = min(ret, dat[s++]);
			if(e % 2 == 0) ret = min(ret, dat[e--]);
		}
		return ret + ts;
	}
} S[2][3];

void ini(){ for(int i = 0; i < 6; i++) S[i / 3][i % 3].ini(); }

void upd(int t, int x, ll v){
	S[t][0].upd(x, v);
	S[t][1].upd(x, v + x);
	S[t][2].upd(x, v - x);
}

void tupd(ll v){ for(int i = 0; i < 6; i++) S[i / 3][i % 3].tupd(v); }

int main(){
	scanf("%d%d%d%d", &n, &q, &a, &b);
	ini();
	upd(0, b, 0);
	for(int x, lx = a; q--; lx = x){
		scanf("%d", &x);
		tupd(abs(lx - x));
		for(int t = 0; t < 2; t++){
			ll nd = min(S[t][0].get(lx, lx), min(S[!t][1].get(x, n) - x, S[!t][2].get(1, x) + x) - abs(lx - x));
			upd(t, lx, nd);
		}
	}
	printf("%lld\n", min(S[0][0].get(1, n), S[1][0].get(1, n)));
}

Measured memory_bytes: 24832
N = int(input())
inputs = [list(map(int, input().split())) for i in range(N-1)]
if len(inputs) != N:
  inputs. append([0, 0, 1])

for i in range(N):
  reach = 0
  for j in range(i, N):
    info = inputs[j]
    if reach < info[1]:
      reach = info[1]
    if (reach-info[1])%info[2] != 0:
      reach += (info[2] - (reach-info[1])%info[2])
    reach += info[0]
    
  print(reach)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define MAXV 1000000000
#define MOD 1000000007
using ll = long long;

bool operator<(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	return a.first < b.first;
}
int N; 


int main() {

	while (cin >> N) {
		if (N == 0) break;
		cin.ignore();
		vector<string> v;
		for (int i = 0; i < N; ++i) {
			string s; 
			getline(cin, s);
			v.push_back(s);
		}
		int dp[1010][1010] = { 0 };


		for (int i = 0; i < N; ++i) {
			if(v[i][0]=='.') dp[i][0]=1;
            if(v[0][i]=='.') dp[0][i]=1;
		}
		int ans = 0;
		for (int i = 1; i < N; ++i) {
			for (int j = 1; j < N; ++j) {
				if (v[i][j] != '.') {
					dp[i][j] = 0;
				}
				else {
					dp[i][j] = min({ dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1] }) + 1;
		
					ans = max(ans, dp[i][j]);
				}
			}
		}
		cout << ans << endl;
	}

}


Measured memory_bytes: 7892
#include<stdio.h>
int main(void) {
	double r;
	double s;
	double l;

	scanf("%lf", &r);

	s = r*r*3.141592653589793;
	l = 2 * r*3.141592653589793;
	printf("%10.6lf %10.6f\n",s,l);

	return 0;
	}

Measured memory_bytes: 660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long ll;
int N,X;
int main(void){
    scanf("%d %d",&N,&X);
    int minimum = 10000;
    int sum = 0;
    int m;
    for(int i = 0; i < N ; i++){
        scanf("%d",&m);
        sum += m;
        if(minimum > m) minimum = m;
    }
    
    printf("%d\n",(X-sum)/minimum+N);
}

Measured memory_bytes: 128
import heapq

def insert(t, x):
    global Qlist
    heapq.heappush(Qlist[t], -x)

def getMax(t):
    global Qlist
    if Qlist[t]:
        num = Qlist[t][0]
        print(-num)

def deleteMax(t):
    global Qlist
    if Qlist[t]:
        heapq.heappop(Qlist[t])


Qlist = []
n,q  = map(int, input().split())

for i in range(n):
    Qi = []
    heapq.heapify(Qi)
    Qlist.append(Qi)

for i in range(q):
    queryi = list(map(int, input().split()))

    if queryi[0] == 0:
        insert(queryi[1], queryi[2])
    
    elif queryi[0] == 1:
        getMax(queryi[1])

    else:
        deleteMax(queryi[1])
    


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

int main() {
    int n;
    long long a[100001], ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    a[n] = 0;
    sort(a, a+n+1);
    for(int i=1;i<=n;i++){
        a[i] += a[i-1];
    }
    for(int i=n-1;i>=0;i--){
        if(a[i+1] > a[i]*3){
            ans = n - i;
            break;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
K = int(input())


def digitsum(x):
    if x == 0:
        return 0
    return x % 10 + digitsum(x // 10)


ans = set(list(range(1, 9)))
for i in range(1, 15):
    base = 10**i - 1
    j = 0
    while True:
        x = int(str(j) + str(base))
        y = int(str(j + 1) + str(base))
        if x * digitsum(y) <= y * digitsum(x):
            ans.add(x)
            j += 1
        else:
            break
print(*sorted(ans)[:K], sep='\n')


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main()
{
      int n,w,T=0;
     cin>>n>>w;
      int m[n+1],v[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>m[i]>>v[i];
        T=T+v[i];
    }
    long long  int f[T];
     f[v[1]]=m[1];
     f[0]=0;
     for(int i=1;i<=T;i++)
     {
          f[i]=1000000000;
     }
    for(int i=1;i<=n;i++)
    {
       for(int j=T;j>=v[i];j--)
       {
           f[j]=min(m[i]+f[j-v[i]],f[j]);
       }
    }
    for(int i=T;i>=v[1];i--)
    {
        if(f[i]<=w)
        {
            cout<<i<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

#define INIT (-(ll)1e9)
#define p(a, b) make_pair(a, b)
typedef pair<int, ll> pi;

int N, M, P;
vector<pi> G[2501];

ll cost[2501];
bool visited[2501];
bool unuse[2501];

bool solve()
{
	bool ret = false;

	repc(i, 2, N) cost[i] = INIT;

	rep(LOOP, N) {
		bool updated = false;
		queue<int> q;

		repc(i, 1, N) visited[i] = false;
		visited[1] = true;
		q.push(1);

		while (!q.empty()) {
			int current = q.front(); q.pop();
			int size = G[current].size();

			rep(i, size) {
				pi item = G[current][i];
				int next = item.first;
				ll coin = item.second;

				if (!unuse[next]) {
					if (cost[current] + coin > cost[next]) {
						cost[next] = cost[current] + coin;
						updated = true;
					}

					if (!visited[next]) {
						visited[next] = true;
						q.push(next);
					}
				}
			}
		}

		if (LOOP == N - 1) ret = !updated;
	}

	return ret;
}

void set_unuse()
{
	repc(root, 1, N - 1) {
		bool reachN = false;
		queue<int> q;

		repc(i, 1, N) visited[i] = false;
		visited[root] = true;
		q.push(root);

		while (!q.empty()) {
			int current = q.front(); q.pop();
			int size = G[current].size();

			rep(i, size) {
				int next = G[current][i].first;

				if (next == N) {
					reachN = true;
					break;
				}

				if (visited[next]) continue;
				visited[next] = true;
				q.push(next);
			}
		}

		if (!reachN) unuse[root] = true;
	}
}

bool f[2501][2501];
int adj[2501][2501];
int A[5000], B[5000];

int main()
{
	int C;

	cin >> N >> M >> P;
	rep(i, M) {
		cin >> A[i] >> B[i] >> C;

		if (!f[A[i]][B[i]]) {
			f[A[i]][B[i]] = true;
			adj[A[i]][B[i]] = C - P;
		}
		else {
			adj[A[i]][B[i]] = max(adj[A[i]][B[i]], C - P);
		}
	}

	rep(i, M) {
		if (f[A[i]][B[i]]) {
			G[A[i]].push_back(p(B[i], adj[A[i]][B[i]]));
			f[A[i]][B[i]] = false;
		}
	}

	set_unuse();

	if (solve()) cout << max((ll)0, cost[N]) << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 30336
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        BigDecimal a = BigDecimal.valueOf(sc.nextLong());
        BigDecimal b = BigDecimal.valueOf(sc.nextDouble());
        BigDecimal ans = b.multiply(a);
        System.out.println(ans.longValue());
    }
}


Measured memory_bytes: 37716
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		cin>>b[i];
	}
	int m=0;
	rep(i,n){
		int ans=0;
		rep(j,i+1){
			ans+=a[j];
		}
		FOR(j,i,n){
			ans+=b[j];
		}
		m=max(ans,m);
	}
	cout<<m<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
int a[200005];
int vis[200005];
int main(){
	long long n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	int now=1;
	while(!vis[now]){
		vis[now]=v.size();
		v.push_back(now);
		now=a[now];
	}
	int s=v.size()-vis[now];
	int l=vis[now];
	if(l>k)
	cout<<v[k];
	else
	{
		k-=l;
		k%=s;
		cout<<v[l+k];
	}
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int inf = int (1e9) + int (1e5);
const ll infl = ll(2e18) + ll(1e10);
const ui M = 1E9 + 7;
const double eps = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define MP make_pair

int main() {
 //   freopen("in.txt", "r", stdin);
    int N;
    vi cnt(100002,0);
    cin >> N;
    vi A(N);
    FOR(i,N){
        int a;
        scanf("%d",&a);
        A[i]=a;
        cnt[a++]++;
        cnt[a++]++;
        cnt[a]++;
    }
    int m=0;
    FOR(i,100002){
        if (cnt[i]>m){
            m = cnt[i];
        }
    }
    cout << m;
    return 0;
}


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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);

  cin.tie(NULL);
  int a, b; cin >> a >> b;
  string s; cin >> s;
  int flag = true;
  flag &=  (s.size() == a+b+1);
  for (int i = 0; i < s.size(); ++i) {
    if (i == a) flag &= s[i] == '-';
    else { flag &= (s[i] <= '9' && s[i] >= '0');
    }
  }
  if (flag) std::cout << "Yes" << std::endl;
  else  std::cout << "No" << std::endl;


  return 0;
}



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


int main() {
    int l;
    string s;
    cin >> l >> s;
    int size = s.size();
    if(size > l){
        cout << s.substr(0,l) + "..." << endl;
        return 0;
    }
    cout << s;
    return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int n;
int a;
int c[300100],d[300100];
long long prekdk[300100],sufdk[300100],func[300100];
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		c[a]++;
	}
	for(int i=1;i<=n;i++)
		d[c[i]]++;
	for(int i=1;i<=n;i++)
		prekdk[i]=prekdk[i-1]+(long long)(i)*(long long)(d[i]);
	for(int i=n;i>=1;i--)
		sufdk[i]=sufdk[i+1]+(long long)(d[i]);
	for(int i=1;i<=n;i++)
		func[i]=(long long)(prekdk[i]/(long long)(i)+sufdk[i+1]);
	sort(func+1,func+n+1);
	int res;
	for(int i=1;i<=n;i++){
		res=(int)(lower_bound(func+1,func+n+1,(long long)(i))-func);
		cout<<n+1-res<<endl;
	}
	return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int h,w; cin >> h >> w;
	int n; cin >> n;
	int md = max(h,w);
	out((n-1)/md+1);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

const ll inf=1e18;
ll n,a,b,c,d,mi[3][66],cost[7];//,f[66][66][66]
unordered_map<ll,ll>Map;
ll f(ll n){
	if(!n)return 0;
	if(n==1)return d;
	if(Map.count(n))return Map[n];
	ll res=inf;if(1.0*n*d<inf)umin(res,n*d);
	rep(i,0,2){
		ll bas=mi[i][1],x=n/bas,lft=n%bas;
		if(x<n)umin(res,f(x)+cost[i]+d*lft);
		if(x+1<n)umin(res,f(x+1)+cost[i]+d*(bas-lft));
	}
	return Map[n]=res;
}
int main() {
	rep(i,0,2)mi[i][0]=1;
	mi[0][1]=2;mi[1][1]=3;mi[2][1]=5;
	rep(i,0,2)rep(j,2,60)mi[i][j]=min(mi[i][j-1]*mi[i][1],inf);
	int T;read(T);while(T--){
		read(n);read(a);read(b);read(c);read(d);
		cost[0]=a;cost[1]=b;cost[2]=c;
		/*rep(i,0,60)rep(j,0,60)rep(k,0,60)f[i][j][k]=inf;
		f[0][0][0]=0;ll res=inf;
		rep(i,0,60)rep(j,0,60)rep(k,0,60){
			ll cur=n/mi[0][i]/mi[1][j]/mi[2][k];
			if((double)cur*d<inf)umin(res,f[i][j][k]+cur*d);
			umin(f[i+1][j][k],f[i][j][k]+a+cur%2*d);
			umin(f[i][j+1][k],f[i][j][k]+b+cur%3*d);
			umin(f[i][j][k+1],f[i][j][k]+c+cur%5*d);
		}*/
		Map.clear();
		cout<<f(n)<<endl;
	}
	return 0;
}


Measured memory_bytes: 4144
#include <stdio.h>
//#include <tchar.h>
#include<set>
#include<deque>
#include<queue>
#include<map>
#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>

#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<33);
const llint ban = (big<<20);

int main(void){
	//di max7
	int i,j,N,M,a,ans;
	vector<int> per={1,2,3,4,5,6,7};
	vector<int>pera={1,2,3,4,5,6,7};
	vector<int> perg={1,2,3,4,5,6,7,8};
	vector<int> di={7,7,7,7,7,7,7};
	vector<int> ai={10000,10000,10000,10000,10000,10000,10000};
	vector<int>stz[5041];
	map<vector<int>,int> zts;
	static int dp[114][5140]={0};
	i=0;
	do {
		stz[i]=per;
		zts[per]=i;
		i++;
	} while(std::next_permutation(per.begin(),per.end()));
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a);
		di.pub(a);
	}
	for(i=0;i<N;i++){
		scanf("%d",&a);
		ai.pub(a);
	}
	for(i=0;i<7;i++){per[i]=i+1;}
	dp[6][zts[per]]=210000;
	for(i=7;i<N+7;i++){
		for(j=0;j<8;j++){
			perg[j]=j+1;
		}
		do {
			for(j=0;j<7;j++){
				if(perg[j]>perg[7]){ per[j]=perg[j]-1; } else{ per[j]=perg[j]; }
			}//per??????????????????
			for(j=0;j<7;j++){
				if(perg[j+1]>perg[0]){ pera[j]=perg[j+1]-1; } else{ pera[j]=perg[j+1]; }
			}//pera??????????????°??????
			ans=dp[i-1][zts[per]];
			for(j=0;j<7;j++){
				if(perg[j]<perg[7]&&di[i-7+j]>=7-j){
					ans+=ai[i-7+j];
				}
				if(perg[j]>perg[7]&&di[i]>=7-j){
					ans+=ai[i];
				}
			}
			dp[i][zts[pera]]=max(dp[i][zts[pera]],ans);
		} while(std::next_permutation(perg.begin(),perg.end()));
	}
	ans=0;
	for(i=0;i<5040;i++){
		ans=max(ans,dp[N+6][i]);
	}
	
	for(i=7;i>0;i--){
		if(N<i){ ans+=10000*(8-i); }
	}
	printf("%d\n",ans-490000);
	return 0;
}

Measured memory_bytes: 6272
n,k = list(map(int, input().split()))
s = input()

#print(s)

part = 1
for i in range(n-1):
    if(s[i]!=s[i+1]):
        part+=1
        
#print(part)

if(part%2 == 1):
    if(k>= (part-1)//2):
        print(n-1)
    else:
        print(n-1 - ((part-1)//2 - k)*2)
else:
    if(k >= part//2):
        print(n-1)
    else:
        print(n - (part//2 - k)*2)

Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const ll maxh=5e4+10;
const ll maxn=1010;
ll a[maxn],b[maxn];
ll dp[maxh];
int main()
{
    ios::sync_with_stdio(false);
    ll h,n;
    while(cin>>h>>n)
    {
        for(ll i=0;i<n;i++)
            cin>>a[i]>>b[i];
        memset(dp,inf,sizeof(dp));
        dp[0]=0;
        for(ll i=0;i<n;i++)
            for(ll j=0;j<=h;j++)
        {
            dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i]);
        }
        ll minn=inf;
        for(ll i=h;i<maxh;i++)
        {
            minn=min(minn,dp[i]);
        }
        cout<<minn<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
char s;
int n,ans,now;
int main() {
	scanf("%d",&n);
	getchar();
	for(int i=1;i<=n;i++){
		s=getchar();
		if(s=='I')now++;
		else now--;
		if(now>ans)ans=now;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
use std::io;


fn main() {
    let c1j = read_one::<String>().chars().collect::<Vec<char>>();
    let c2j = read_one::<String>().chars().collect::<Vec<char>>();
    if c1j[0] == c2j[2] && c1j[2] == c2j[0] && c1j[1] == c2j[1] {
        println!("YES");
    } else {
        println!("NO");
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
// g++ test.cpp && ./a.out < in
#pragma GCC optimize("O3")
using namespace std;
#define fi first
#define se second
#define pb push_back
#define loop(i, a, b) for (int i=a; i<(b); i++)
typedef long long ll;
typedef pair<int,int> pi;
const int INF = 1e9;
const int MOD = 1000000007;



void test_case() {
	int n; cin>>n;
	string s; cin>>s;
	int cnt=0,ans=0;;
	for(auto it: s) if(it=='R') cnt++;
	for(int i=0;i<cnt;i++) if(s[i]=='W') ans++;
	cout<<ans<<endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++) {
		test_case();
	}
	return 0;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for (int i = 0; i <= n - 3; i++) {
        if (s.substr(i, 3) == "ABC") ans++;
    }

    cout << ans;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    double time500[] = {35.5, 37.5, 40, 43, 50, 55, 70};
    double time1000[] = {71, 77, 83, 89, 105, 116, 148};
    string rank[] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};

    for(;;){
        double a, b;
        if(!(cin >> a >> b))
            return 0;

        int i = upper_bound(time500, time500 + 7, a) - time500;
        int j = upper_bound(time1000, time1000 + 7, b) - time1000;
        cout << rank[max(i, j)] << endl;
    }
}

Measured memory_bytes: 0
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1<<29;
int main(){
ll n;cin>>n;
ll h[n];
rep(i,n){cin>>h[i];h[i]--;}
bool ok=true;
rep(i,n-1){
   if(h[i]<=h[i+1]+1){
        if(h[i]==h[i+1]+1){
            h[i+1]++;
        }
   }

   else ok=false;
}
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

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

using namespace std;
using u64 = std::uint_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  int sum = 0;
  vector<int> C(N);
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    sum += C[i];
  }
  sort(C.begin(), C.end(), greater<int>());
  sum -= C[0];

  vector<int> D(N, -1);
  queue<int> que;
  que.push(0);

  int p = 0;
  D[0] = C[p++];
  while (!que.empty()) {
    int u = que.front();
    que.pop();

    for (int v : G[u]) {
      if (D[v] != -1) continue;

      D[v] = C[p++];
      que.push(v);
    }
  }

  cout << sum << '\n';
  for (int i = 0; i < N; i++) {
    cout << D[i] << (i == N - 1 ? '\n' : ' ');
  }
  return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int n,m;
	cin >> n >>m;
	vector<int> h(n);
	rep(i, n)cin>>h[i];

	int ans=0;

	vector<int> graph[n];
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--, b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	ans = n;
	rep(i,n){
		int hey = h[i];
		for(auto x:graph[i]){
			if(hey <= h[x]){
				ans --; 
				break;
			}
			continue;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 8812
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    if(a > b) swap(a, b);
    cout << c*10+b+a << "\n";
    return 0;
}


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

int main() {
	int n,m;
  	cin>>n>>m;
  
  string ans;
  if(n==1)ans="0";
  else if(n==2)ans="10";
  else ans="100";
  
  int count1=true;
  string count2="000";

  rep(i,m){
  	int a;char b;cin>>a>>b;a--;
    if(n>=2&&a==0&&b=='0'){
    	count1 = false;break;
    }
    
    else if(count2[a]=='0'){
    	ans[a]=b;
      	count2[a]='1';
    }
    else if(ans[a]!=b){
    	count1=false;
      	break;
    }
  }
    
    if(count1)cout<<ans<<endl;
    else cout<<-1<<endl;
      
  

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
int n, a[N], mk[N], f, gc;
void work(int x)
{
	for(int i = 2; i * i <= x; i++)
	{
		if(x % i == 0)
		{
			if(mk[i])
			{
				f = 1;
				return;
			}
			mk[i] = 1;
			while(x % i == 0) x /= i;
		}
	}
	if(x != 1)
	{
		if(mk[x])
		{
			f = 1;
			return;
		}
		mk[x] = 1;
	}
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
    	cin >> a[i];
    	work(a[i]);
	}
	gc = __gcd(a[1], a[2]);
	for(int i = 3; i <= n; i++) gc = __gcd(gc, a[i]);
	if(gc != 1) cout << "not coprime" << endl;
	else if(f) cout << "setwise coprime" << endl;
	else cout << "pairwise coprime" << endl;
	return 0;
}


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

int main() {
    cout << fixed << setprecision(0);
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    int64_t ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans << endl;
    return 0;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<int> word(26, 0);
  rep(i, H) {
    rep(j, W) {
      char a;
      cin >> a;
      word[a - 'a']++;
    }
  }

  // H=5 W=7
  // a b c d c b a
  // e f g h g f e
  // i j k l k j i
  // e f g h g f e
  // a b c d c b a

  // H=4 W=7
  // a b c d c b a
  // e f g h g f e
  // e f g h g f e
  // a b c d c b a

  // H=4 W=6
  // a b c c b a
  // e f g g f e
  // e f g g f e
  // a b c c b a

  int g1 = ((H % 2) && (W % 2)) ? 1 : 0;
  int g2 = 0;
  if (W % 2) g2 += H / 2;
  if (H % 2) g2 += W / 2;
  int g4 = H / 2 * W / 2;
  // cout << "g1=" << g1 << " g2=" << g2 << " g4=" << g4 << endl;

  while (g1--) {
    rep(i, 26) {
      if ((word[i] % 4 == 1) || (word[i] % 4 == 3)) {
        word[i] -= 1;
        break;
      }
    }
  }

  while (g2--) {
    bool found = false;
    rep(i, 26) {
      if (word[i] % 4 == 2) {
        word[i] -= 2;
        found = true;
        break;
      }
    }
    if (found) continue;

    rep(i, 26) {
      if (word[i] != 0 && word[i] % 4 == 0) {
        word[i] -= 2;
        break;
      }
    }
  }

  while (g4--) {
    rep(i, 26) {
      if (word[i] != 0 && word[i] % 4 == 0) {
        word[i] -= 4;
        break;
      }
    }
  }

  rep(i, 26) {
    if (word[i] != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
    #define N 300000

    int fac[N+100],invfac[N+100];

    int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
    int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
    int mul(int x,int y) {return 1ll*x*y%maxd;}
    ll qpow(ll x,int y)
    {
        ll ans=1;
        while (y)
        {
            if (y&1) ans=mul(ans,x);
            x=mul(x,x);y>>=1;
        }
        return ans;
    }
    int getinv(int x) {return qpow(x,maxd-2);}

    int C(int n,int m)
    {
        if ((n<m) || (n<0) || (m<0)) return 0;
        return mul(mul(fac[n],invfac[m]),invfac[n-m]);
    }

    void math_init()
    {
        fac[0]=invfac[0]=1;
        rep(i,1,N) fac[i]=mul(fac[i-1],i);
        invfac[N]=getinv(fac[N]);
        per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
    }
    #undef N
}
using namespace My_Math;

int n,a,b;
ll k;

int main()
{
    n=read();a=read();b=read();
    k=readll();
    math_init();
    int ans=0;
    rep(i,0,n)
    {
        if ((1ll*i*a<=k) && ((k-1ll*i*a)%b==0) && ((k-1ll*i*a)/b<=n))
        {
            int j=(k-1ll*i*a)/b;
            ans=add(ans,mul(C(n,i),C(n,j)));
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back
#define END cout << endl


int main() {
  ll n,m,q;
  cin >> n >> m >> q;

  ll cum[n+2][n+2];
  rep(i,n+2)rep(j,n+2) {
    cum[i][j] = 0;
  }

  rep(i,m) {
    ll l,r; cin >> l >> r;
    cum[l][r] += 1;
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      cum[i][j] += cum[i][j-1];
    }
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      cum[i][j] += cum[i-1][j];
    }
  }

  rep(i,q) {
    ll q,r;
    cin >> q >> r;

    cout << cum[r][r] + cum[q-1][q-1] - cum[q-1][r] - cum[r][q-1] << endl;
  }
}


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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

int main() {

    string s;
    getline(cin, s);

    for (int i = 0; i < sz(s); i++) 
        if (s[i] == '?')
            s[i] = 'D';

    cout << s << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#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 INF 2e9
#define MOD 1e9+7
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

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 InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

int ni() {
    int i;
    cin >> i;
    return i;
}

int main() {
    int N = ni();
    map<int, int> mp;
    REP(i, N) {
        mp[ni()]++;
    }
    ll ans = 0;
    int state = 0;
    for (auto itr = mp.rbegin(); itr != mp.rend(); itr++) {
        ll len = itr->first;
        int count = itr->second;
        if (state == 0) {
            if (count >= 4) {
                ans = len*len;
                state = 2;
                break;
            } else if (count >= 2) {
                ans = len;
                state = 1;
            }
        } else if (state == 1) {
            if (count >= 2) {
                ans *= len;
                state = 2;
                break;
            }
        }

    }

    cout << (state == 2 ? ans : 0) << endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    map<string,long> mp;
    
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll sum=0;
    for(auto it:mp){
        sum += (it.second)*(it.second-1)/2;
    }
    
    cout<<sum<<endl;
    
}


Measured memory_bytes: 11136
/* All men have limits. They learn what they are and learn
   not to exceed them, I ignore mine. -Batman           */

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

int main(){
int n[5];
for(int i=0;i<5;i++){
	cin>>n[i];
}
sort(n,n+5,greater<int>() );
for(int i=0;i<5;i++){
	if(i==4)cout<<n[i]<<endl;
	else cout<<n[i]<<" ";
}
return 0;
}

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

int main(){
    int W,H,x,y,r;

    cin >> W >> H >> x >> y >> r;

    if((0 <= x-r && x+r <= W )&&(0 <= y-r && y+r <= H)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3108
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b){
		if(c<b){
			d=b;
			b=c;
			c=d;
		}
	}
	
	
	if(a>b){
		d=a;
		a=b;
		b=d;
		if(c<b){
			d=b;
			b=c;
			c=d;
			if(a>b){
				d=a;
				a=b;
				b=d;
			}
		}
	}
	
	printf("%d %d %d\n",a,b,c);
	
	
	
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long Q,ch[501][501],mc,pc,p[100001],m[100001],n, bc, now, C, H, W, X[100000],K, Y, ans, r, l, numcon, N, M;
string S,s,a[101],b[101],c[101];
bool h,k[101];

int main() {
	cin >> N >> M;
	if (N%M == 0)cout << 0 << endl;
	else cout << 1 << endl;
	return 0;

}




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

int main()
{
  int A, B, X;
  cin >> A >> B >> X;
  
  if(((X - A) >= 0) && ((B - (X - A)) >= 0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

int main(void)
{
    string S, T;
    cin >> S >> T;

    int A, B;
    cin >> A >> B;

    string U;
    cin >> U;

    if (U == S)
        A--;
    else
        B--;

    cout << A << " " << B << endl;

    return 0;
}


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

#define ll long long 

using namespace std;

int a,b,c;
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b>>c;
    if (a==5 && b==5 && c==7) cout <<"YES";
    else if (a==5 && b==7 && c==5) cout<<"YES";
    else if (a==7 && b==5 && c==5) cout<<"YES";
    else cout<<"NO";
    
    
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int partition(int A[],int p,int r)
{
  int x,i,j,a,b;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      a=A[i];
      b=A[j];
      A[i]=b;
      A[j]=a;
    }
  }
  a=A[i+1];
  b=A[r];
  A[i+1]=b;
  A[r]=a;
  
  return i+1;
}


int main(){
  int i,q,n,A[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    if(i==q){
      printf("[%d]",A[i]);
    }else{
    printf("%d",A[i]);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2136
#include <stdio.h>

int main(void) {
	int A, B, C,D;
	scanf("%d%d%d%d", &A, &B, &C,&D);
	if (A >= B && C >= D) {
		printf("%d", B + D);
	}
	else if (A >= B && C < D) {
		printf("%d", B + C);
	}
	else if (A < B&&C >= D) {
		printf("%d", A + D);
	}
	else if (A < B&&C < D) {
		printf("%d", A + C);
	}


	return 0;

}

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

int main() {
  int n;
  cin >> n;
  int digit;
  for(int i=0;i<=5;i++){
    if( n>=pow(10,i) && n<pow(10,i+1) ){
      digit = i+1;
      break;
    }
  }
  int count =0;
  for(int i=0;i<digit-1;i++){
  	if( (i+1)%2 == 1){
      count += pow(10,i+1) - pow(10,i);
    }
  }
  if(digit%2==1){
    count += n-pow(10,digit-1)+1;
  }
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int kou,sou=114514,H,W;int main(){cin>>H>>W;char HW[H][W];for(int i=0;i<H;i++){for(int o=0;o<W;o++){scanf(" %c",&HW[i][o]);}}for(int i=1;i<H-1;i++){for(int j=1;j<H-i;j++){kou=0;for(int o=0;o<i;  o++){for(int f=0;f<W;f++){if(HW[o][f]!='W'){kou++;}}}for(int o=i;o<i+j;o++){for(int f=0;f<W;f++){if(HW[o][f]!='B'){kou++;}}}for(int o=i+j;o<H;o++){for(int f=0;f<W;f++){if(HW[o][f]!='R'){kou++;}}}sou=min(sou,kou);}}cout<<sou<<endl;}

Measured memory_bytes: 3140
//
// Created by MengHaitao on 2019/11/27 0027.
//
//insert sort
#include <iostream>
using namespace std;
int arr[1005],n;
void print()
{
    for (int i = 0; i < n; ++i) {
        cout<<arr[i];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
}
void insertSort()
{
    for (int key,j, i = 1; i < n; ++i) {
        key=arr[i];
        j=i;
        while(j>0&&arr[j-1]>=key)
        {
            arr[j]=arr[j-1];
            j--;
        }
        arr[j]=key;
        print();
    }
}
void solve()
{
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>arr[i];
    }
    print();
    insertSort();
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int A, B;
	cin >> A >> B;

	if((A+B)%2 == 1){
		cout << "IMPOSSIBLE" << '\n';
	}else{
		cout << (A+B) / 2 << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
#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<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#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++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  ll N; cin>>N;
  vector<ll> A;
  vector<ll> B;
  rep(i,N){
    ll a; cin>>a;
    A.push_back(a);
  }
  
  for(int i=N-1; i>=0; i-=2) B.push_back(A[i]);
  if(N%2!=0){
    for(int i=1; i<N-1; i+=2) B.push_back(A[i]);
  }
  if(N%2==0){
    for(int i=0; i<N-1; i+=2) B.push_back(A[i]);
  }
  
  rep(i,N) cout<<B[i]<<" ";
}
    

Measured memory_bytes: 5488
n=list(input())
if n[0]=="1":
  n[0]="9"
else:
  n[0]="1"
if n[1]=="1":
  n[1]="9"
else:
  n[1]="1"
if n[2]=="1":
  n[2]="9"
else:
  n[2]="1"
print("".join(n))

Measured memory_bytes: 3060
n = int(input())
s = [input() for i in range(n)]
c = [0 for i in range(4)]
for i in range(n):
    if s[i] == "AC":
        c[0] += 1
    elif s[i] == "WA":
        c[1] += 1
    elif s[i] == "TLE":
        c[2] += 1
    elif s[i] == "RE":
        c[3] += 1
print("AC x "+str(c[0]))
print("WA x "+str(c[1]))
print("TLE x "+str(c[2]))
print("RE x "+str(c[3]))

Measured memory_bytes: 79160
S = input()

if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
elif S == 'SAT':
  print(1)

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

int main() {
  int a;
  int b;
  int c;
    cin >> a >> b >> c;
  int Plan1;
  int Plan2;
  	Plan1 = a * b;
    Plan2 = c;
  if (Plan1 >= Plan2){
    cout << Plan2 << endl;
  }
  else if (Plan1 < Plan2){
    cout << Plan1 << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
int main(void)
{
	long long i,j,n,a[200000],m,k=1000000000+7,w;
	scanf("%lld",&n);
	m=0; w=0;
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		w+=a[i];
		w%=k;
	}
	for(i=0;i<n;i++){
		w-=a[i];
		if(w<0){
			w+=k;
		}
		m+=a[i]*w;
		m%=k;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 3268
# ABC153B
def f(n, k, h):
    if n <= k:
        print(0)
    else:
        h = sorted(h)[::-1]
        for i in range(k):
            h[i] = 0
        print(sum(h))

n, k = map(int, input().split())
h = list(map(int, input().split()))
f(n, k, h)

Measured memory_bytes: 26180
'use strict'

function main(input) {

    input = input.split("\n")
    input = input[0].split('')

    let ans = "AC"


    //found A
    if (input[0] != "A") {
        ans = "WA"
    }

    //found C
    //S の先頭から 3 文字目と末尾から 2 文字目の間（両端含む）
    let c = false
    let ci = 0
    for (let i = 2; i < input.length - 1; i++) {
        if (input[i] == "C" && !c) {
            c = true
            ci = i
        } else if (input[i] == "C" && c) {
            c = false //すでにCが見つかり、さらに　Cが見つかったら false
        }
    }
    if (!c) ans = "WA"


    // is lowercase
    let tmp = input;
    tmp[0] = 'a' // A 削除
    if (ci != 0) tmp[ci] = 'c' // C 削除

    tmp = tmp.join('')
    let boo
    boo = tmp.match(/^[a-z]+$/) ? true : false
    if (!boo) ans = 'WA'

    //judge
    console.log(ans)

}

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


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

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

//primitive data types
typedef long long ll;

//pair
typedef pair<ll,ll> pll;
#define mp(x,y) make_pair(x,y)
#define f first
#define s second

//vector
typedef vector<ll> vll;
typedef vector<pll> vpll;
#define pb(x) push_back(x)

//control statements
#define fori(i,start,end) for(ll i = start ; i <= end ; i++)
#define ford(i,start,end) for(ll i = start ; i >= end ; i--)

void solve(){
  ll N,W,x,y;
  cin>>N>>W;
  
  vpll items(N + 1);
  fori(i,1,N){
    cin>>x>>y;
    items[i] = mp(x,y);
  }
  
  vll K(W + 1, 0);
  fori(i,1,N)
    ford(j,W,items[i].f)
      K[j] = max(K[j], items[i].s + K[j - items[i].f]);
  cout<<K[W];
}

int main(){
  fastIO();
  ll t = 1;
  //cin>>t;
  while(t--){
    solve();
    cout<<"\n";
  }
  return 0;
}


Measured memory_bytes: 1024