akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int MOD = 1000000007;

vector<int> prime;
int prime_factor[1010] = {};

void primeenumeration(int n) {
  FOR(i, 2, n+1) {
    bool flag = true;
    FOR(j, 2, i) {
      if (j*j > i) break;
      if (i%j == 0) {
        flag = false;
        break;
      }
    }
    if (flag) prime.push_back(i);
  }
}

void primefactorization(int n) {
  for (int i = 0; n >= prime[i];) {
    if (n%prime[i] == 0) {
      n /= prime[i];
      prime_factor[prime[i]]++;
    } else {
      i++;
    }
  }
}

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

  int n;
  cin >> n;

  primeenumeration(1000);

  rep(i, n+1) {
    primefactorization(i);
  }

  ll ans = 1;
  rep(i, n+1) {
    ans = ans * (prime_factor[i]+1) % MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for x in range(1, H + max_damage):
    dp[x] = min(dp[x - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

print(ans)


Measured memory_bytes: 3664
#include<cstdio>
using namespace std;
long long n,m,x,y,dp[100010];
long long minn(long long a,long long b){
	return a>b?b:a;
}
int main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n*1000;i++)dp[i]=0x3f3f3f3f;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&x,&y);
		for(int j=n*1000;j>=y;j--)dp[j]=minn(dp[j],dp[j-y]+x);
	}
	int ans=0;
	for(int i=1;i<=n*1000;i++)if(dp[i]<=m)ans=i;
	printf("%lld",ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())

typedef	long long ll;

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int len;
	cin >> len;
	string s;
	cin >> s;

	set<int> letters[26];
	for (int i(0); i < len; ++i)
		letters[s[i]-'a'].insert(i+1);

	int q;
	cin >> q;
	while (q--)
	{
		int type;
		cin >> type;
		if (type == 1)
		{
			int pos; char c;
			cin >> pos >> c;
			letters[s[pos-1]-'a'].erase(pos);
			s[pos-1] = c;
			letters[s[pos-1]-'a'].insert(pos);
		}
		else
		{
			int l, r;
			cin >> l >> r;
			int cnt(0);
			for (int c(0); c < 26; ++c)
			{
				auto it = letters[c].lower_bound(l);
				if (it != letters[c].end() and *it <= r)
					++cnt;
			}
			cout << cnt << '\n';
		}
	}
	
}



Measured memory_bytes: 24220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  int n, k; cin >> n >> k;
  vi arr(n);
  rep(i,n) cin >> arr[i];

  sort(all(arr));

  int ans = 1e9;
  rep(i,n-k+1) ans = min(ans, arr[i+k-1] - arr[i]);
  cout << ans << endl;
}

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


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200, MAX_X = 100000;
int N, X;
int S[MAX_N+1];
ll dp[MAX_N+1][MAX_X+1];

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

  cin >> N >> X;
  rep(i, N) cin >> S[i];

  sort(S, S+N);
  reverse(S, S+N);

  int b = S[0];
  rep(i, N) {  
      int t = S[i+1];
      S[i+1] = b;
      b = t;
  }

  for (int x = 0; x <= X; ++x) dp[N][x] = x;
  for (int i = N-1; i >= 0; --i) {
      for (int x = 0; x <= X; ++x) {
          ll t = dp[i+1][x%S[i+1]];
          t = mod(t + dp[i+1][x]*(N-i-1)%MOD, MOD);
          dp[i][x] = t;
      }
  }

  cout << dp[0][X] << endl;

  return 0;
}


Measured memory_bytes: 157312
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

const double PI = 3.14159265358979;

template<class T>
using Graph = vector<vector<T>>;

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    printFixedDouble(((x/a < a*b/2) ? atan( a*b*b/(2*x) ) : atan( (b-x/(a*a))/(a/2) ))/PI*180, 10);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)return 0;
		for(i=1 ; i<=H ; i++){
			for(j=1 ; j<=W ; j++){
				if((i+j)%2==0)printf("#");
			else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }
    int q;
    cin>>q;
    vector<int>m(q);
    vector<bool>ok(q);
    rep(i,q){
        cin>>m[i];
        ok[i]=false;
    }
    for(int bit=0; bit<(1<<n); ++bit){
        int sum=0;
        rep(i,n){
            if(bit>>i&1){
                sum+=a[i];
            }
        }
        rep(i,q){
            if(sum==m[i]){
                ok[i]=true;
            }
        }
    }
    rep(i,q){
        cout<<(ok[i]==true?"yes":"no")<<endl;
    }
}


Measured memory_bytes: 3100
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,a[200005],l=1,r=1;
ll now,sum,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(;r<=n+1;r++)
	{
		while(now!=sum&&l<=n+1)
		{
			sum-=a[l];
			now^=a[l++];
		}
		if(l>n+1) break;
		ans+=r-l;
		sum+=a[r];
		now^=a[r];
	}
	printf("%lld",ans);
}

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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// どこで反転するかを全探索

int n, c, x, v, s, p, r;
vpii a, b;
int ma[100100], mb[100100], sma[100100], smb[100100];

signed main() {
	cin >> n >> c;
	rep(i,n) {
		cin >> x >> v;
		a.pb({x,v}), b.pb({c-x,v});
	}
	
	sort(all(a)), sort(all(b));
	rep(i,n) {
		sma[i] = (i==0 ? 0 : sma[i-1]) + a[i].se;
		smb[i] = (i==0 ? 0 : smb[i-1]) + b[i].se;
	}
	
	rep(i,n) {
		s += a[i].se - (a[i].fi - p);
		chmax(ma[i],s);
		chmax(r,s);
		if (0<i) chmax(ma[i],ma[i-1]);
		p = a[i].fi;
	}
	
	s = p = 0;
	rep(i,n) {
		s += b[i].se - (b[i].fi - p);
		chmax(mb[i],s);
		chmax(r,s);
		if (0<i) chmax(mb[i],mb[i-1]);
		p = b[i].fi;
	}
	
	// 時計回りにi番目まで回収してから逆に戻る
	rep(i,n) {
		s = sma[i] - a[i].fi*2;
		if (s>0) chmax(r, s + (i==n-1 ? 0 : mb[n-i-2]));
	}
	rep(i,n) {
		s = smb[i] - b[i].fi*2;
		if (s>0) chmax(r, s + (i==n-1 ? 0 : ma[n-i-2]));
	}
	cout << r << ln;
}

Measured memory_bytes: 6756
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "Yes" : "No")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int N, X, T;
    cin >> N >> X >> T;
    cout << ((N+X-1)/X)*T << endl;
}   

// Main

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

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define lli long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// int const mod = 7340033;
int const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 1e6+5;
int const inf = 1e18;
vector<int> p;
int b[N];
map<int, int> m1[10005];
map<int, int> m2;
void pre(){
    for(int i=2;i<N;i++){
        if(b[i] == 0){
            p.pb(i);
            for(int j=i;j<N;j+=i){
                if(b[j] == 0) b[j] = i;
            }
        }
    }
}

void solve(){
    int i,j,l;
    int n;
    cin>>n;
    int a[n];
    int sm = 1;
    for(i=0;i<n;i++){
        int x; cin>>x;
        while(x > 1){
            m1[i][b[x]]++;
            m2[b[x]] = max(m1[i][b[x]] , m2[b[x]]);
            x = x/b[x];
        }
    }

    for(auto y:m2){
        int f = y.first;
        int cnt = y.second;
        sm = sm*power(f,cnt,mod);
        sm %= mod;
    }

    // for(i=0;i<n;i++){
    //     for(j=0;j<p.size();j++){
    //         m2[p[j]] = max(m2[p[j]] , m1[i][p[j]]);
    //     }
    // }

    // cout<<sm<<endl;

    int ans = 0;

    for(i=0;i<n;i++){
        int x = sm;
        for(auto y:m1[i]){
            int f = y.first;
            int cnt = y.second;

            // int z = m2[f] - cnt;
            if(cnt > 0) {
                int w = power(f,cnt,mod);
                w = inverse(w);
                x = x*w;
            }
            x %= mod;
        }
        // cout<<x<<endl;
        ans += x;
        ans %= mod;
    }
    cout<<ans<<endl;
}   

int32_t main(){
    IOS;
    int t;
    t = 1;
    pre();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

*/

Measured memory_bytes: 12276
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  while (in.hasNext()) {
	int ans = 0;
	for (int a = in.nextInt(), b = in.nextInt(), i = in
	    .nextInt(); i > 0; i--) {
	  ans += (a * 10 / b) % 10;
	  a = a * 10 % b;
	  if (a == 0) break;
	}
	System.out.println(ans);
  }
}
}

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

#define pb push_back
typedef long long ll;
typedef vector<long long> vll;
#define fo(i,a) for(ll i=0;i<a;i++)
#define Fo(i,a,b) for(ll i=a;i<b;i++)


void solve(){
    ll x,a[5];
    fo(i,5){
        cin>>a[i];
        if(a[i] == 0)
            x = i+1;
    }
    cout<<x<<"\n";
}


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

	ll t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  // 締め切りに近い方から, 最大の選んでく
  int n, m;
  cin >> n >> m;
  vector<vector<int> > x(m + 1);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    x[a].eb(b);
  }

  ll ans = 0;
  priority_queue<int> q;
  rep3(i, 1, m + 1) { // 猶予
    for (int j : x[i]) q.push(j);
    if (sz(q) == 0) continue;
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
  return;
}


Measured memory_bytes: 5632
n=gets.to_i
s=[]
n.times{|i|s[i]=gets.chomp.chars}
dame=(s.size-s.uniq.size==0)? 0:1
for i in 0..n-2
  dame+=1 if s[i][-1]!=s[i+1][0]
end
puts dame>=1? :No : :Yes


Measured memory_bytes: 14276
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string input;
        while ((input = Console.ReadLine()) != null)
        {
            string[] s = input.Split(' ');
            int[] a = new int[4];
            int[] b = new int[4];
            for (int i = 0; i < 4; i++)
            {
                a[i] = int.Parse(s[i]);
            }
            input = Console.ReadLine();
            s = input.Split(' ');
            for (int i = 0; i < 4; i++)
            {
                b[i] = int.Parse(s[i]);
            }
            int hit = 0;
            HashSet<int> set = new HashSet<int>(); 
            for (int i = 0; i < 4; i++)
            {

                if (a[i] == b[i])
                {
                    hit++;
                    set.Add(i);
                }
            }
            int blow = 0;
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (set.Contains(i)) continue;
                    if (set.Contains(j)) continue;
                    if (a[i] == b[j])
                    {
                        blow++;
                        
                    }
                }
            }
            Console.WriteLine(hit + " " + blow);
        }
    }
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;
using vb=vector<bool>;using vs=vector<string>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<typename T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){o<<'('<<p.fst<<", "<<p.snd<<')';return o;}

#define P first
#define X P.first
#define Y P.second
#define R second

using pll=pair<ll,ll>;

template<class T>
double dist(const pair<T, T> &p1, const pair<T, T> &p2) {
  T dx = p1.first - p2.first;
  T dy = p1.second - p2.second;
  return sqrt(dx * dx + dy * dy);
}

void Main() {
  pll s, t;
  s.fst = read<int>();
  s.snd = read<int>();
  t.fst = read<int>();
  t.snd = read<int>();
  int n = read<int>();
  vector<pair<pll, int>> C(n);
  rep(i, n) {
    C[i].X = read<int>();
    C[i].Y = read<int>();
    C[i].R = read<int>();
  }

  vd D(n);

  rep(i, n) {
    double d = max(0.0, dist(C[i].P, s) - C[i].R);
    D[i] = d;
  }

  //cout << "D:"; rep(ii,sz(D)) cout << ' ' << D[ii]; cout << endl;

  vb done(n);

  while (1) {
    int mav = -1;
    ll mac = 1e18;
    rep(i, n) if (!done[i]) {
      if (D[i] < mac) {
        mac = D[i];
        mav = i;
      }
    }
    if (mav == -1) break;

    int v = mav;
    done[v] = 1;

    rep(i, n) {
      double d = max(0.0, dist(C[i].P, C[v].P) - C[i].R - C[v].R);

      if (D[i] > D[v] + d) {
        D[i] = D[v] + d;
      }
    }
  }

  double ans = dist(s, t);
  rep(i, n) {
    double d = max(0.0, dist(C[i].P, t) - C[i].R);
    ans = min(ans, D[i] + d);
  }

  _p("%.10f\n", ans);

}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 384
while true
m,f,r=gets.split(" ").map(&:to_i)
break if m==-1 && f==-1 && r==-1

grade="F"
if m == -1 || f == -1
    grade="F"

elsif (m + f) >=80 
    grade= "A"
elsif (m + f) >=65
    grade= "B"
elsif (m + f)>=50
    grade="C"
elsif (m + f)>=30
    if r >= 50
        grade= "C"
    else
        grade= "D"
    end
end

puts grade


end








Measured memory_bytes: 6872
A,B,C,D = map(int,input().split())
count = 0

#A-Bの中でCで割れる最小数
if A%C==0:
  lowC=A//C
else:
  lowC=A//C+1
#A-Bの中でCで割れる最大数
highC=B//C
numC = (highC-lowC)+1

#A-Bの中でDで割れる最小数
if A%D==0:
  lowD=A//D
else:
  lowD=A//D+1
#A-Bの中でDで割れる最大数
highD=B//D
numD = (highD-lowD)+1


#まず最大公約数を求める
a=C
b=D
if a<b:a,b=b,a
while a%b!=0:
  a,b=b,a%b
gcd=b
#CとDの最小公倍数
lcm=C*D//gcd

#A-Bの中でlcmで割れる最小数
if A%lcm==0:
  lowlcm=A//lcm
else:
  lowlcm=A//lcm+1
#A-Bの中でlcmで割れる最大数
highlcm=B//lcm
numlcm = (highlcm-lowlcm)+1
total=((numC+numD)-numlcm)
print(((B-A)+1)-total)

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    int x, n;
    cin >> x >> n;
    int ans = 1000000;
    
    set<int> a;
    rep(i,n){
        int p; cin >> p;
        a.insert(p);
    }
    
    reps(p,-1000,1000){
        if(a.count(p)) continue;
        if(abs(x - ans) >= abs(x - p)){
            if(abs(x - ans) == abs(x - p)){
                ans = min(ans, p);
            }else{
                ans = p;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>

char str[200005];
int ch;
int sp = 0;

int main()
{

	while((ch = getchar()) != EOF) {

		if (ch == 'S') {
			sp++;
			str[sp] = 'S';
		} else if (ch == 'T') {
			if(str[sp] == 'S') {
				sp--;
			} else {
				sp++;
				str[sp] = 'T';
			}
		}
	}

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

	return 0;
}


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

int main()
{
        int a, b, c;
        cin >> a >> b >> c;
        int ans = a * 100 + b * 10 + c;
        if (ans % 4 == 0) cout << "YES" << endl;
        else cout << "NO" << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e10

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
//	char ch;
//	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    //lli a,b;
    cin >> s1;
    if(s1=="ABC")	cout<<"ARC";
    else	cout<<"ABC";
    
    
}













int main()
{
	long long int t=1,c=1;
	//scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <cstring>
#include <sstream>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;

ll power(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) {
            res = res * a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    string s;
    cin >> s;
    int n = s.length();
    if (s[n - 1] == 's') s += "es";
    else s += "s";
    cout << s << endl;
    return 0;
}







Measured memory_bytes: 3664
/**
 * Created by hiramekun at 20:58 on 2020-04-19.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n - 1);
    cin >> a;

    vl ans(n);
    rep(i, n-1) {
        ans[a[i] - 1]++;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

#define ld long double
#define int long long
#define pii pair<int,int>
#define X first
#define Y second
#define mp make_pair
#define MOD 1000000007ll
#define inf 1000000000000000ll

using namespace std;

inline int binexp(int a,int b,int m)
{
	int res=1;
	a%=m;
	while(b)
	{
		if(b&1)
		{
			res=(res*1ll*a)%m;
		}
		a=(a*1ll*a)%m;
		b>>=1;
	}
	return res;
}


signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int j=0,ans=0;
	while(j<n-1)
	{
		ans++;
		j+=k-1;
	}
	cout<<ans<<"\n";
	return 0;
}  


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << (double)W * H / 2 << " ";
    if(x != W / 2 || y != H / 2){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[2100][2100];
long long int res[2100][2] = {};

int main(){
    string SS, S[2] = {"", ""}, hoge = " ";
    cin >> SS;
    int K;
    cin >> K;
    for(int i = 0; i < SS.size(); i++){
        if(SS[i] == 'L' || SS[i] == 'R'){
            hoge[0] = '0' + (SS[i] == 'R');
            S[0] += hoge;
        }else{
            hoge[0] = '0' + (SS[i] == 'U');
            S[1] += hoge;
        }
    }
    for(int n = 0; n < 2; n++){
        for(int p = 0; p < 2; p++){
            for(int i = 0; i < 2100; i++){
                for(int j = 0; j < 2100; j++){
                    DP[i][j] = -INF;
                }
            }
            DP[0][0] = 0;
            for(int i = 0; i < S[n].size(); i++){
                for(int j = 0; j <= K; j++){
                    if(S[n][i] == '0' + (p + j) % 2){
                        DP[i + 1][j] = max(DP[i + 1][j], DP[i][j] - 1);
                    }else{
                        DP[i + 1][j] = max(DP[i + 1][j], DP[i][j] + 1);
                    }
                    DP[i][j + 1] = max(DP[i][j + 1], DP[i][j]);
                }
            }
            for(int j = 0; j <= K; j++){
                DP[S[n].size()][j + 1] = max(DP[S[n].size()][j + 1], DP[S[n].size()][j]);
                res[j][n] = max(res[j][n], DP[S[n].size()][j]);
            }
        }
    }
    long long int ans = 0;
    for(int i = 0; i <= K; i++){
        ans = max(ans, res[i][0] + res[K - i][1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 37704
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N, K; cin >> N >> K;
  vector<int> v(N);
  for(int i=0; i<N; i++)
    cin >> v[i];
  
  vector<int> vl, vr;
  int ans = 0, tmp;
  for(int l=0; l<=min(N, K); l++){
    vl.clear();
    for(int i=0; i<l; i++)
      vl.push_back(v[i]);

    for(int r=0; r<=min(N-l, K-l); r++){
      vr.clear();
      for(int i=0; i<r; i++)
        vr.push_back(v[N-1-i]);
      vr.insert(vr.end(), vl.begin(), vl.end());
      sort(vr.begin(), vr.end());
      
      for(int k=0; k<=K-l-r; k++){
        int elim = min(k, (int)vr.size());
        tmp = accumulate(vr.begin()+elim, vr.end(), 0);
        ans = max(ans, tmp);
      }
    }
  }
  
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define task "MAXFRAME"

#define nguyen_dz the_best
#define ll long long
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define Yes cout <<"Yes"<<endl;
#define No cout<<"No" <<endl;


using namespace std;
const ll  maxn= 4e6+100;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    if (fopen(task".INP","r"))
    {
        freopen(task".INP", "r", stdin);
        freopen(task".OUT", "w", stdout);
    }
    ll n;
    cin>> n;
    ll ans=0;
    for (long long  i=2; i*i<=n; i++)
    {

        if (n%i==0)
        {
            ll cnt=0;
            while (n%i==0)
            {
                n/=i;
                cnt++;
            }
            ll res= cnt;
            ll l=1, h= 1e8;
            while (l<=h)
            {
                ll m= (l+h)/2 ;
                if (m*(m+1)/2>res)
                    h=m-1;
                else
                    l=m+1;
            }
            ans+=h;
        }
    }
    if (n>1) ans++;

    cout <<ans;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class CumulativeSum{
public:
  vector<int> sum;
  CumulativeSum(){}
  CumulativeSum(vector<int> A){
    int n = A.size();
    sum.resize(n+1,0);
    for(int i=1;i<=n;i++) sum[i] += sum[i-1] + A[i-1];
  }
  int get(int l,int r){assert(l>=0 && r<=(int)sum.size());return sum[r] - sum[l];} //[l,r)
};


typedef pair<CumulativeSum,CumulativeSum> PC;

PC initPC(string a){
  int n = a.size();
  vector<int> A(n),B(n);
  for(int i=0;i<n;i++) A[i] = a[i] == 'A';
  for(int i=0;i<n;i++) B[i] = a[i] == 'B';
  return PC(CumulativeSum(A),CumulativeSum(B));
}

P getAB(int l,int r,PC &S){
  int a = S.first.get(l,r+1);
  int b = S.second.get(l,r+1);
  return P(a%3,b%3);
}

int isA(P p){
  int a,b; tie(a,b) = p;
  if(a == 0 && b == 2) return 1;
  if(a == 1 && b == 0) return 1;
  if(a == 2 && b == 1) return 1;
  return 0;
}

signed main(){
  string s,t;
  cin>>s>>t;

  PC S = initPC(s);
  PC T = initPC(t);
  
  int q;
  cin>>q;
  while(q--){
    int a,b,c,d;
    cin>>a>>b>>c>>d; a--,b--,c--,d--;
    //cout<<"s="<<s.substr(a,b-a+1)<<endl;
    //cout<<"t="<<t.substr(c,d-c+1)<<endl;
    P p = getAB(a,b,S);
    P q = getAB(c,d,T);
    //cout<<p<<" "<<q<<endl;
    int ans = isA(p) && isA(q);
    swap(p.first,p.second);
    swap(q.first,q.second);
    ans |= isA(p) && isA(q);
    ans |= p.first == p.second && q.first == q.second;
    cout<<(ans?"YES":"NO")<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 8896
import java.util.Scanner;
public class Main{
  public static int r1(int c){
    if(c == 1)
      return 1;
    else
      return c + r1(c - 1);
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = b - a;  // b は c 本目だとわかる
    int hight = r1(c);  // 棒の高さは hight
    System.out.println(hight - b);
  }
}

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

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	
	string abbrv;
	abbrv = s[0] + to_string(s.size() - 2) + s[s.size() - 1];
	cout << abbrv << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	string ans = "";
	REP(i, n) {
		ans += s[i];
		ans += t[i];
	}
	cout << ans;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    ll get() const { return x; }
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); return (t & 1) ? a*a*(*this) : a*a; }
    operator ll () const { return x; }
    operator string () const { return to_string(x); }
    friend istream& operator>>(istream& is, mint& a) { is>>a.x; return is; }

    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

class Combination {
public:
    int n;
    vector<mint> fc, fci;
    Combination(int n): n(n), fc(n+1,1), fci(n+1,1) {
        for (int i=2; i<=n; ++i) {
            fc[i] = fc[i-1] * mint(i);
            fci[i] = fci[i-1] / mint(i);
        }
    }
    mint operator()(ll n, ll k) {
        if (k == 0 || n == k) return 1;
        return fc[n] * fci[k] * fci[n-k];
    }
};

int main() {
    int N, M;
    cin >> N >> M;

    Combination C(500010);
    function<mint(ll,ll)> P = [&](ll n, ll k) {
        return C.fc[n] * C.fci[n-k];
    };

    mint p = P(M, N).pow(2);
    for (int i=1; i<=N; ++i) {
        if (i % 2) {
            p -= C(N, i) * P(M, i) * P(M - i, N - i).pow(2);
        } else {
            p += C(N, i) * P(M, i) * P(M - i, N - i).pow(2);
        }
    }
    cout << p << endl;

    return 0;
}

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

int digitCheck(int n) {
    bool flg = true;
    int digit = 1;
    while (flg) {
        n = n / 10;
        if (n == 0) {
            flg = false;
        } else {
            digit++;
        }
    }
    return digit;
}

int main() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (digitCheck(i) % 2 == 1) {
            ans++;
        }
    }
    printf("%d", ans);
    return 0;
}

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

 using namespace std;
 
 #define ll long long
 #define inf (int)1e9
 #define odd(x) x&1
 #define pow2(x) 1 << x
 #define log2bin(x) 32-__builtin_clz(x)-1
 #define popcnt(x) __builtin_popcount(x)
 #define mod7(x) x%1000000007

 #define cinarr(A,len) for(int i=0;i<len;i++){cin>>A[i];}
 #define coutarr(A,len) for(int i=0;i<len;i++){cout<<A[i]<<' ';}cout<<endl
 #define coutin(V) for(auto& i : V){cout << i << ' ';}cout<<endl // for vect and set
 #define coutmap(U) for(auto& i : U){cout << i.first << "->" << i.second << ' ';}cout<<endl // for map

 // ==== fast function ====
 /*
 bool prime(long long n){ const long long sqrtn = floor(sqrt(n)); if(n!=2 && n&1^1){return false;} for(long long i = sqrtn; i>=3; i-=2){ if(n%i==0){ return false;} } return true;}
 long long fastexp(long long base, long long pwr){ if(!pwr || !base)return 0; if(n&1^1){return fastexp(a*a, b/2);}else{return a*fastexp(a*a, b/2);}}
 */
 
/*========================================================================*/
/* strategi/note:

dp[t][d] itu max point get pada hari ke d, yg berakhir tipe t (0 swim, 1 catch, 2 homework) 

/================================*/



void solve(){
    int n;
    cin >> n;
    
    int p[3][n];
    for(int j = 0; j<n; j++){
        for(int i = 0; i<3; i++){
            cin >> p[i][j];
        }
    }
    
    int dp[3][n];
    dp[0][0] = p[0][0];
    dp[1][0] = p[1][0];
    dp[2][0] = p[2][0];
    
    for(int i = 1; i<n; i++){ // from second index
        dp[0][i] = p[0][i]+max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = p[1][i]+max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = p[2][i]+max(dp[0][i-1], dp[1][i-1]);
    }
    
    cout << max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1]) ) << endl;

}

int main(){
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     //cout.setprecision( ) // iomanip **

	solve();
//	int t;cin>>t;while(t--){solve();}
//	int t;cin>>t;((int))* ans=new ((int))[(( ))];solve();((int)) in;while(t--){cin>>in;cout<<ans[in-(( )) ];}delete[] ans;

	 //cout.flush(); cin.get();
     return 0;
}


Measured memory_bytes: 5900
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    cin >> n >> a >> b;
    
    int max_num, min_num;
    max_num = min(a, b);
    min_num = a + b - n;
    if(min_num <= 0){
        cout << max_num << " " << 0 << endl;
    }else{
        cout << max_num << " " << min_num << endl;
    }
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t mk = 0;
    dp[0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        for (auto j : irange(mk, -1L, -1L)) {
            auto r = min(k - j, a[i + 1] - a[i]);
            for (auto c : irange(0L, a.back() - a[i + 1] + 1)) {
                for (auto b : irange(c + 1, c + r + 1)) {
                    auto w = j + b - c;
                    dp[w][c] += dp[j][b];
                    if (dp[w][c] >= M) {
                        dp[w][c] -= M;
                    }
                }
            }

            for (auto c : irange(1L, a.back() - a[i + 1] + 1)) {
                dp[j][c] += dp[j][c - 1];
                if (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
        mk = min(k, mk + a[i + 1] - a[i]);
    }

    int64_t ans = 0;
    for (auto i : irange(0L, mk + 1)) {
        ans += dp[i][0];
    }

    cout << ans % M << endl;
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int n, d, a;
    cin >> n >> d;
    int ans = 0;
    rep(i, 0, n){
        cin >> a;
        if(a > d) ans += a - d;
    }
    if(ans == 0) cout << "kusoge" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

map<int, LL> dp[200005][2];  //! dp[i][j][k]  i: index of the last number checked, j: if the number at i was used, k: the count of numbers used so far

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

    int N;
    cin >> N;
    vector<LL> A(N);
    rep(i, N) cin >> A[i];

    dp[0][0][0] = 0;
    dp[0][1][1] = A[0];
    // cout << "dp[0][0][0] = 0" << endl; 
    // cout << "dp[0][1][1] = " << dp[0][1][1] << endl; 

    for (int i = 1; i < N; ++i) {
        for (int k = i/2; k <= (i+2)/2; ++k) {
            if (dp[i-1][1].find(k) != dp[i-1][1].end()) {
                if (dp[i-1][0].find(k) != dp[i-1][0].end()) {
                    dp[i][0][k] = max(dp[i-1][1][k], dp[i-1][0][k]);
                } else {
                    dp[i][0][k] = dp[i-1][1][k];
                }
            } else {
                if (dp[i-1][0].find(k) != dp[i-1][0].end()) {
                    dp[i][0][k] = dp[i-1][0][k];
                }
            }
            // if (dp[i][0].find(k) != dp[i][0].end()) {
            //     cout << "dp[" << i << "][0][" << k << "] = " << dp[i][0][k] << endl;         
            // }
            if (k) {
                dp[i][1][k] = dp[i-1][0][k-1] + A[i];
                // cout << "dp[" << i << "][1][" << k << "] = " << dp[i][1][k] << endl; 
            }
        }
    }

    cout << max(dp[N-1][0][N/2], dp[N-1][1][N/2]) << endl;

    return 0;
}


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

int main(){

    int a,b,c,x;
    cin >>a >>b >>c >>x;
    ll ans=0;
    for(int i=0;i*500<=x&&i<=a;i++){
        for(int j=0;j*100+i*500<=x&&j<=b;j++){
            int t=x-i*500-j*100;
            if(t/50<=c){
                ans++;
            }
        }
    }
    cout <<ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
	#include<string.h>
	int min(int a, int b);
	using namespace std;
	int main() {

		//A
		/*string str;
		cin >> str;

		if ((str == "AAA") || (str == "BBB")) {
			cout << "No";
		}else{
			cout << "Yes";
		}*/
		//B
		long long int n, a, b;
		cin >> n;
		cin >> a;
		cin >> b;

		cout << (long long int)(n / (a + b))* a + min(n % (a + b), a);



	}

	int min(int a, int b) {
		if (a < b) {
			return a;
		}
		else {
			return b;
		}
	}

Measured memory_bytes: 256