akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, K;
  cin >> N >> K;

  ll ans = 1;
  rep(i, N) {
    if (ans < K) {
      ans *= 2;
    } else {
      ans += K;
    }
  }
  ANS;
  return 0;
}

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

string check = "AGCT";
int main() {
  string str; cin >> str;
  int res = 0;
  for (int i = 0; i < str.size(); ++i) {
    for (int j = i + 1; j <= str.size(); ++j) {
      bool ok = true;
      for (int k = i; k < j; ++k) {
        bool ok2 = false;
        for (auto c : check) if (str[k] == c) ok2 = true;
        if (!ok2) ok = false;
      }
      if (ok) res = max(res, j - i);
    }
  }
  cout << res << endl;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

  int dp[200010][3];//dp_table

int main() {
    string s;
    cin>>s;

    // 初期化
    rep(i,20010)rep(j,3) dp[i][j] = 0;

    // 初期条件
    dp[0][1]=0;dp[0][2]=0;

    // ループ
    rep(i,s.size()){
      if(i>=1&&s[i-1]!=s[i]){
        chmax(dp[i+1][1],dp[i][1]+1);
      }
      chmax(dp[i+2][2],dp[i][1]+1);
      chmax(dp[i+1][1],dp[i][2]+1);
      if(i>=2&&(s[i+1]!=s[i-1]||s[i]!=s[i-2])){
        chmax(dp[i+2][2],dp[i][2]+1);
      }
    }

    // 答え
    cout<<max(dp[s.size()][1],dp[s.size()][2])<<endl;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s, t; cin >> s >> t;
    int n = s.length(), m = t.length();
    rFOR(i, 0, n - m + 1) {
        bool ng = false;
        FOR(j, 0, m)ng |= (s[i + j] != t[j] && s[i + j] != '?');
        if (ng)continue;
        FOR(j, 0, i)cout << (s[j] == '?' ? 'a' : s[j]);
        cout << t;
        FOR(j, i + m, n)cout << (s[j] == '?' ? 'a' : s[j]);
        cout << "\n";
        return 0;
    }
    cout << "UNRESTORABLE\n";
}


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

int main() {

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

  int n, m;
  cin >> n >> m;

  vector<long long> b(n), t(n), p(n);
  for (int i = 0; i < n; ++i)
    cin >> b[i] >> t[i] >> p[i];


  long long ans = 0;
  for (int i = 0; i < 8; ++i) {
    int f = (i&1), s = (i>>1)&1, th = (i>>2)&1;
    if (!f) f = -1;
    if (!s) s = -1;
    if (!th) th = -1;

    vector<long long> tmp(n);
    for (int j = 0; j < n; ++j) {
      tmp[j] = f * b[j] + s * t[j] + th * p[j];
    } 
    sort(tmp.begin(), tmp.end(), greater<long long> ());
    long long sum = 0;
    for (int j = 0; j < m; ++j)
      sum += tmp[j];
    ans = max(ans, sum);    
  }

  cout << ans << '\n';
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define fl(i,x) for(ll i=head[x],to;to=e[i].to,i;i=e[i].next)
#define inf 233333333
using namespace std;
/*---------------------------------------*/
namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
inline void outn(ll x){out(x);pc('\n');}
inline void swap(ll &x,ll &y){ll t=x;x=y;y=t;}
inline ll jdz(ll x){return x>=0?x:-x;}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
#define N 100001
ll a[4],k,x;
int main(){
	cin>>a[1]>>a[2]>>a[3]>>k;
	sort(a+1,a+4);
	Fur(i,1,k)a[3]<<=1;
	cout<<a[1]+a[2]+a[3];
}

/*

*/

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


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	string s;
	cin >> s;
	string ans(s.length(), 'x');
	cout << ans <<endl;
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int n = s.length;
		int[] value = new int[n + 1];
		for (int i = 0 ; i < n + 1 ; i++) {
			value[i] = 0;
		}
		
		rightWrite(s, value, 0, n);
		
		for(int i = 1 ; i < n ; i++) {
			if(s[i].equals("<")) {
				leftWrite(s, value, i -1);
				i = rightWrite(s, value, i, n);
			}
		}
		
		leftWrite(s, value, n -1);
		
		long ans= 0 ;
		for (int i = 0 ; i < n + 1 ; i++ ) {
			 ans +=value[i];
		}
		System.out.println(ans);
	}

	public static int rightWrite(String s[],int[] value , int i ,int n){

		int cnt = 1;
		while(i < n && s[i] .equals("<")) {
			if(value[i + 1] < cnt ) {
				value[i + 1] = cnt;
			}
			i++;
			cnt++;
		}
		
		
		return i;
	}
	
	public static void leftWrite(String s[],int[] value , int i){

		int cnt = 1;
		while(i >= 0 && s[i].equals(">")) {
			if(value[i] < cnt ) {
				value[i] = cnt;
			}
			i--;
			cnt++;
		}
	}
	
	
}


Measured memory_bytes: 66568
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
#include <string>
using namespace std;


int main() {
  long long N, W;
  cin >> N >> W;

  vector<long long> w(N), v(N);
  for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

  const long long maxV = pow(10, 5) + 1, maxW = pow(10, 9) + 1;

  // dp[i][j]: min weight s.t. total value >= j up to item i
  vector<vector<long long>> dp(N, vector<long long>(maxV, maxW));
  for (int i = 0; i < N; i++) dp[i][0] = 0;
  for (int j = 1; j < maxV; j++) if (j <= v[0]) dp[0][j] = w[0];

  for (int i = 1; i < N; i++) {
    for (int j = 1; j < maxV; j++) {
      if (j >= v[i]) dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
      else dp[i][j] = dp[i-1][j];
    }
  }

  for (int j = maxV - 1; j >= 0; j--) {
    if (dp[N-1][j] <= W) {
      cout << j << endl;
      return 0;
    }
  }

  return 1;
}


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

int main(){
long long a,b,c,n,ans=0;
cin>>a>>b>>c>>n;

for(int i=0;i<=n;i+=a)
for(int j=0;j<=n;j+=b){
if(i+j<=n)
if((n-(i+j)) % c == 0)
ans++; 
}

cout<<ans;
}

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

using namespace std;
using ll = long long;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> w(n + 1, 0);
    for (int i = 0; i < m; ++i) {
        int b;
        cin >> b;
        w[b] = -1;
    }
    w[0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (w[i] != -1 && w[i - 1] != -1) w[i] = (w[i] + w[i - 1]) % 1000000007;
        if (i > 1 && w[i] != -1 && w[i - 2] != -1) w[i] = (w[i] + w[i - 2]) % 1000000007;
    }
    cout << w[n] << endl;
}

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

#define int ll
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5, M = 3;

int A[N], DP[N][M];
bool P[N];

int Sign(int i) { return i & 1 ? -1 : 1; }

int32_t main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) DP[i][j] = -INF;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		if (i) {
			char c; cin >> c;
			P[i] = (c == '+');
		}
		cin >> A[i];
	}
	DP[0][0] = A[0];
	for (int i = 1; i < n; i++) for (int j = M - 1; j >= 0; j--) {
		if (P[i]) DP[i][j] = DP[i - 1][j] + A[i] * Sign(j);
		else if (j) DP[i][j] = DP[i - 1][j - 1] + A[i] * Sign(j);
		if (j + 1 < M) DP[i][j] = max(DP[i][j], DP[i][j + 1]);
	}
	cout << DP[n - 1][0] << endl;

	return 0;
}


Measured memory_bytes: 3456
n,a,b,c=map(int,input().split())
g=[input() for i in range(n)]
sousa=[]
for i in range(n):
    s=g[i]
    if s=="AB":
        if a==0 and b==0:print("No");exit()
        if a==1 and b==0:sousa.append("B");a=0;b=1
        elif a==0 and b==1:sousa.append("A");a=1;b=0
        else:
            if a>b:a-=1;b+=1;sousa.append("B")
            elif a==b and i<n-1 and g[i+1]=="BC":
                sousa.append("B");b+=1;a-=1
            else:b-=1;a+=1;sousa.append("A")
    elif s=="AC":
        if a==0 and c==0:print("No");exit()
        if a==1 and c==0:sousa.append("C");a=0;c=1
        elif a==0 and c==1:sousa.append("A");a=1;c=0
        else:
            if a>c:a-=1;c+=1;sousa.append("C")
            elif a==c and i<n-1 and g[i+1]=="BC":
                sousa.append("C");a-=1;c+=1
            else:c-=1;a+=1;sousa.append("A")
    else:
        if b==0 and c==0:print("No");exit()
        if c==1 and b==0:sousa.append("B");c=0;b=1
        elif c==0 and b==1:sousa.append("C");c=1;b=0
        else:
            if c>b:c-=1;b+=1;sousa.append("B")
            elif b==c and i<n-1 and g[i+1]=="AB":
                sousa.append("B");b+=1;c-=1
            else:b-=1;c+=1;sousa.append("C")
print("Yes")
for i in range(n):
    print(sousa[i])


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b; cin >> a >> b;
    string sa(b,a+'0'), sb(a,b+'0');
    cout << (sa > sb ? sb : sa) << endl;
    return 0;
}

Measured memory_bytes: 256
# K = 距離、 N = 家の数
K, N = map(int, input().split())

# 家の位置取得
An_list = list(map(int, input().split()))

# 家の差分(A1_A2、A2_A3、・・・AN-1_AN)データセット
An_diff_list = []
for i in range(N-1):
    tmp_diff = abs(An_list[i+1] - An_list[i])
    An_diff_list.append(tmp_diff)
# 最後のみ(An_A1)
tmp_diff = An_list[0] + K - An_list[N-1]
An_diff_list.append(tmp_diff)

# 差分の最大値
An_max = max(An_diff_list)

print(K-An_max)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  if (n == 1) {
    cout << m << '\n';
    return 0;
  }
  int ans = -1;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      if ((long long)i * n <= m) {
        ans = max(ans, i);
      }
      if (i >= n) {
        ans = max(ans, m / i);
      }
    }
  }
  assert(ans != -1);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 200;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    long long R;
    scanf("%lld", &R);
    std::vector<long long> r(R);
    for (int i = 0; i < R; i++)
    {
        ll tmp;
        cin >> tmp;
        --tmp;
        r[i] = tmp;
    }
    SORT(r);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for (int i = 0; i < M; i++)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    warshall_floyd(N);

    ll ans = INF;
    do
    {
        ll tmp = 0;
        for (int i = 1; i < R; i++)
        {
            ll a, b;
            b = r[i];
            a = r[i - 1];
            tmp += dist[a][b];
        }
        ans = min(ans, tmp);
    } while (next_permutation(r.begin(), r.end()));

    cout << ans << endl;
    return 0;
}


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

#define maxnum 100
#define maxk 100000
int main() {
    int n, k;
    vector<int> vec;
    cin>>n>>k;
    int num;
    int result[maxk]={0};
    for (int i = 0; i< n; ++i) {
        cin>>num;
        vec.push_back(num);
    }
    for (int i=0;i <=k ; ++i) {
        result[i] = 1; // the second
    }
    for (int i= vec.front(); i<=k; ++i) {
        for (auto ele: vec) {
            if (i>= ele) {
                if (result[i - ele] == 1) {
                    result[i] = 0;
                    break;
                }
            }
        }
    }
    cout<< ((result[k]==0)?"First":"Second") << endl;
    return 0;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	ms := make([]int, n)
	for i, _ := range ms {
		fmt.Scan(&ms[i])
	}

	sum := 0
	min := ms[0]
	for _, m := range ms {
		sum += m
		if m < min {
			min = m
		}
	}
	r := (x - sum) / min

	fmt.Println(n + r)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

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

const int MAX = 300001;
ll fc[MAX]; // fc[i] := iの階乗
ll fci[MAX]; // fci[i] := iの階乗の逆元

ll modpow(ll a, ll b) {
    if ( ! b) return 1;
    if (b % 2) return (a * modpow(a, b-1)) % mod;
    ll t = modpow(a, b/2);
    return (t * t) % mod;
}

void init_fact() {
    fc[0] = fc[1] = 1;
    for (int i=2; i<MAX; ++i) {
        fc[i] = (fc[i-1] * i) % mod;
    }
    fci[0] = fci[1] = 1;
    for (int i=2; i<MAX; ++i) {
        fci[i] = (fci[i-1] * modpow(i, mod-2)) % mod;
    }
}

ll C(ll n, ll a) {
    ll res = 1;
    for (ll i=n; i>n-a; --i) {
        res *= i;
        res %= mod;
    }
    res *= fci[a];
    res %= mod;
    return res;
}

int main() {
    init_fact();
    ll n, a, b;
    cin >> n >> a >> b;
    
    ll res = modpow(2, n) - 1;
    res += mod - C(n, a);
    res %= mod;
    res += mod - C(n, b);
    res %= mod;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n,ma,mb=MI()
	dp=[[10**6]*(n*10+15) for i in range(n*10+15)]
	for i in range(n+1):
		dp[0][0]=0

	for _ in range(n):
		a,b,c=MI()
		for aa in range(n*10+1,-1,-1):
			for bb in range(n*10+1,-1,-1):
				dp[a+aa][b+bb]=min(dp[aa][bb]+c,dp[a+aa][b+bb])

	ans=10**6

	for i in range(1,1000):
		try:
			ans=min(ans,dp[ma*i][mb*i])
		except:
			break

	print(ans if ans<10**6 else -1)





























if __name__ == "__main__":
	main()


Measured memory_bytes: 69276
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        COrdinaryBeauty solver = new COrdinaryBeauty();
        solver.solve(1, in, out);
        out.close();
    }

    static class COrdinaryBeauty {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int d = in.nextInt();

            if (d == 0) {
                out.println((double) (m - 1) / n);
                return;
            }

            out.println((double) 2 * (m - 1) * (n - d) / n / n);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
	string line;
	for(;cin>>line,line!="#";){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--,b--,c--,d--;
		vector<string>v;
		string s;
		for(auto e:line){
			if(e=='/')v.push_back(s),s="";
			else if(e=='b')s+=e;
			else s+=string(e-'0','.');
		}
		v.push_back(s);
		swap(v[a][b],v[c][d]);
		for(int i=0;i<v.size();i++){
			int c=0;
			for(auto e:v[i]){
				if(e=='b'){
					if(c)cout<<c;
					cout<<e;
					c=0;
				}else{
					c++;
				}
			}
			if(c)cout<<c;
			cout<<(i<v.size()-1 ? '/' : '\n');
		}
	}
}

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

long long N, C, x[100009], r[100009], c1[100009], c2[100009];

int main() {
	cin >> N >> C;
	for (int i = 1; i <= N; i++) cin >> x[i] >> r[i];
	long long maxn1 = 0, sum1 = 0;
	for (int i = 1; i <= N; i++) {
		sum1 += r[i]; maxn1 = max(maxn1, sum1 - x[i]);
		c1[i] = maxn1;
	}
	long long maxn2 = 0, sum2 = 0;
	for (int i = N; i >= 1; i--) {
		sum2 += r[i]; maxn2 = max(maxn2, sum2 - (C - x[i]));
		c2[i] = maxn2;
	}
	long long maxn3 = 0, sum3 = 0;
	for (int i = 1; i <= N; i++) {
		sum3 += r[i]; maxn3 = max(maxn3, (sum3 + c2[i + 1]) - x[i] * 2);
	}
	long long maxn4 = 0, sum4 = 0;
	for (int i = N; i >= 1; i--) {
		sum4 += r[i]; maxn4 = max(maxn4, (sum4 + c1[i - 1]) - (C - x[i]) * 2);
	}
	cout << max({ maxn1,maxn2,maxn3,maxn4 }) << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
inline int min(int x,int y,int z){return min(x,min(y,z));}
inline int max(int x,int y,int z){return max(x,max(y,z));}
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
#define N 305
int f[N][N][N];
string s;
int a[N],n,m;
signed main()
{
	cin>>s>>m;
	int cur=0;
	for(int i=0;i<(int)s.length();i++)
	{
		if(s[i]=='1') cur++;
		else a[++n]=cur,cur=0;
	}
	m=min(m,(int)s.length()-n);
	a[++n]=cur;
	f[n+1][0][0]=1;
	for(int i=n;i>=1;i--)
	{
		for(int j=0;j<=m;j++)
		{
			for(int k=0;k<=j;k++)
			{
				for(int c=0;c<=min(a[i],j,k);c++)
				{
					f[i][j][k]=add(f[i][j][k],f[i+1][j-c][k-c]);
				}
				for(int c=1;c+k<=m;c++)
				{
					f[i][j][k]=add(f[i][j][k],f[i+1][j][k+c]);
				}
			}
		}
	}
	// for(int i=1;i<=n;i++)
	// {
		// for(int j=0;j<=m;j++)
		// {
			// for(int k=0;k<=j;k++) printf("%d %d %d : %d\n",i,j,k,f[i][j][k]);
		// }
	// }
	int ans=0;
	for(int i=0;i<=m;i++) ans=add(ans,f[1][i][0]);
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 31036
#!/usr/bin/env python3

a = input()

L = len(a)

ans1 = 0
ans2 = 0

for i in range(L):
    if i%2 == 0:
        ans1 += 0 ^ int(a[i])
        ans2 += 1 ^ int(a[i])
    else:
        ans1 += 1 ^ int(a[i])
        ans2 += 0 ^ int(a[i])

if ans1 < ans2:
    print(ans1)
else:
    print(ans2)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  S[K - 1] = (char)(S[K - 1] - 'A' + 'a');
  cout << S << "\n";
  return 0;
}

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

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

    vector<long> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    vector<int> B(N);

    // 売る = -1,何もしない = 0 , 買う = 1
    if (A.at(N - 1) > A.at(N - 2))
    {
        B.at(N - 1) = -1;
        B.at(N - 2) = 1;
    }
    else
    {
        B.at(N - 1) = 0;
        B.at(N - 2) = -1;
    }

    for (int i = N - 2; i > 0; i--)
    {
        // 買う予定
        if (B.at(i) == 1)
        {
            // 前日の方が安ければ買うのをやめる。
            // 前日に買う事にする。
            // 値段が同じであれば前日に買う。
            if (A.at(i) >= A.at(i - 1))
            {
                B.at(i) = 0;
                B.at(i - 1) = 1;
            }
            // 前日の方が高い場合、
            // たくさん買えるようにするために前日に売る。
            else
            {
                B.at(i - 1) = -1;
            }
        }
        // 売る予定
        else if (B.at(i) == -1)
        {
            // 前日の方が安い場合、
            // たくさん売れるようにするために買う。
            if (A.at(i) > A.at(i - 1))
            {
                B.at(i - 1) = 1;
            }
            // 前日の方が高い場合は売るのをやめる。
            // 前日に売る事にする。
            // 同じ値段の場合、前日に売ることにする。
            else
            {
                B.at(i) = 0;
                B.at(i - 1) = -1;
            }
        }
    }


    // 所持金
    long money = 1000;

    // 所持株数
    long stock_cnt = 0;

    for (int i = 0; i < N; i++)
    {
        // 買う
        if (B.at(i) == 1)
        {
            stock_cnt += money / A.at(i);
            money = money % A.at(i);
        }
        // 売る
        else if (B.at(i) == -1)
        {
            money += stock_cnt * A.at(i);
            stock_cnt = 0;
        }
    }

    cout << money << endl;
    return 0;
}

Measured memory_bytes: 3580
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = (int)s.size();
    REP(i,l-1){
        if(s.substr(i,2)=="AC"){
            puts("Yes");
            return 0;
        }
    }
    puts("No");

    return 0;
}

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

int main()
{
  int h,n;
  cin>>h>>n;
  
  int totaldm=0;
  vector<int> a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
    totaldm+=a.at(i);
  }
  
  if(totaldm>=h)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
    

Measured memory_bytes: 640
import heapq
 
def FUNCTION(A, M):
    heapq.heapify(A)
    for i in range(M):
        heapq.heappush(A, int(heapq.heappop(A) / 2))
    return -sum(A)

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))
print(FUNCTION(A, N[1]))

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

int main() {
	int N;
  	double ans;
  cin >> N;
  
  if (N % 2 == 0){
    ans = (double)(N / 2) /(double) N;
  	cout << ans << endl;
  }
  else if (N % 2 != 0){
    ans = (double)(N / 2 + 1) /(double) N ;
  	cout << ans << endl;
  }
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int64_t a, b, k;
    cin >> a >> b >> k;

    if(a <= k) cout << "0 " << max(INT64_C(0), a+b-k) << endl;
    else cout << a - k << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  double a, ans = 0.0, denominator = 0.0;
  for(int i=0; i<n; i++){
    cin >> a;
    denominator += 1/a;
  }
  ans = 1/denominator;
  printf("%lf\n", ans);
  return 0;
}			

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string n;
	cin >> n;
	if (n[0] == '9' || n[1] == '9') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] inputs = Console.ReadLine().Split(' ');
        int Aint = int.Parse(inputs[0]);
        int Bint = int.Parse(inputs[1]);
        int Cint = int.Parse(inputs[2]);
        int Dint = int.Parse(inputs[3]);
        string result = "Yes";

        while(Aint > 0  && Cint > 0)
		{
            Aint -= Dint;
            if(Aint <= 0)
			{
                result = "No";
			}
            Cint -= Bint;
            if(Cint <= 0)
			{
                result = "Yes";
			}
		}
        Console.WriteLine(result);
    }
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

struct Team{
	int n,t;
	bool operator <(const Team &a)const{
		return t<a.t;
	}
};

struct Time{
	int s,m;
};

Team team[1000000];

int main(){
	int N;
	while(cin>>N,N){
		for(int i=0;i<N;i++){
			Time time;
			cin>>team[i].n; team[i].t = 0;
			for(int j=0;j<4;j++){
				cin>>time.m>>time.s; team[i].t += time.m*60+time.s;
			}
		}
		sort(team,team+N);
		printf("%d\n%d\n%d\n",team[0].n,team[1].n,team[N-2].n);
	}
	return 0;
}

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932


int main(){
    int mod=1000000007;
    for (;;) {
        int a,b,c;
        sc3(a,b,c);
        if (a==-1 && b==-1 && c==-1) break;
        if (a==-1 || b==-1) printf("F");
        else if (a+b>=80) printf("A");
        else if (a+b>=65) printf("B");
        else if (a+b>=50) printf("C");
        else if (a+b>=30 && c>=50) printf("C");
        else if (a+b>=30) printf("D");
        else printf("F");
        puts("");
    }
    return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int x=0;
  int ans=0;
  for(int i=0; i<N; i++){
    if(S.at(i)=='I') x++;
    else x--;
    ans=max(ans, x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/******************************************
* NICK : nikhilsinghh59 *
******************************************/


#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    
    ll x , n;
    cin >> x >> n;
    
    map<ll , bool>mp;
    for(ll i=0;i<n;i++){
        ll t;
        cin >> t;
        mp[t] = true;
    }
    
    ll diff=0;
    while(true) {
        if(mp.find(x - diff)==mp.end()) {
            cout << x - diff;
            return 0;
        }
        if(mp.find(x + diff)==mp.end()) {
            cout << x + diff;
            return 0;
        }
        diff++;
    }
    
    
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
	int n, m, l, i, j, k=0, a[100][100], b[100][100];
	long long c[100][100] = {};
	scanf("%d %d %d", &n, &m, &l);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d", &a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d", &b[i][j]);
		}
	}
	while(k!=m){
		for(i=0;i<n;i++){
			for(j=0;j<l;j++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
		k++;
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			printf("%ld", c[i][j]);
			if(j != l-1) printf(" ");
			else printf("\n");
		}
	}
}


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

int main() {
  
  int n;
  cin >> n;
  
  if((n%10 == 2)||(n%10 == 4)||(n%10 == 5)||(n%10 == 7)||(n%10 == 9)){
    cout << "hon" << endl;
  }else if((n%10 == 0)||(n%10 == 1)||(n%10 == 6)||(n%10 == 8)){
     cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3596
def attack_survival(n, k, q, ali):

    count = [0]*n
    ans = []

    for i in ali:
        count[i-1] += 1

    for i in range(n):
        if k+count[i]-q > 0:
            ans.append("Yes")
        else:
            ans.append("No")

    return ans

def main():
    n, k, q = map(int, input().split())
    ali = [int(input())for i in range(q)]
    ans = attack_survival(n, k, q, ali)
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 8620
#include<bits/stdc++.h>
const int N=1e5+10;
const long long P=1e9+7;
using namespace std;

long long n,k,a[N],fac[N],inv[N];
long long s,ma,mi,ans;

long long read()
{
	long long a,f=1;
	char c;
	c=getchar();
	while(c<'0'||c>'9')
	{
	  if(c=='-') f=-1;
	  c=getchar();
	}
	a=c-'0';
	c=getchar();
	while(c>='0'&&c<='9')
	{
	  a=a*10+c-'0';
	  c=getchar();
	}
	return a*f;
}

long long qpow(long long x,long long b)
{
	long long y;
	if(b==0) return 1;
	if(b==1) return x;
	y=qpow(x,b/2)%P;
	y=y*y%P;
	if(b%2) y=y*x%P;
	return y;
}

int main()
{
	long long i;
	n=read(); k=read();
	for(i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	fac[0]=1;
	inv[0]=1;
	for(i=1;i<=n;i++)
	{
	  fac[i]=(fac[i-1]*i)%P;
	  inv[i]=qpow(fac[i],P-2);
	}
	for(i=k;i<=n;i++)
	{
	  s=a[i]%P;
	  if(k-1!=0)
	  {
	  	s=(s*fac[i-1])%P;
	  	s=(s*inv[k-1])%P;
	    s=(s*inv[i-k])%P;
	  }
	  ma=(ma+s)%P;
	}
	for(i=1;i<=n-k+1;i++)
	{
	  s=a[i]%P;
	  if(k-1!=0)
	  {
	  	s=(s*fac[n-i])%P;
	  	s=(s*inv[k-1])%P;
	    s=(s*inv[n-i-k+1])%P;
	  }
	  mi=(mi+s)%P;
	}
	ans=((ma-mi)%P+P)%P;
	printf("%lld\n",ans%P);
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        if(s.matches("^[0-9]{" + a + "}-[0-9]{" + b + "}$")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

using ll = long long;
using ld = double;
using pii = pair<int, int>;
using cd = complex<ld>;

const int N = 70;

ll cnt[N][N];

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

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s.find('.') != string::npos) {
			int cnt = s.end() - find(s.begin(), s.end(), '.');
			s += string(10 - cnt, '0');
			s.erase(s.find('.'), 1);
		} else {
			s += string(9, '0');
		}
//		cerr << s << endl;
		ll y = stoll(s);
		int cnt2 = 0, cnt5 = 0;
		while (y % 2 == 0) {
			cnt2++;
			y /= 2;
		}
		while (y % 5 == 0) {
			cnt5++;
			y /= 5;
		}
		cnt[cnt2][cnt5]++;
//		cerr << cnt2 << " " << cnt5 << endl;
	}
	ll res = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int l = 0; l < N; l++) {
					if (i + k >= 18 && j + l >= 18 && cnt[i][j] > 0 && cnt[k][l] > 0) {
						if (i == k && j == l) {
							res += cnt[i][j] * (cnt[i][j] - 1);
						} else {
							res += cnt[i][j] * cnt[k][l];
						}
					}
				}
			}
		}
	}
	cout << (res / 2);
	return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=998244353;

ll dp[3001][3001] = {0};
int main(){
  ll N;
  ll S;
  cin>>N>>S;
  vector<ll> A(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
  }
  dp[0][0] = 1;
  for(int i(0);i<N;i++){
    for(int j(0);j<=S;j++){
      dp[i+1][j] += dp[i][j]*2;
      dp[i+1][j] %= MOD;
      if(j+A[i] <= S){
        dp[i+1][j+A[i]] += dp[i][j];
        dp[i+1][j+A[i]] %= MOD;
      }
    }
  }
  cout << dp[N][S]%MOD << endl;
  return 0;
}



Measured memory_bytes: 73920
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <cmath>
using namespace std;

void insertionSort(int* A, int N) {
	for (int i = 1; i < N; i++) {
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		for (int i = 0; i < N-1; i++) {
			cout << A[i] << " ";
		}
		cout << A[N - 1] << endl;
	}
}


int main() {
	int length, elem[1000];
	cin >> length;
	for (int i = 0; i < length; i++) {
		cin >> elem[i];
	}
	for (int i = 0; i < length -1; i++) {
		cout << elem[i] << " ";
	}
	cout << elem[length - 1] << endl;

	insertionSort(elem, length);


}


Measured memory_bytes: 3088
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

a, b, c = map(int, input().split())
cnt = 0
for i in reversed(range(1, 101)):
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == c:
        break
print(i)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int max = 2 * n;
			string s = cin.Next();
			if (s[0] != 'B' || s[max - 1] != 'B') {
				Console.WriteLine(0);
				return;
			}

			bool[] lr = new bool[max];
			lr[0] = false;
			lr[max - 1] = true;
			int line = 1;
			for (int i = 1; i < max - 1; i++) {
				if (s[i] == 'B') {
					if (line % 2 == 0) {
						lr[i] = false;
						line += 1;
					} else {
						lr[i] = true;
						line -= 1;
					}
				} else {
					if (line % 2 == 0) {
						lr[i] = true;
						line -= 1;
					} else {
						lr[i] = false;
						line += 1;
					}
				}
			}

			int ln = lr.Where(x => x == false).Count();
			int rn = lr.Where(x => x == true).Count();
			if (ln != rn) {
				Console.WriteLine(0);
				return;
			}

			long ans = 1;
			for (int i = 1; i <= n; i++) {
				ans = (ans * i) % MOD;
			}

			int count = 0;
			for (int i = 0; i < max; i++) {
				if (lr[i] == false) {
					count += 1;
				} else {
					ans = (ans * count) % MOD;
					count -= 1;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

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

int main() {
	static long long N, K, A[200000], SUM[200010] = {}, COUNT = 0, ANS = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] %= K;
		A[i] = (A[i] - 1 + K) % K;
		SUM[i + 1] = (SUM[i] + A[i]) % K;
	}
	map<long long, long long> mp;
	if (K != 1) mp[0]++;
	for (int i = 1; i <= N; i++) {
		ANS += mp[SUM[i]];
		mp[SUM[i]]++;
		if (i >= K - 1) mp[SUM[i - K + 1]]--;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a1,a2,a,b,c,d;
    cin>>a>>b>>c>>d;
    a1=a*b;
    a2=c*d;
    if(a1>a2)
    {
        cout<<a1<<endl;
    }
    else if(a2>a1)
    {
        cout<<a2<<endl;
    }
    else 
    {
        cout<<a1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    // int q; cin >> q;
    int q = buf.next();
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        cout << accs[r] - accs[l - 1] << '\n';
    }
}


Measured memory_bytes: 1152