akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
        import java.math.BigDecimal;
        import java.math.BigInteger;
        import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int D = in.nextInt();
        while (true) {
            C -= B;
            if (C <= 0) {
                out.println("Yes");
                out.flush();
                return;
            }
            A -= D;
            if (A <= 0) {
                out.println("No");
                out.flush();
                return;
            }
        }
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}

Measured memory_bytes: 32708
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
char s[nmax],t[nmax];
int i,dp[2][nmax],q,a,b,c,d;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>(s+1)>>(t+1)>>q;
    for(i=1;i<=strlen(s+1);i++)dp[0][i]=dp[0][i-1]+s[i]-'A'+1;
	for(i=1;i<=strlen(t+1);i++)dp[1][i]=dp[1][i-1]+t[i]-'A'+1;
    while(q--)
	{
	  cin>>a>>b>>c>>d;
	  if((dp[0][b]-dp[0][a-1])%3==(dp[1][d]-dp[1][c-1])%3)cout<<"YES"<<endl;
	  else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

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

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define rep(i, n) for(int i = 0; i < n; ++i) 
#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) 

#define TRACE(x...) x
#define watch(x) TRACE(cout << #x" = " << x << endl)
#define watcharr(i, x) TRACE(cout << #x" = "); rep(i, sz(x)) cout << x[i] << " "; cout << endl

int main() {
	
	ifstream infile("input.in");
	if(infile.good()) cin.rdbuf(infile.rdbuf());
	
	int K, A, B;
	cin >> K >> A >> B;

	bool ok = false;
	for(int i = A; i <= B; i++) if(i % K == 0) { ok = true; break; }

	cout << (ok ? "OK" : "NG") << endl;
	
	if(infile.good()) infile.close();
	return 0;
	
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B, C; 
  cin >> A >> B >> C;

  int ans = 0;
  int MAX = max(A, max(B, C));
  while(A+2 <= MAX){
    A += 2;
    ans++;
  }
  while(B+2 <= MAX){
    B += 2;
    ans++;
  }
  while(C+2 <= MAX){
    C += 2;
    ans++;
  }

  int cnt = 0;
  if(A != MAX) cnt++;
  if(B != MAX) cnt++;
  if(C != MAX) cnt++;

  if(cnt == 1) ans += 2;
  if(cnt == 2) ans += 1;

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

double n,k;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    double res = 0;
    for(double i=1;i<=n;i++){
        int m = ceil(log(k/i)/log(2));
        if(m  <= 0){
            m=0;
        }
        res += pow(0.5, (double) m);
    }
    res = res/n;
    cout <<fixed << setprecision(10) << res << el;
    return 0;
}

Measured memory_bytes: 640
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); i++)

#define MAX 100001
#define NIL -1

using namespace std;

struct Node{int parent, left, right; };

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){ //深さを求める再帰関数
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeight(int u){ //高さを求める再帰関数
	int h1=0,h2=0;
	if(T[u].left != NIL) h1 = setHeight(T[u].left) + 1; //子がいるならそのこの子の高さに1をくわえる
	if(T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2); //高さの高い方を返す
}

int getSibling(int u){
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;
	return NIL;
}

void print(int u){
	cout << "node " << u;
	cout << ": parent = " << T[u].parent;
	cout << ", sibling = " << getSibling(u);
	int deg = 0;
	if(T[u].left != NIL) deg++;
	if(T[u].right != NIL) deg++;
	cout << ", degree = " << deg;
	cout << ", depth = " << D[u];
	cout << ", height = " << H[u];

	if(T[u].parent == NIL) cout << ", root" << endl;
	else if(T[u].left == NIL && T[u].right == NIL) cout << ", leaf" << endl;
	else cout << ", internal node" << endl;

}

int main(){
	int v,l,r,root=0;
    // 追加２, 以降 cin の入力元が 'input.txt' になる
	//提出時に消す！！
	//std::ifstream in("sample.txt");
	//std::cin.rdbuf(in.rdbuf());

	cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる
	int n;
	cin >> n;

	rep(i,n) T[i].parent = NIL;

	rep(i,n){
		cin >> v >> l >> r;
		T[v].left = l;
		T[v].right = r;
		if (l != NIL) T[l].parent = v;
		if (r != NIL) T[r].parent = v;
	}
	rep(i,n){
		if(T[i].parent == NIL) root = i;
	}
	setDepth(root,0);
	setHeight(root);

	rep(i,n) print(i);

	return 0;
}



Measured memory_bytes: 3236
def C():
    N = int(input())

    word_dict = dict()
    count = 0

    for i in range(N):
        word = ''.join(sorted(input()))
        if word not in word_dict.keys():
            word_dict[word] = 1
        else:
            count += word_dict[word]
            word_dict[word] += 1

    print(count)

if __name__ == '__main__':
    C()


Measured memory_bytes: 17848
#include <bits/stdc++.h>
#define PB push_back
#define MP std::make_pair
#define FI first
#define SE second
#define M 1000005
#define INF 1000000000
int n,S[M],top;
bool flag=1;
std::pair <int,int> Stack[M];
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
void Write(int x){
	if (x<10) putchar(x+'0');
	else Write(x/10),putchar(x%10+'0');
	return;
}
void Insert(int x,int up){
	while (Stack[top].FI>x) top--;
	if (Stack[top].FI==x) Stack[top].SE++;
	else Stack[++top]=MP(x,1);
	if (Stack[top].SE==up){
		if (x==1) return flag=0,void();
		--top,Insert(x-1,up);
	}
	return;
}
bool check(int x){
	flag=1;top=0;
	for (int i=2;i<=n&&flag;i++)
		if (S[i]<=S[i-1]) Insert(S[i],x);
	return flag;
}
int main(){
	n=read();int ml=2,mr=n;
	for (int i=1;i<=n;i++) S[i]=read();
	for (int i=1;i<n;i++) flag&=(S[i]<S[i+1]);
	if (flag) return !printf("1");
	while (ml<=mr){
		int mid=(ml+mr)/2;
		if (check(mid)) mr=mid-1;
		else ml=mid+1;
	}
	return Write(ml),0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int K;
    cin >> K;
    int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << x[K-1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)


int main(){
  int N,M,ans=0;
  string temp;
  vector<string> str;
  vector<int> num;

  cin >> N;
  REP(i,N){
    cin >> temp;
    if(i==0){
      str.push_back(temp);
      num.push_back(1);
    }
    
    else{
      REP(j,str.size()){
	if(temp==str.at(j)){
	  num.at(j)++;
	  break;
	}
	else if(j==str.size()-1){
	  str.push_back(temp);
	  num.push_back(1);
	  break;
	}
      }
    }
  }
  
  cin >>M;
  REP(i,M){
    cin >> temp;
    REP(j,str.size()){
      if(temp==str.at(j))num.at(j)--;
    }
  }

  REP(i,num.size())ans=max(num.at(i),ans);
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll M;
    cin>>M;
    cout<<48-M<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define foreach(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<int64, int64> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    LL ans = 0;
    REP(i, 1, n+1){
        if(to_string(i).length() % 2 == 1)
            ans++;
    }
    co(ans);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,m,k;
ll mem;
ll ans;

ll factorial(ll n,ll mod = mod){
  static ll dp[e5];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1))%mod;
}

ll powl(ll x,ll r,ll mod = mod){
  ll ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

ll inverse(ll x,ll mod = mod){
  return powl(x,mod-2,mod);
}

ll combination(ll n,ll m,ll mod = mod){
  if(n < m) return 0;
  return (((factorial(n)*inverse(factorial(m)))%mod)*inverse(factorial(n-m)))%mod;
}

int main(){
  cin >> n >> m >> k;
  for(ll i = 0;i < n;i++){
    for(ll j = 0;j < m;j++){
      mem += i*(i+1)/2*m+j*(j+1)/2*n;
      mem += (n-i)*(n-i-1)/2*m+(m-j)*(m-j-1)/2*n;
      mem %= mod;
    }
  }

  ans = mem * k;
  ans %= mod;
  ans *= inverse(2);
  ans %= mod;
  ans *= inverse(n*m);
  ans %= mod;
  ans *= k-1;
  ans %= mod;
  ans *= inverse(n*m-1);
  ans %= mod;
  ans *= combination(n*m,k);
  ans %= mod;
  cout << ans << endl;



}


Measured memory_bytes: 8064
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

const int INF = 1e9 + 5;

int N, best;
string S;
vector<vector<int>> adj;
vector<int> depth, piece_count, depth_sum, min_depth_sum;

void depth_dfs(int node, int parent) {
    depth[node] = parent < 0 ? 0 : depth[parent] + 1;
    piece_count[node] = S[node] - '0';
    depth_sum[node] = 0;

    for (int neighbor : adj[node])
        if (neighbor != parent) {
            depth_dfs(neighbor, node);
            depth_sum[node] += depth_sum[neighbor] + piece_count[neighbor];
            piece_count[node] += piece_count[neighbor];
        }
}

void answer_dfs(int node, int parent) {
    min_depth_sum[node] = depth_sum[node];
    vector<pair<int, int>> children;

    for (int neighbor : adj[node])
        if (neighbor != parent) {
            answer_dfs(neighbor, node);
            children.emplace_back(depth_sum[neighbor] + piece_count[neighbor], min_depth_sum[neighbor] + piece_count[neighbor]);
        }

    if (!children.empty()) {
        nth_element(children.begin(), --children.end(), children.end());
        int sum_except = 0;

        for (int i = 0; i < (int) children.size() - 1; i++)
            sum_except += children[i].first;

        if (children.back().second <= sum_except) {
            if (parent < 0 && depth_sum[node] % 2 == 0)
                best = min(best, depth_sum[node] / 2);

            min_depth_sum[node] = depth_sum[node] % 2;
        } else {
            min_depth_sum[node] = children.back().second - sum_except;
        }
    }
}

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

    cin >> N >> S;
    adj.assign(N, {});

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    best = INF;

    for (int root = 0; root < N; root++) {
        depth.assign(N, 0);
        piece_count.assign(N, 0);
        depth_sum.assign(N, 0);
        min_depth_sum.assign(N, 0);
        depth_dfs(root, -1);
        answer_dfs(root, -1);
    }

    cout << (best < INF ? best : -1) << '\n';
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int D;
vll C, T;
vvll S;

ll calcScore(vll &T) {
	vll last(26, -1);	
	ll score = 0;
	for (int i = 0; i < D; i++) {
		score += S[i][T[i]];
		last[T[i]] = i;
		for (int j = 0; j < 26; j++) {
			score -= (i-last[j])*C[j];
		}
	}
	return (score);
}

void Main() {
	cin >> D;
	C = makeVector(26, 0ll); cin >> C;
	S = makeVector(D, 26, 0ll); cin >> S;
	T = makeVector(D, 0ll);
	
	ll maxv = 0;
	int M = 100000;
	for (int i = 0; i < M; i++) {
		int d = rand()%D;
		int q = rand()%26;
		int tmp = T[d];
		T[d] = q;
		ll score = calcScore(T);
		if (score <= maxv) T[d] = tmp;
		else maxv = score;
	}
	for (int i = 0; i < D; i++) {
		cout << T[i]+1 << el;
	}
	//cout << maxv << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        while (sc.hasNext()){
            int studentsNum = sc.nextInt();
            if (studentsNum == 0)
                break;
            double point[] = new double[studentsNum];
            double sum = 0;
            for (int i = 0; i < studentsNum; i++){
                point[i] = sc.nextInt();
                sum += point[i];
            }
            double ave = sum / studentsNum;
            double sm = 0;
            for (int j = 0; j < studentsNum; j++){
                sm += Math.pow(point[j] - ave, 2);
            }
            double aa = sm / studentsNum;
            double result = Math.sqrt(aa);
            System.out.println(result);
        }
    }
}



Measured memory_bytes: 31316
#include<cstdio>
#include<algorithm>
using namespace std;
void func(int,int);
int main(void)
{
	char a[8][9];
	int aa[8][8],i,j,k,l,flg,ii,xx,yy;
	int px[7][3]={{1,0,1},{0,0,0},{1,2,3},{-1,0,-1},{1,1,2},{0,1,1},{1,-1,0}},
		py[7][3]={{0,1,1},{1,2,3},{0,0,0},{1,1,2},{0,1,1},{1,1,2},{0,1,1}};
	char mo[8]="ABCDEFG";
	while(scanf("%s",a[0])!=EOF)	{
		for(i=1;i<8;i++)	{
			scanf("%s",a[i]);
		}
		for(i=0;i<8;i++)	{
			for(j=0;j<8;j++)	{
				if(a[i][j]=='1')	{
					for(k=0;k<7;k++)	{
						flg=1;
						for(l=0;l<3;l++)	{
							xx=j+px[k][l];
							yy=i+py[k][l];
							if(xx<0 || xx>=8 || yy<0 || yy>=8 || a[yy][xx]!='1')	{
								flg=0;
								break;
							}
						}
						if(flg==1)	{
							ii=k;
							i=8;	j=8;	break;
						}
					}
				}
			}
		}
		printf("%c\n",mo[ii]);
					
	}
	return 0;
}


Measured memory_bytes: 968
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>

#define lengthof(x) (sizeof(x) / sizeof(*(x)))

using namespace std;

int w,h;
char inpMap[51][51]={'0'},ctemp;
const int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};

void dfs(int y,int x,char moji){
		
	for(int i=0;i<4;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];

		if(0<=nx && nx<w && 0<=ny && ny<h){
			if(inpMap[ny][nx]=='.'){
				inpMap[ny][nx]=ctemp;//(moji=='W')? 'w' : 'b';
				dfs(ny,nx,moji);
			}
			else if((moji=='B'&&inpMap[ny][nx]=='w')||(moji=='W'&&inpMap[ny][nx]=='b')){
				inpMap[ny][nx]='?';
				dfs(ny,nx,moji);
			}
		}
	}
}


void solve(int y, int x,char moji){
	if(moji=='W'){
		ctemp='w';
	}
	else if(moji=='B'){
		ctemp='b';
	}
	dfs(y,x,moji);
}


int main(){
	

	while(cin>>w>>h,w||h){
		int white=0,black=0;

		fill((int *)inpMap,(int *)inpMap+lengthof(inpMap),'0');
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>inpMap[i][j];
			}
		}

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(inpMap[i][j]=='W' || inpMap[i][j]=='B'){
					solve(i,j,inpMap[i][j]);
				}
			}
		}

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(inpMap[i][j]=='b'){
					black++;
				}
				else if(inpMap[i][j]=='w'){
					white++;
				}
			}
		}
		
		cout<<black<<' '<<white<<endl;
	}
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
#define printv(v) for(auto it : v) cout<<it<<" ";cout<<endl;
#define prec(n) fixed<<setprecision(n)
const int mod1 = 1000000007;
const int mod2 = 998244353;
const int N = 1e5;

int main()
{
	optimize

	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
	#endif

	int n;
	cin>>n;
	int ans = 0;
	
	// for(int i = 1; i <= n; i++)
	// {
	// 	for(int j = 1; j <= n; j++)
	// 	{
	// 		if(n-i*j > 0)
	// 			ans++;
	// 	}
	// }

	forab(c, 1, n)
	{
		for(int i = 1; i*i <= n-c; i++)
		{
			if((n-c)%i == 0)
			{
				ans++;

				if((n-c)%((n-c)/i) == 0 && i != (n-c)/i)
					ans++;
			}

		}
	}


	cout<<ans<<endl;
	

	return 0;
}

Measured memory_bytes: 3648
<?php

fscanf(STDIN, "%d", $N);

$fact = my_pow($N);

echo $fact;

function my_pow($num) {
    $count = 1;
    for ($i=1; $i < $num+1; $i++) {
       $count *= $i;
       $count = (int)($count % 1000000007);
    }
    return $count;
}

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

int main(){
    string s, t;
    cin >> s >> t;
    int ans =0;
    
    for(int i=0; i<s.size(); i++){
        if(s.at(i) != t.at(i)){
            ans++;
        }

    }
    cout << ans << endl;
}

Measured memory_bytes: 3920
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(mut x: i64, mut y: i64) -> i64 {
    while y != 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    x
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input!{
        n: usize,
        x: i64,
        a: [i64; n],
    }
    let mut g = 0;
    for a in a {
        g = gcd(g, (a - x).abs());
    }
    puts!("{}\n", g);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<stdio.h>
int main()
{
  int n=0,k=0;
  int p[1050];
  int sum=0; 
  int tmp=0;
  
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++)
  {
    scanf("%d",&p[i]);
  };
  
  for (int i=0; i<n; ++i) {
    for (int j=i+1; j<n; ++j) {
      if (p[i] > p[j]) {
        tmp =  p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }

  for (int i=0; i<k; i++){
    sum += p[i];
}
  printf("%d",sum);
  
  return 0;
};

  
          

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

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

    int L[N];
    for(int i=0;i<N;i++){
        cin >> L[i];
    }
    sort(L, L+N, greater<int>());

    int sums=0;
    for(int i=1;i<N;i++){
        sums += L[i];
    }
    if(sums>L[0]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long N;
void solve()
{
    vector < long > inp;
    long i,ans=0;
    for (i=0;i<N;i++)
    {
        long x;
        cin>>x;
        inp.push_back(x);
    }
    for (i=0;i<N;i++)
        if (inp[i]==i+1)
        {
            swap(inp[i],inp[i+1]);
            ans++;
        }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>N)
        solve();
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}




void solve()
{
  
  int r;
  cin >> r;

  cout<<r*r;

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3648
#include<cstdio>
using namespace std;
int main()
{
	char s[7];
	int i,flg;
	scanf("%s",s);
	if(s[2]==s[3]&&s[4]==s[5]) flg=1;
	else flg=0;
	if(flg==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner sn, PrintWriter out) {
            String s = sn.next();
            int res = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == '1') {
                    res++;
                }
            }
            out.println(res);
        }

    }
}



Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int n;
string s;

int check(int m){
  int mini=1e9;
  int maxm=-1e9;
  
  for(int i=0;i<m;i++){
    int len=n/m;
    int v=s[i*len+len-1];
    mini=min(mini,v);
    maxm=max(maxm,v);
    for(int j=0;j+1<len;j++){
      if(s[j]!=s[i*len+j])return 1e9;
    }
  }
  return maxm-mini;
}

int solve(){
  if(n==2)return 1e9;
  
  int maxm=-1e9;
  int mini=1e9;
  int i=0;
  while(i<n){
    int num=(s[i]-'0');
    i++;
    if(num==1&&i<n){
      num=num*10+(s[i]-'0');
      i++;
    }
    maxm=max(maxm,num);
    mini=min(mini,num);
  }
  return maxm-mini;
}

int main(){
  cin>>s;
  n=s.size();
  int ans=check(n);
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      ans=min(ans, check(i) );
      ans=min(ans, check(n/i) );
    }
  }

  cout<< min(ans,solve()) <<endl;
  return 0;
}



Measured memory_bytes: 3300
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int spk[100001], par[100001];

int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x, int y) {
    par[find(x)] = find(y);
}

int main(void) {
    int i, j, n, m;
    scanf("%d%d",&n,&m);
    REP (i,1,n) par[i] = i;
    REP (i,1,n) {
        int k;
        scanf("%d",&k);
        REP (j,k) {
            int l;
            scanf("%d",&l);
            if (spk[l] > 0) unite(spk[l],i);
            else spk[l] = i;
        }
    }
    bool ok = true;
    REP (i,1,n) if (find(i) != find(1)) ok = false;
    if (ok) puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+10;
int n,sum[N],nxt[N][3],dp[N];
char s[N];
void add(int &a, int b) {a=(a+b)%P;}
int main() {
	scanf("%s",s+1);
	n = strlen(s+1);
	REP(i,1,n) s[i] += -'a'+1;
	int ok = 0;
	REP(i,2,n) if (s[i]==s[i-1]) ok = 1;
	if (!ok) return puts("1"),0;
	REP(i,1,n) sum[i] = (sum[i-1]+s[i])%3;
	PER(i,0,n) {
		memcpy(nxt[i],nxt[i+1],sizeof nxt[0]);
		nxt[i][sum[i]] = i;
	}
	dp[0] = 1;
	REP(i,0,n) if (dp[i]) { 
		add(dp[nxt[i][(sum[i]+1)%3]],dp[i]);
		add(dp[nxt[i][(sum[i]+2)%3]],dp[i]);
	}
	int ans = 0;
	REP(i,1,n) if (sum[i]==sum[n]) add(ans,dp[i]);
	printf("%d\n",ans);
}








Measured memory_bytes: 4992
// input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>()
           };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        _c: i64,
        k: i64,
    }

    if a >= k {
        println!("{}", k);
    } else if (a + b) >= k {
        println!("{}", a);
    } else {
        println!("{}", a - (k - a - b));
    }
}


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

int main() {
  int64_t n, K;
  cin >>  n >> K;
  int64_t N;
  N = n % K;
  while(N >= 0){
    N = N - K;
  }
  int64_t a,b;
  a = N * (-1);
  b = N + K;
  if (a < b){
    cout << a << endl;
  }
  else{
    cout << b << endl;
  }
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    string s;
    cin >> s;
    bool flag = true;
    int n = (int)s.size();
    auto ss = s;
    reverse(ss.begin(),ss.end());
    rep(i,n){
        if(ss[i] == 'b') ss[i] = 'd';
        else if(ss[i] == 'p') ss[i] = 'q';
        else if(ss[i] == 'd') ss[i] = 'b';
        else if(ss[i] == 'q') ss[i] = 'p';
    }
    if(s == ss){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	int a[101];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a, a+n, greater<int>());
	int A = 0, B = 0;
	for (int i = 0; i < n; ++i)
	{
		if (i % 2)
		{
			B += a[i];
		}
		else
		{
			A += a[i];
		}
	}
	cout << A - B << endl;
	return 0;
}

Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N,K; cin>>N>>K;
    ll arr[N];
    
    for(ll i=0;i<N;++i)
        cin>>arr[i];
    
    ll dp[N + 1][K + 1];
    memset(dp,0,sizeof(dp));
    
    dp[0][0] = 1;
    for(ll i=1;i<=N;++i)
    {
        ll pre[K + 1];
        //cout<<"For i: "<<i<<endl;
        for(ll k=0;k<=K;++k)
        {
            pre[k] = (((k > 0) ? pre[k - 1] : 0) + dp[i - 1][k]) % MOD;
            //cout<<k<<" "<<pre[k]<<endl;
        }
        
        for(ll k=0;k<=K;++k)
            dp[i][k] = (pre[k] - ((k > arr[i - 1]) ? pre[k - arr[i - 1] - 1] : 0) + MOD) % MOD;
    }
    
    //cout<<dp[1][1]<<endl;
    cout<<dp[N][K]<<endl;
}

Measured memory_bytes: 83192
//don't go gentle into
// the goodnight.

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

#define int       long long
#define ll        long long
#define fr        first
#define sec       second
#define pi        3.141592653589793
#define M         1000000007
#define mod       998244353
#define maxint    2147483647
#define minint    -2147483648
#define maxll     9223372036854775807
#define minll     -9223372036854775808
#define meme0(a)  memset(a,0,sizeof(a));
#define meme1(a)  memset(a,-1,sizeof(a));
#define i_m_speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open      freopen("input.txt","r",stdin);
#define close     freopen("output.txt","w",stdout);
#define v_int     vector<int >
#define v_ll      vector<long long >
#define pb        push_back
#define mk        make_pair
//upper_bound(begin(),end(),key)
//lower_bound(begin(),.end(),key);

ll expo(ll x , ll n , ll m){
    if(n==0)
        return 1;
    else if(n%2==0)
        return expo((x*x)%m , n/2 , m);
    else
        return (x*expo((x*x)%m,(n-1)/2,m))%m;

}
string toBinary(ll n)
{
    std::string r;
    while(n!=0){
        r=(n%2==0 ?"0":"1")+r;
        n/=2;
    }
    return r;
}
void solve(){
    int n;
    cin >> n;
    int a[n];
    int ans = 1;
    long double sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return;
        }
    }
    for(int i=0;i<n;i++){
        sum += log10(a[i]);
    }
    if(sum>18.1){
        cout << -1 << endl;
    
    return;}
    else{
        for(int i=0;i<n;i++)
            ans *= a[i];
    }
    if(ans > 1000000000000000000)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return;
}
int32_t main(){
    i_m_speed
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 4624
N = int(input())
S = input()

### 000~999の文字が作れるか試していく
cnt=0

# i: 100の位
for i in range(10):
  ii = S.find(str(i), 0)
  if ii < 0:
    continue # 数字iがSにない場合はスキップ

  # j: 10の位
  for j in range(10):
    ji = S.find(str(j), ii + 1) # 一番左のiの次の位置から探す
    if ji < 0:
      continue # 数字jがS[ii+1:]にない場合はスキップ

    # k: 1の位
    for k in range(10):
      ki = S.find(str(k), ji + 1) # S[ji+1:] から探す
      if ki >= 0:
        cnt += 1 # kがS[ji+1:]に存在するのであれば、ijkという暗証番号は作れる
      
print(cnt)

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(a.begin(), a.end());
    int mid = a[n/2];
    ll ans = 0;
    rep(i,n) ans += abs(a[i] - mid);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	string s; cin>>s;
//	int n=s.size();
	if(n%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	rep(i,0,n/2){
		if(s[i]!=s[n/2+i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 3588
N = int(input())
if N < 10:
    ans = N
elif N < 10 ** 2:
    ans = 9
elif N < 10 ** 3:
    ans = N - 10 ** 2 + 10
elif N < 10 ** 4:
    ans = 909
elif N < 10 ** 5:
    ans = N - 10 ** 4 + 910
else:
    ans = 90909
print(ans)


Measured memory_bytes: 2940
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define F first
#define S second
#define M 1000000007
	ll n,m,x,y;
	ll a[205],b[205];
	
	bool check1(ll i){
		if(i>a[n-1])
		return 1;
		return 0;
	}
	
	bool check2(ll i){
		if(i<=b[0])
		return 1;
		return 0;
	}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin>>n>>m>>x>>y;
	
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<m;i++)
	cin>>b[i];
	sort(a,a+n);
	sort(b,b+m);
	int l=x+1;
	int h=y;
	ll mid;
	while(l<h){
	mid=l+(h-l)/2;
	if(check1(mid)==0)
	l=l+1;
	else if(check2(mid)==0)
	h=h-1;
	else
	{
	cout<<"No War";
	return 0;
	}
	
	}
	cout<<"War";
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int a[5];
char b[5];

void solve(char ch)
{
    if(ch == 'P') a[0] = 1;
    else if(ch == 'W') a[1] = 1;
    else if(ch == 'G') a[2] = 1;
    else if(ch == 'Y') a[3] = 1;
}

int main()
{
    int n;
    int i;
    while(scanf("%d",&n) != EOF)
    {
        memset(a,0,sizeof(a));
        for(i = 0;i < n;i++)
        {
            scanf("%s",b);
            solve(b[0]);
        }
        for(i = 0;i < 4;i++)
        {
            if(!a[i])
            {
                printf("Three\n");
                break;
            }
        }
        if(i == 4) printf("Four\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int mod = 1e9+7;
const int INF = 2e9;
// const ll INF = 1e12;
const int MAX = 1e6;
// const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

// struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visited[MAX]; // 訪問状況

int main() {
    // input
    string s;
    cin >> s;
    // solve
    int n = s.size();
    vector<int> x(n);
    rep(i, n) {
        x[i] = s[i] - '0';
    }
    reverse(ALL(x));
    ll sum = 0;
    // if (n == 1) {
    //     sum = x[0];
    // }
    rep(bit, 1<<(n-1)) {
        bitset<10> B = bit;
        sum += x[0];
        ll d = 1;
        rep(i, n-1) {
            if (bit & 1<<i) {
                d *= 10;
            } else {
                d = 1;
            }
            sum += d * x[i+1];
        }
    }
    // output
    cout << sum << endl;
}

Measured memory_bytes: 3612