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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    ll n, d, a;
    cin >> n >> d >> a;
    d = d*2;
    vector<pair<int, int>> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    queue<pair<ll,ll>> q;
    ll ans = 0, tot = 0;
    rep(i, n){
        ll x = p[i].first;
        ll h = p[i].second;
        while(q.size() && q.front().first < x){
            tot -= q.front().second;
            q.pop();
        }
        h -= tot;
        if(h > 0){
            ll b_n = (h+a-1)/a;
            ans += b_n;
            ll damage = b_n*a;
            tot += damage;
            q.emplace(x+d, damage);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    
    ll n,m;
    cin>>n>>m;
    priority_queue<pair<ll,ll>> q;

    rep(i,n){
        ll a;
        cin>>a;
        q.push(mp(a,1));
    }
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        q.push(mp(b,a));
    }
    ll rest=n;
    ll ans=0;
    while(rest>0){
        auto p=q.top();q.pop();
        // cout<<p.first<<" "<<p.second<<endl;
        if(p.second <= rest){
            rest-=p.second;
            ans+=p.second*p.first;
        } else {
            ans+=rest*p.first;
            rest=0;
        }
    }
    fin(ans);
}


Measured memory_bytes: 6384
# coding: utf-8
import collections
n=int(input())
D=list(map(int,input().split()))
m=int(input())
T=list(map(int,input().split()))
T_=list(set(T))
c = collections.Counter(D)
c2 = collections.Counter(T)
flg=True
for t in T_:
    #print(c[t], c2[t])
    if c[t] < c2[t]:
        flg=False
if flg:
    print("YES")
else:
    print("NO")

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

int main(){
    int n,k,tmp;
    int ans=0;
    cin>>n>>k;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;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++){
        ans+=p[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3576
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		// 標準入力からデータを読み込む準備
		Scanner sc = new Scanner(System.in);
		// 2つの文字の固まりをそれぞれ整数値と想定して読み込む 
		int area = 0;/* ここを変えて面積を求めよう */
		for(;;){
		int a = sc.nextInt();
		String b = sc.next();
		int c = sc.nextInt();
		if(b.equals("?")){
			break;
		}
		if(b.equals("+")){
			area = a+c;
		}
		if(b.equals("-")){
			area = a-c;
		}
		if(b.equals("*")){
			area = a*c;
		}
		if(b.equals("/")){
			area = a/c;
		}
		System.out.println(area);
		}
		sc.close();
		}
}


Measured memory_bytes: 26328
#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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#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 N,Q; cin >> N >> Q;
    string S; cin >> S;
    vector<char> t(Q), d(Q); REP(i,Q) cin >> t[i] >> d[i];

    int ans = N;
    int l = -1, r = N, n = (l+r)/2;
    while(r-l>1){
        int x = n;
        REP(i,Q){
            if(x < 0 || N-1 < x) break;
            if(t[i] == S[x]){
                if(d[i]=='L') x--;
                else x++;
            }
        }
        if(x < 0) l = n;
        else r = n;
        n = (l+r)/2;
    }
    ans -= r;

    REP(i,Q) if(d[i]=='L') d[i] = 'R'; else d[i] = 'L';
    REVERSE(S);

    l = -1; r = N; n = (l+r)/2;
    while(r-l>1){
        int x = n;
        REP(i,Q){
            if(x < 0 || N-1 < x) break;
            if(t[i] == S[x]){
                if(d[i]=='L') x--;
                else x++;
            }
        }
        if(x < 0) l = n;
        else r = n;
        n = (l+r)/2;
    }
    ans -= r;

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

Measured memory_bytes: 900
H, W = map(int, input().split())
state = [list(input()) for _ in range(H)]

rmh = 0
for h in range(H):
    h -= rmh
    ok = True
    for w in range(W):
        if state[h][w] == '#':
            ok = False
            break
    if ok:
        state.pop(h)
        rmh += 1
H -= rmh
rmw = 0
for w in range(W):
    w -= rmw
    ok = True
    for h in range(H):
        if state[h][w] == '#':
            ok = False
            break
    if ok:
        for h in range(H):
            state[h].pop(w)
        rmw += 1

for s in state:
    print(''.join(s))

Measured memory_bytes: 3188
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,n){
        cin>>h[i];
    }
    vector<int> hh;
    rep(i,n){
        if(i==0||i==n-1){
        hh.push_back(h[i]);
        }else if(h[i]==h[i+1]){
            
        }else{
            hh.push_back(h[i]);
            
        }
    }
    int u=0;int l=0;
    int hn=hh.size();
    rep(i,hn){
        if(i==0&&hh[0]>hh[1]){
            u+=hh[0];
        }else if(i==hn-1&&(hh[hn-1]>hh[hn-2])){
            u+=hh[hn-1];
        }else{
            if(hh[i]>hh[i-1]&&hh[i]>hh[i+1]){
                u+=hh[i];
            }else if(hh[i]<hh[i+1]&&hh[i]<hh[i-1]){
                l+=hh[i];
            }
        }
    }
  //  cout<<u<<l<<endl;
    cout<<u-l<<endl;
        
        
  

return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    if(b - (a+w) > 0)
    {
        cout << b - (a+w) << endl;
    }
    else if (b+w < a)
    {
        cout << a-(b+w) << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

int main(){
    int n;cin >> n;
    string s;cin >> s;
    LL ans = 1;
    if(s[0]!='B'&&s[2*n-1]!='B'){
        ans = 0;
    }
    LL k=0;
    for (int i = 0; i < 2*n; i++) {
        if(s[i]=='B'){
            if(k%2){
                ans = (ans * k) %mod;
                k--;
            }
            else{
                k++;
            }
        } 
        else{
            if(k%2){
                k++;
            }
            else{
                ans = (ans * k) %mod;
                k--;
            }
        }
    }
    if(k) ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = (ans * i)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
if a + b + c + d == 7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a + b + c - d == 7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a + b - c - d == 7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif a - b - c - d == 7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif a - b - c + d == 7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a - b + c + d == 7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a - b + c - d == 7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
else:
    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String[] nums = sc.nextLine().split(" ");
      int ans = Integer.parseInt(nums[0]) * Integer.parseInt(nums[1]);
      
      if (ans % 2 == 0) {
        System.out.println("Even");
      } else {
        System.out.println("Odd");
      }
    }
  }
  

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

int main(){
    vector<unsigned long int> v;
    int n;
    cin>>n;
    v.resize(n);
    int max_jump=0,jump=0;
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    for(int i=1; i<n; i++){
        if(v[i]<=v[i-1]){
            jump++;
            max_jump = max(max_jump, jump);
        }else{
            jump=0;
        }
    }
    cout<<max_jump<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,k,sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int c;
        cin>>c;
        sum+=2*min(c,k-c);
    }
    cout<<sum<<endl;
}


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

int main() {
  int n, h;
  cin >> n >> h;
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  int ans = 0;
  sort(a.begin(), a.end(), greater<int>());
  sort(b.begin(), b.end(), greater<int>());
  rep(i,n){
    if(b[i] > a[0]){
      h -= b[i];
      ans++;
    }else {
      break;
    }
    if(h <= 0){
      cout << ans << endl;
      return 0;
    }
  }
  if(h % a[0] != 0){
    ans += h / a[0] + 1;
  }else {
    ans += h / a[0];
  }
  cout << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
vi order;
bool cmp(int a, int b) {
	return order[a] < order[b];
}
int dfs(int u, vi& trap, vi& a, vi& vis, int* cyc) {
	vis[u]=1;
	if(!vis[a[u]]) {
		dfs(a[u], trap, a, vis, cyc);
	} else if(vis[u]==1 && vis[a[u]]==1) {
		*cyc=u;
	}
	vis[u]=2;
}
int32_t main(void)
{
	IOS;
	int n;
	cin>>n;
	cout<<((n)*(n-1))/2<<endl;
	time();
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int splus[n+1];
  splus[0] = 0;
  for (int i=1; i<n+1; i++){
    if (s[i-1] == '#') splus[i] = splus[i-1] + 1;
    else splus[i] = splus[i-1];
  }
  int ans = n-splus[n];
  int ans_cand;
  for (int j=1; j<n+1; j++){
    ans_cand = splus[j] + (n-j-splus[n]+splus[j]);
    if (ans_cand < ans) ans = ans_cand;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1412
#include <iostream>
#include <string>

using namespace std;


string s;

int main()
{
    cin >> s;

    int n = s.size() - 1;
    int rez = 0;
    for(int i = 0; i <= n / 2; i++)
    {
        if(s[i] != s[n - i])
            rez++;


    }

    cout << rez;
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    ll nowt=1, nowa=1;
    rep(i,n){
        ll t,a;cin>>t>>a;
        ll n1 = (nowt+(t-1))/t;
        ll n2 = (nowa+(a-1))/a;
        ll tn = max(n1,n2);
        nowt = t*tn; nowa = a*tn;
    }
    cout<<nowa+nowt<<endl;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef pair< int, int > pii;

int N, K;
vector< vector< int > > adj;

void dfs(int v, int p, vector< int >& del, int d) {
	del[v] = 0;
	if (d == 0) return;
	for (int u : adj[v]) {
		if (u == p) continue;
		dfs(u, v, del, d-1);
	}
}

void solve() {
	if (K == 1) {
		cout << N - 2 << endl;
		return;
	}
	
	int ans = N;
	if (K % 2) {
		for_(v,0,N) for (int u : adj[v]) {
			vector< int > del(N, 1);
			dfs(v, u, del, K / 2);
			dfs(u, v, del, K / 2);
			ans = min(ans, accumulate(del.begin(), del.end(), int()));			
		}
	} else {
		for_(v,0,N) {
			vector< int > del(N, 1);
			dfs(v, -1, del, K / 2);
			ans = min(ans, accumulate(del.begin(), del.end(), int()));
		}
	}
	cout << ans << endl;
}

int main() {
	cin >> N >> K;
	adj.assign(N, vector< int >());
	for_(i,0,N-1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	solve();
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

int main(){
    int n;
    cin >> n;
    set<int> ans;
    int num = 0;
    for(int i=1;i<=n;i++){
        ans.insert(i);
        num += i;
        if(num > n){ break; }
    }
    ans.erase(num - n);
    for(int i : ans){
        cout << i << endl;
    }
    return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

array<array<ll, 2>, 2010> dp;
array<ll, 2010> a;

ll rec(ll z, ll w, int s, int t, int n){
	ll& rtn = dp[s][t];
	if(rtn !=-1) return rtn;
	if(s == n) return abs(z -w);
	
	if(t==0){
		rtn = 0;
		rep2(i, s, n) rtn = max(rtn, rec(a[i], w, i+1, 1, n));
	}else{
		rtn = 1LL<<60;
		rep2(i, s, n) rtn = min(rtn, rec(z, a[i], i+1, 0, n));
	}
	return rtn;
}

int main()
{
 
	cin.tie(0); ios_base::sync_with_stdio(false);
	int  n; ll z,w;
	cin >>n >>z >>w;
	rep(i, n) cin >>a[i];
	ll ans=0;
	if(n > 1) ans = max(abs(a[n-1] - w) , abs(a[n-2] - a[n-1]));
	else ans = abs(a[n-1] - w);
	cout << ans <<"\n";
	//rep(i, 2010) dp[i].fill(-1);
	//cout << rec(z, w, 0, 0, n) <<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char c[101][101];
long long a,b;
inline long long read()
{
   long long sum=0,x=1;
   char ch=getchar();
   while (ch<'0'||ch>'9')
   {
       if (ch=='-')
	     x=-1;
	   ch=getchar();
   }
   while (ch>='0'&&ch<='9')
   {
   	   sum=sum*10+ch-'0';
	   ch=getchar();
   }
   return sum*x;
}
inline void write(long long x)
{
    if (x<0)
	{
        putchar('-');
        x=-x;
    }
    if (x>9)
      write(x/10);
    putchar(x%10+'0');
    return;
}
int main()
{
	a=read()-1;b=read()-1;
	memset(c,'.',sizeof(c));
	for (register int i=51;i<=100;++i)
	  for (register int j=1;j<=100;++j)
		c[i][j]='#';
	for (register int i=1;i<=50&&b;i+=2)
	  for (register int j=1;j<=100&&b;j+=2)
	  {
		c[i][j]='#';
		--b;
	  }
	for (register int i=100;i>50&&a;i-=2)
	  for (register int j=1;j<=100&&a;j+=2)
	  {
	  	c[i][j]='.';
		--a;
	  }
	write(100);putchar(' ');
	write(100);putchar('\n');
	for (register int i=1;i<=100;++i)
	{
		for (register int j=1;j<=100;++j)
		  putchar(c[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <stdio.h>
using namespace std;
using ll =long long;

int main (void) {
  int K,T;
  cin >> K >>T ;
  int a[T];
  int ma=0;
  int sum=0;
  for (int i=0;i<T;i++){
    cin >> a[i];
    if(a[i]>ma){
      ma=a[i];
    }
  }
  int ans=0;
  ans=max(ans,2*ma-K-1);
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,knmax=0;
  string s;
  map<string,int> m;
  map<string,int>::iterator ite;
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> s;
    m[s]++;
    knmax=max(knmax,m[s]);
  }
  
  vector<string> ans;
  for (ite=m.begin();ite!=m.end();ite++){
    if (ite->second==knmax) ans.push_back(ite->first);
  }
  
  sort(ans.begin(),ans.end());
  
  for (i=0;i<ans.size();i++) cout << ans[i] << endl; 
  
  return 0;
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e8;
typedef pair<int,int> P;

int main(){
  ll N,K,Q,a;cin>>N>>K>>Q;
  vector<ll> vec(N,0);
  REP(i,0,Q){
    cin>>a;
    vec[--a]++;
  }
  REP(i,0,N){
    print(((K-Q+vec[i])>0 ? "Yes":"No"))
  }
}


Measured memory_bytes: 1408
N = int(input())
D = {i: 0 for i in range(100)}
for i in range(1, N+1):
    if i % 10 != 0:
        s = str(i)
        D[int(s[0])*10+int(s[-1])] += 1
S = 0
for i in range(10):
    for j in range(10):
        S += D[i*10+j] * D[j*10+i]
print(S)


Measured memory_bytes: 3060
/*
[abc136] D - Gathering Children
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
string S;
int ans[MAX_N];

void solve() {
    for (int i = 0, cnt = 0; i < N; i++) {
        if (S[i] == 'R') {
            cnt++;
        } else {
            ans[i] += cnt / 2;
            ans[i - 1] += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    for (int i = N - 1, cnt = 0; i >= 0; i--) {
        if (S[i] == 'L') {
            cnt++;
        } else {
            ans[i] += cnt / 2;
            ans[i + 1] += (cnt + 1) / 2;
            cnt = 0;
        }
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
}

int main() {
    cin >> S;
    N = S.length();

    solve();

    return 0;
}


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


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

	int current_t = 0, current_x = 0, current_y = 0;
	bool failureFlg = false;
	for (int i = 0; i < N; i++) {
		int next_t, next_x, next_y;
		cin >> next_t >> next_x >> next_y;

		int timeDiff = next_t - current_t;
		int distance = abs(next_x - current_x) + abs(next_y - current_y);
		if (timeDiff < distance || (timeDiff % 2) != (distance % 2)) {
			failureFlg = true;
			break;
		}

		current_t = next_t;
		current_x = next_x;
		current_y = next_y;
	}

	if (failureFlg == true)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;


// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  ll m , n; cin >> m >> n;
  ll ans = modpow(m , n , MOD);
  cout << ans << endl;

}



Measured memory_bytes: 3100
#include <stdio.h>

int main(void) {
	int prime[1000000],i,j,n,num;
    for(i = 0;i < 1000000;i++) prime[i] = 1;
    for(i = 2;i < 1000;i++){
        for(j = i * 2;j < 1000000;j += i) prime[j] = 0;
    }
    while(scanf("%d",&n) != EOF){
        num = 0;
        for(i = 2;i <= n;i++) if(prime[i]) num++;
        printf("%d\n",num);
    }
	return 0;
}

Measured memory_bytes: 4500
input()
S = input()
length = len(S)

dp = {}

for i in range(length):
  for ch in ['#', '.']:
    base = 1 if S[i] != ch else 0

    if i == 0:
      dp[(i, ch)] = base
      continue
    if ch == '#':
      dp[(i, ch)] = min(base + dp[(i-1,'#')], base + dp[(i-1,'.')])
    else:
      dp[(i, ch)] = base + dp[(i - 1, '.')]


# print('dp', dp)
print(min(dp[(length - 1, '#')], dp[(length - 1, '.')]))


Measured memory_bytes: 78996
import static java.lang.Character.*;

import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws IOException {
		char alpha = 'a';
		int[] count = new int[26];
		String str;
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			str = sc.next();
			str = str.toLowerCase();// ????????????????????????????°??????????????????????.isLetter?????£?????????????????????
			for (int i = 0; i < str.length(); ++i) {
				int a = str.charAt(i);
				//System.out.println(str.charAt(i) + " " + 'a'+ " "+ a);
				if(isLetter(a)){ // ?????????????????¨???????????\?????\??£???????????????????????????????£?????¨??????§????¢??????§IndexoutofBounds??????????????????.
				count[str.charAt(i) - 'a']++; // ??¢????????????????????¨????????????.??????????????????????????????????????????????????§????????????
				//System.out.println(str.charAt(i) - 'a');
				}
			}
		}
		for (int j = 0; j < 26; ++j) {
			System.out.println(alpha++ + " : " + count[j]);
		}
		sc.close();
	}
}

Measured memory_bytes: 26356
#include <iostream>

#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN(N); IN(C);

  vector<vector<pii>> program(C, vector<pii>());
  REP(i, N) {
    IN(s); IN(t); IN(c);
    program[c-1].push_back(make_pair(s, t));
  }
  REP(c, C) {
    priority_queue<pii, vector<pii>, greater<pii>> q;
    for (const auto& e : program[c])
      q.push(e);
    program[c].clear();
    while (!q.empty()) {
      pii p = q.top(); q.pop();
      if (p.second == q.top().first) {
        pii p2 = q.top(); q.pop();
        q.push(make_pair(p.first, p2.second));
      } else {
        program[c].push_back(p);
      }
    }
  }
  vi indexes(C);
  int res = 0;
  REP(s, 200002) {
    int count = 0;
    REP(c, C) {
      if (program[c].size() == indexes[c])
        continue;
      if (2 * program[c][indexes[c]].first - 1 <= s && s < 2 * program[c][indexes[c]].second)
        ++count;
      else if (2 * program[c][indexes[c]].second <= s)
        ++indexes[c];
    }
    res = max(res, count);
  }
  OUT(res);

  return 0;
}


Measured memory_bytes: 2548
namespace _106_2
{using System;

    class Program
    {
        static void Main(string[] args)
        {
			int N = int.Parse(Console.ReadLine());
			if(N < 105)
			{
				Console.WriteLine("0");
			}
			else if (N < 135)
			{
				Console.WriteLine("1");
			}
			else if (N < 165)
			{
				Console.WriteLine("2");
			}
			else if (N < 189)
			{
				Console.WriteLine("3");
			}
			else if (N < 195)
			{
				Console.WriteLine("4");
			}
			else
			{
				Console.WriteLine("5");
			}
        }
    }
}


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

int main() {
    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else  cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long n,i,j,ans=0,x,k,d;
   cin>>x>>k>>d;
   if(abs(x)/d<=k)
   {
       k=k-abs(x/d);
       if(k%2==0)
       {
           if(x>=0)
           {
                cout<<x-(abs(x/d)*d)<<endl;
           }
           else
            cout<<abs(x+(abs(x/d)*d))<<endl;
       }
       else
       {
           if(x>=0)
           {
               x=x-(abs(x/d)*d);
               cout<<min(abs(x-d),abs(x+d))<<endl;
           }
           else
           {
               x=x+(abs(x/d)*d);
               cout<<min(abs(x+d),abs(x-d))<<endl;
           }

       }
   }
   else
   {
       if(x>=0)
       {
           cout<<abs(x-(k*d))<<endl;
       }
       else
       {
           cout<<abs(x+(k*d))<<endl;
       }
   }

}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF (ll)1e18

ll N, A[101010];
ll i, j, k;

int main(){
    scanf("%lld", &N);
    j = 0;
    fornum(i,0,N){
        scanf("%lld", &A[i]);
        if(A[i]==0)
            j = 1;
    }
    if(j==1){
        printf("0\n");
        return 0;
    }
    j = 1;
    fornum(i,0,N){
        if(INF/j<A[i]){
            printf("-1\n");
            return 0;
        }
        j *= A[i];
    }
    printf("%lld\n", j);

    return 0;
}

Measured memory_bytes: 4544
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();
    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    let xs = line.trim().split_whitespace();
    let mut result = Vec::new();

    for x in xs {
        let ans = x.parse::<T>().map_err(|_| format!("{}", "parse error"))?;
        result.push(ans);
    }
    Ok(result)
}

fn main() {
    // let (a, b) = read_parameters::<isize>().map(|xs| (xs[0], xs[1])).unwrap();
    let (a, b, c) = read_parameters::<isize>()
        .map(|xs| (xs[0], xs[1], xs[2]))
        .unwrap();

    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5032
// 11232019.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
using namespace std;

int main()
{
	int x, y, ans = 0;
	cin >> x >> y;
	if (x == 1 && y == 1) ans += 400000;
	if (x == 1) {
		ans += 300000;
	}
	if (y == 1) ans += 300000;
	if (x == 2) ans += 200000;
	if (y == 2) ans += 200000;
	if (x == 3) ans += 100000;
	if (y == 3) ans += 100000;
	cout << ans << endl;
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

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

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    int n;cin >> n;
    vector<char>c(n);
    rep(i,n)cin>>c[i];
    vector<int> r,w;
    rep(i,n){
        if(c[i]=='W')w.push_back(i);
        else r.push_back(i);
    }
    int ans = 0;
    reverse(r.begin(),r.end());
    rep(i,min(r.size(),w.size())){
        if(r[i]>w[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(x,y) '(' << x << ',' << y << ')'
ll MOD = 1000000007;
ll INF = 214748364700000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

ll d(ll n){
   ll res = 0;
   while(n){
      res += n % 10;
      n /= 10;
   }
   return res;
}

int main(){
   ll K;cin >> K;
   ll cnt = 1;
   FOR(i,1,K){
      if(i == 15){
         rep(j,9){
            cout << (ll)pow(10,i-1) + j * (ll)pow(10,i-3) + (ll)pow(10,i-3) - 1 << endl;
            cnt++;
            if(cnt > K){
               return 0;
            }
         }
      }
      FOR(j,1,max((ll)1,min(i-2,(ll)10))){
         ll n = j * (ll)pow(10,i-1);
         rep(k,10){
            n = j * (ll)pow(10,i-1) + (k * (ll)pow(10,i-2)) + (ll)pow(10,i-2) - 1;
            cout << n << endl;
            cnt++;
            if(cnt > K){
               return 0;
            }
         }
      }
      FOR(j,max((ll)1,min(i-2,(ll)10)),10){
         ll n = j * (ll)pow(10,i-1) + (ll)pow(10,i-1) - 1;
         cout << n << endl;
         cnt++;
         if(cnt > K){
            return 0;
         }
      }
   }
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = LIST()
H.sort()

if K > N:
    print(0)
else:
    print(sum(H[0:N-K]))

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

int main(int argc, char const *argv[]) {
    string str;
    int q;
    cin >> str >> q;

    for (int i = 0; i < q; i++) {
        string order;
        int a, b;
        cin >> order >> a >> b;

        if (order == "print") {
            cout << str.substr(a, b-a+1) << endl;
        } else if (order == "reverse") {
            string tmp = str.substr(a, b-a+1);
            reverse(tmp.begin(), tmp.end());
            str = str.replace(a, b-a+1, tmp);
        } else {
            string p;
            cin >> p;
            str = str.replace(a, b-a+1, p);
        }
    }

    return 0;

}



Measured memory_bytes: 3204
// {{{
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)x.size())
#define FOR(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
using LL=long long;
using PII=pair<int,int>;
using VI=vector<int>;

#ifdef FEI
template<typename T>
void _dump(const char* s, T&& head) { cerr<<s<<"="<<head<<endl; }
template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail) {
    int c=0;
    while (*s!=',' || c!=0) {
        if (*s=='(' || *s=='[' || *s=='{') c++;
        if (*s==')' || *s==']' || *s=='}') c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1, tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, ##__VA_ARGS__); \
} while(0);

template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<'[';
    for (auto it=b; it!=e; it++) s<<(it==b?"":",")<<*it;
    s<<']';
    return s;
}

template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) { return s<<"("<<p.first<<","<<p.second<<")";}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &x) { return _out(s,ALL(x)); }
template<typename T, size_t N>
ostream& operator <<(ostream &s, const array<T,N> &x) { return _out(s,ALL(x)); }
template<typename T>
ostream& operator <<(ostream &s, const set<T> &x) { return _out(s,ALL(x)); }
template<typename A, typename B>
ostream& operator <<(ostream &s, const map<A,B> &x) { return _out(s,ALL(x)); }
#else
#define dump(...)
#endif

template<typename T>
void _R(T &x) { cin>>x; }
void _R(int &x) { scanf("%d",&x); }
void _R(LL &x) { scanf("%" PRId64,&x); }
void _R(double &x) { scanf("%lf",&x); }
void _R(char &x) { scanf(" %c",&x); }
void _R(char *x) { scanf("%s",x); }

void R(){}
template<typename T, typename... X>
void R(T& head, X&... tail) { _R(head); R(tail...); }

const int MOD = 1e9+7;
// }}}

const int N = 200005;
vector<int> edge[N];
int dist[2][N];

void dfs(int pos, int d, int arr[]) {
    arr[pos] = d;
    for (int next : edge[pos])
        if (arr[next] == INT_MAX)
            dfs(next, d+1, arr);
}

int main() {
    int n;
    R(n);
    for (int i=1; i<n; i++) {
        int x, y;
        R(x, y);
        edge[x].push_back(y);
        edge[y].push_back(x);
    }

    for (int i=1; i<=n; i++)
        dist[0][i] = dist[1][i] = INT_MAX;

    dfs(1, 0, dist[0]);
    dfs(n, 0, dist[1]);


    int cnt = 0;
    for (int i=1; i<=n; i++) {
        if (dist[0][i] <= dist[1][i]) cnt++;
    }

    if (cnt*2 > n) puts("Fennec");
    else puts("Snuke");

    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}


const int M=2005;
const int N=M*M;
const int mo=1e9+7;

int n,m,jc[N],inv[N],f[M][M];

inline int ksm(int x,int y)
{
	int ret=1ll;
	while(y)
	{
		if(y&1) ret=ret*x%mo;
		x=x*x%mo;
		y>>=1ll;
	}
	return ret%mo;
}

inline void Add(int &x,int y)
{
	x+=y;
	if(x>=mo) x%=mo;
}

inline int C(int x,int y)
{
	return jc[x]*inv[y]%mo*inv[x-y]%mo;
}

signed main()
{
	n=read();
	m=read();
	if(m==1) return puts("1"),0;
	inv[0]=jc[0]=1;
	for ( int i=1;i<=n*m;i++ ) jc[i]=jc[i-1]*i%mo;
	for ( int i=1;i<=n*m;i++ ) inv[i]=ksm(jc[i],mo-2)%mo;
	for ( int i=1;i<=n;i++ ) f[i][0]=1;
	for ( int i=1;i<=n;i++ ) 
		for ( int j=1;j<=i;j++ ) 
		{
			f[i][j]=(f[i][j]+f[i-1][j]+mo)%mo;
			f[i][j]=(f[i][j]+1ll*f[i][j-1]*(n-j+1)%mo*C(n-i+(n-j+1)*(m-1)-1,m-2)%mo+mo)%mo;
		}
	printf("%lld\n",(f[n][n]+mo)%mo);
	return 0;
}
			

Measured memory_bytes: 93056
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


class UnionFind:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes

        # self.parents[x] < 0 の時，xが根である．
        # また，xが根の時，(-1) * (同一グループの要素数) が格納されるようになる.
        self.parents = [-1] * n_nodes

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # 常にxの方が要素数が多くなるように，スワップする
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        # 要素数の少ない方のグループを，要素数が多い方の木に貼る．
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def get_size(self, x):
        return -self.parents[self.find(x)]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_members(self, x):
        parent = self.find(x)
        return [i for i in range(self.n_nodes) if self.find(i) == parent]

    def get_parent_list(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def get_n_groups(self):
        return len(self.get_parent_list())

    def get_members_dict(self):
        return {par: self.get_members(par) for par in self.get_parent_list()}


def main():
    N, M = map(int, input().split())
    tree = UnionFind(N)

    ab = []
    for _ in range(M):
        a, b = map(int, input().split())
        ab.append((a, b))
    ab.reverse()

    # 行き来できる島の数を記録
    cnt = [0]
    for i in range(M):
        a, b = ab[i]
        a -= 1
        b -= 1
        if tree.is_same(a, b):
            cnt.append(cnt[-1])
            continue

        c = cnt[-1]
        a_size = tree.get_size(a)
        b_size = tree.get_size(b)
        c -= a_size * (a_size - 1) // 2 + b_size * (b_size - 1) // 2

        tree.unite(a, b)
        size = tree.get_size(a)
        c += size * (size - 1) // 2
        cnt.append(c)

    cnt.reverse()
    orig = cnt[0]
    for c in cnt[1:]:
        print(orig - c)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24620
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int k;
	cin >> k;
	int m = 7 % k;
	for(int i = 0;i <= k + 5;i++){
		if(m == 0){
			cout << (i + 1) << endl;
			return 0;
		}
		m = (m * 10 + 7) % k;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3632
# coding: utf-8
import math


def test(n):
    count = 1
    count_lst = []
    num = int(n[0])
    for i in n[1:4]:
        if num == int(i):
            count += 1
        else:
            count_lst.append(count)
            count = 1
        num = int(i)
    else:
        count_lst.append(count)

    if max(count_lst) >= 3:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    n = input()
    test(n)

Measured memory_bytes: 3064
#include <stdio.h>
  #include <stdlib.h>
  int puzle[3][3];
  int tmp[3][3];
  int d1[4]={0,1,0,-1};
  int d2[4]={1,0,-1,0};

  void empty(int *x,int *y){
    int i,j;
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        if(!puzle[i][j]){
  	*x=j;
  	*y=i;
  	return;
        }
      }
    }
  }

  void swap(int *a,int *b){
    int tmp=*a;
    *a=*b;
    *b=tmp;
  }

  int cal(){
    int a,i,sum=0;
    for(i=0;i<9;i++){
      a=puzle[i/3][i%3];
      if(a){
        a--;
        sum += abs(i/3-a/3) + abs(i%3-a%3);
      }
    }
    return sum;
  }

  int dfs(int x,int y,int p,int dep,const int lim){
    int i,h,n1,n2,res;
    h=cal();
    if(h==0){
      return dep;
    }
    if(dep+h > lim){
      return -1;
    }
    for(i=0;i<4;++i){
      n1=x+d1[i];
      n2=y+d2[i];

      if(~p && i==(p+2)%4)
        continue;
      if(!(0 <= n1 && n1 < 3 && 0 <= n2 && n2 < 3))
        continue;
      swap(&puzle[y][x],&puzle[n2][n1]);
      res=dfs(n1,n2,i,dep+1,lim);

      if(~res){
        return res;
      }
      swap(&puzle[y][x],&puzle[n2][n1]);
    }
    return -1;
  }

  int main(){
    int ans,x,y,l,i,j;

    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        scanf("%d",&puzle[i][j]);
      }
    }
    empty(&x,&y);
    for(l=0;l<100;l++){
      for(i=0;i<3;i++){
        for(j=0;j<3;j++){
  	tmp[i][j]=puzle[i][j];
      }
    }
      ans=dfs(x,y,-1,0,l);
      if(ans!=-1){
        printf("%d\n",ans);
        break;
      }
      for(i=0;i<3;i++){
        for(j=0;j<3;j++){
  	puzle[i][j]=tmp[i][j];
      }
      }
      ans=-1;
      if(l==99){
        printf("%d\n",ans);
    }
    }
    return 0;
  }


Measured memory_bytes: 2108
import math


def IsPrime(x):
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    i = 3
    while i <= math.sqrt(x) + 1:
        if x % i == 0:
            return False
        i += 2
    return True

N = int(input())
count =0
for _ in  range(N):
    x = int(input())
    if IsPrime(x):
        count+=1
print(count)


Measured memory_bytes: 5676
N, K = map(int, input().split())
C = [0 for _ in range(N)]


for _ in range(K):
    D = int(input())
    A = list(map(int, input().split()))
    for a in A:
        C[a - 1] += 1

res = 0
for c in C:
    if c > 0:
        res += 1

print(N - res)


Measured memory_bytes: 9180
n_y = input().split(' ')
maisu = int(n_y[0])
total = int(n_y[1])

result_flg = True
for i in range(maisu+1):
    for j in range(maisu+1):
        if maisu - i - j < 0:
            break

        sum_kingaku = i * 10000 + j * 5000 + (maisu - i - j) * 1000

        if sum_kingaku > total:
            break

        if total == sum_kingaku:
            print(str(i) + ' ' + str(j) + ' ' + str(maisu -i -j))
            result_flg = False
            break
    if result_flg == False:
        break
    

if result_flg:
    print('-1 -1 -1')
            

Measured memory_bytes: 9072
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

multiset<int> mt;
vector<int> v[100005];


int main()
{
    NO_TLE
    int n,m,t;
    cin>>n>>m;
    LL ans=0;
    rep(i,n)
    {
        int a,b;
        cin>>a>>b;
        //mt.insert(t);
        v[a].push_back(b);
    }
    //rep(i,100005)mt.insert(0);
    rer(i,1,m)
    {
        rep(j,v[i].size())
        {
            mt.insert(v[i][j]);
        }
        if(!mt.empty())
        {
            auto it=mt.end();
            --it;
            int x=*it;
            ans+=x;
            mt.erase(it);
        }
    }
    cout<<ans<<endl;
    return 0;
}







































Measured memory_bytes: 7808