akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

const int INF = 1001001001;

int a[12][12];

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vi c(n);
  REP(i, n) {
    cin >> c[i];
    REP(j, m) cin >> a[i][j];
  }

  int ans = INF;
  REP(z, 1<<n) {
    int cost = 0;
    vi u(m);
    REP(i, n) {
      if (z>>i&1) {
        cost += c[i];
        REP(j, m) u[j] += a[i][j];
      }
    }
    bool ok = true;
    REP(j, m) if(u[j] < x) ok = false;
    if(ok) chmin(ans, cost);
  }
  if (ans==INF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}

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

main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s;
	cin>>s;

	int x=((int)(s[0]-'0'))*10+(int)(s[1]-'0');
	int y=((int)(s[2]-'0'))*10+(int)(s[3]-'0');

	int f1=0,f2=0;
	if(x>0 and x<=12)
		f1=1;
	if(y>0 and y<=12)
		f2=1;

	string ans="NA";
	if(f1==1 and f2==1)
		ans="AMBIGUOUS";
	else if(f1==1)
		ans="MMYY";
	else if(f2==1)
		ans="YYMM";

	cout<<ans;
}

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

const int MOD = (int)1e9+7;

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

  vector<vector<long long>> dp(N+1,vector<long long>(N*100+1,0));
  dp.at(0).at(0)=1;
  for(int i=1;i<N+1;i++){
    for(int j=0;j<N*100+1;j++){
      dp.at(i).at(j)=dp.at(i-1).at(j);
      if(j-A.at(i-1)>=0)  dp.at(i).at(j)+=dp.at(i-1).at(j-A.at(i-1));
    }
  }
  long long ans=0;
  if(P==0){
    for(int i=0;i<N*100+1;i+=2){
      ans+=dp.at(N).at(i);
    }
  }
  else{
    for(int i=1;i<N*100+1;i+=2){
      ans+=dp.at(N).at(i);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2304
#include<iostream>
using namespace std;
int main(){
	int x,y, y2, z, z3, e;
	while(cin>>e&&e!=0){
		int min=1e6;
		for(y=0;y<=1e3;y++){
			y2=y*y;
			for(z=0;z<=1e2;z++){
				z3=z*z*z;
				x=e-y2-z3;
				if(min>x+y+z&&x>=0){
					min=x+y+z;
				}
			}
		}
		cout<<min<<endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007
#define YOKO 1
#define TATE 2

using namespace std;

long long W, H;
long long tatenum, yokonum;

//               cost, tate, yoko
vector<pair<long long, long long> >vec;


int main(){
	cin >> W >> H;
	for(int i = 0; i < W; i++){
		long long tmp;
		cin >> tmp;
		vec.push_back(make_pair(tmp, TATE));
	}
	for(int i = 0; i < H; i++){
		long long tmp;
		cin >> tmp;
		vec.push_back(make_pair(tmp, YOKO));
	}
	sort(vec.begin(), vec.end());

	long long ans = 0;
	for(int i = 0; i <  vec.size(); i++){
		if(vec[i].second == TATE){
			//cout << vec[i].first << " TATE" << endl;
			//cout << "num = " << (H-yokonum+1) << endl;
			ans += (H-yokonum+1) * vec[i].first;
			tatenum++;
		}else{
			//cout << vec[i].first << " YOKO" << endl;
			//cout << "num = " << (W-tatenum+1) << endl;
			ans += (W-tatenum+1) * vec[i].first;
			yokonum++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int x;
  cin >> x;
 
  int a = x / 500;
  int b = (x % 500) / 5;
 
  cout << (a * 1000 + 5 * b) << endl;
 
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <string.h>
#include <algorithm>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = (int) 3e5 + 77;

int n, a[300005];
ll l[300005], r[300005];

int main(){
    scanf("%d",&n);
    for(int i=1; i<=3*n; i++) scanf("%d",&a[i]);
    priority_queue<int, vector<int>, greater<int> > pq;
    priority_queue<int> pq2;
    ll sum = 0;
    for(int i=1; i<=3*n; i++){
        sum += a[i];
        pq.push(a[i]);
        while(pq.size() > n){
            sum -= pq.top();
            pq.pop();
        }
        l[i] = sum;
    }
    sum = 0;
    for(int i=3*n; i; i--){
        sum += a[i];
        pq2.push(a[i]);
        while(pq2.size() > n){
            sum -= pq2.top();
            pq2.pop();
        }
        r[i] = sum;
    }
    ll ret = -1e18;
    for(int i=n; i<=2*n; i++){
        ret = max(ret, l[i] - r[i+1]);
    }
    cout << ret << endl;
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    string s;
    cin >> s;
    int mx = 0, now = 0;
    for(auto &&c : s) {
        if(c == 'R')
            chmax(mx, ++now);
        else
            now = 0;
    }
    cout << mx << endl;

    return 0;
}

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

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

    while(--n >= 0){
        int k, p;
        cin >> k >> p;

        int ans = (k - 1) % p + 1;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
def resolve():
    import itertools
    n, m, q = map(int, input().split())
    cond = [list(map(int, input().split())) for _ in range(q)]
    ans = 0
    for i in list(itertools.combinations_with_replacement(range(1, m+1), n)):
        point = 0
        for j in range(q):
            if i[cond[j][1]-1] - i[cond[j][0]-1] == cond[j][2]:
                point += cond[j][3]
        ans = max(ans, point)
    print(ans)
resolve()

Measured memory_bytes: 84664
long long score[4000],u;
ID[4000],pos[4000],N;
n,id,c;
main(){
	for(;scanf("%d",&n),n;){
		for(;n--;){
			scanf("%d%lld%d",&id,&u,&c);
			if(pos[id-1])
				score[pos[id-1]-1]+=u*c;
			else
				ID[N]=id,score[N]=u*c,pos[id-1]=++N;
		}
		c=0;
		for(n=0;n<N;n++){
			if(score[n]>=1000000)
				c=printf("%d\n",ID[n]);
		}
		if(!c)
			puts("NA");
		memset(pos,0,4000*4);
		N=0;
	}
	exit(0);
}

Measured memory_bytes: 0
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
	    int B = sc.nextInt();

	    String str = sc.next();
	    char[] c = str.toCharArray();
	    for(int i=0; i<A+B+1; i++){
	    	if(i==A){
	    		if(!(String.valueOf(c[i]).equals("-"))){
	    			System.out.println("No");
	    			return;
	    		}
	    	}else{
	    		if(Character.isDigit(c[i])==false){
	    			System.out.println("No");
	    			return;
	    		}
	    	}
	    }

	    System.out.println("Yes");
    }
}

Measured memory_bytes: 22868
#include<stdio.h>

int main()
{

  int k,a,b;
  scanf("%d %d %d",&k,&a,&b);

  for(int i=a; i<=b; i++){
    if(i%k == 0){
      printf("OK");
      return 0;
    }
  }

  printf("NG");

  return 0;

}



Measured memory_bytes: 1728
#include<stdio.h>
int main()
{
  int n,t,e,i,j,a=-1,x[100];
  scanf("%d%d%d",&n,&t,&e);
  for(i=0;i<n;i++)
    {
      scanf("%d",&x[i]);
    }
  for(i=0;i<n;i++)
    for(j=x[i];j<=t+e;j+=x[i])
	  if(j-e<=t && j+e>=t)
	    a=i+1;
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<sstream>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}



int pref[100010];
int main() {
	int n, m;
	cin >> n >> m;
	int *y = new int[m];
	int *p = new int[m];
	vector<pair<int,pair<int, int>>> s;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> y[i];
		s.push_back(make_pair(y[i],make_pair(i, p[i])));
	}
	sort(s.begin(), s.end());
	vector < pair<int, pair<int,int>>> ans;
	for (int i = 0; i < m; i++) {
		pref[s[i].second.second]++;
		stringstream temp;
		ans.push_back(make_pair(s[i].second.first, make_pair(s[i].second.second, pref[s[i].second.second])));
	}
	sort(ans.begin(), ans.end());
	for (int i = 0; i < m; i++) {
		cout << setfill('0') << setw(6) << right << ans[i].second.first;
		cout << setfill('0') << setw(6) << right << ans[i].second.second << endl;

	}


	return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s; 
  cin >> s;
  
  if (s[0] == s[1] && s[1] == s[2] ) {
    cout << "Yes" << endl;
  }
  else if (s[1] == s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
  }
   else 
     cout << "No" << endl;
 
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int f =0;
  string s;
  cin >> s;
  if(s == "AAA"|| s == "BBB")
  {
    cout << "No";
  }
  else
    cout << "Yes";
	return 0;
}	

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int e,y;
	scanf("%d%d",&e,&y);
	if(e==1)
	printf("%d\n",y+1867);
	else if(e==2)
	printf("%d\n",y+1911);
	else if(e==3)
	printf("%d\n",y+1925);
	else if(e==4)
	printf("%d\n",y+1988);
	else{
	if(y>1988)
	printf("H%d\n",y-1988);	
	else if(y>1925)
	printf("S%d\n",y-1925);
	else if(y>1911)
	printf("T%d\n",y-1911);
	else
	printf("M%d\n",y-1867);
	}
	return 0;
}

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

int cnt1[26],cnt2[26];

int main(){
	string s,t;
	cin>>s>>t;
	for (int i=0;i<s.size();i++) cnt1[s[i]-'a']++;
	for (int i=0;i<t.size();i++) cnt2[t[i]-'a']++;
	sort(cnt1,cnt1+26);
	sort(cnt2,cnt2+26);
	for (int i=0;i<26;i++){
		if (cnt1[i]!=cnt2[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 776
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n,m,k = readInt()
    a = readInt()
    b = readInt()
    a_sum = [0]
    for i in range(n):
        a_sum.append(a_sum[i] + a[i])
    b_sum = [0]
    for i in range(m):
        b_sum.append(b_sum[i] + b[i])
    b_sum.append(INF)
    ans = 0
    for i in range(n+1):
        t = a_sum[i]
        l = 0
        r = m+2
        while l+1<r:
            c = (l + r) // 2
            if t+b_sum[c]<=k:
                l = c
            else:
                r = c
        if a_sum[i]+b_sum[l]<=k:
            ans = max(ans,i+l)
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 47524
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
map<int,int>mp;
multiset<string> st;
multiset<string> :: iterator it;

deque <char> q ;
int vis [1000];
int main()
{
    fast ;
   char c;
   cin >> c ;
  if(c =='a' || c=='e' || c == 'i' || c =='o' || c=='u')
  cout <<"vowel\n";
else
   cout <<"consonant\n";
}







Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1e9+7
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int N,ans=0,cnt=0;
    cin>>N;
    VI h(N);
    REP(i,N)cin>>h[i];
    REP(i,N-1){
        if(h[i]>=h[i+1]){
            cnt++;
            //cout<<cnt<<endl;
        }else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}




Measured memory_bytes: 640
s=input()
t=input()
ans=[]
for i in range(len(s)-len(t)+1):
  start=i
  end=i+len(t)
  ok=True
  for j in range(len(t)):
    if s[start+j]!='?' and s[start+j]!=t[j]:
      ok=False
      break
  if ok:
    a=s[:start]+t+s[end:]
    ans.append(a.replace('?','a'))
if ans:
  ans=sorted(ans)
  print(ans[0])
else:
  print('UNRESTORABLE')

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

typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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 H, W;
vector<string> maze;
vector<vector<ll>> path;

int main() {
  cin >> H >> W;
  maze = vector<string>(H);
  path = vector<vector<ll>>(H,vector<ll>(W,0));
  for (ll i=0;i<H;i++){
    cin >> maze.at(i);
  }

  path.at(0).at(0)=1;

  for (ll i=0;i<H;i++){
    for (ll j=0;j<W;j++){
      if (i+1<H && maze.at(i+1).at(j)=='.') (path.at(i+1).at(j) += path.at(i).at(j)) %= MOD;
      if (j+1<W && maze.at(i).at(j+1)=='.') (path.at(i).at(j+1) += path.at(i).at(j)) %= MOD;
    }
  }
  cout << path.at(H-1).at(W-1) << endl;
}

Measured memory_bytes: 9088
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bit(i) (1<<(i))
#define set(mask,i) (mask |= (1<<(i)))
#define get(mask,i) (mask & (1<<(i)))
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
const ll INF64 = (ll)1e15;
const int INF32 = (int)1e9;
const int64_t md = (int64_t)((int64_t)1e9 + 7);
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll n, w;
	cin >> n >> w;
	vector<pair<ll, ll>> v(n);
	for(auto& el : v)
		cin >> el.first >> el.second;
	ll dp[n + 1][w + 1];
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= w; j++) {
			dp[i][j] = -INF32;
		}
	}
	for(int i = 0; i <= w; i++) dp[n][i] = 0;
	for(int i = n-1; i >= 0; i--) {
		for(int j = 0; j <= w; j++) {
			dp[i][j] = dp[i+1][j];
			if(j >= v[i].first) dp[i][j] = max(dp[i][j], dp[i+1][j-v[i].first] + v[i].second);
		}
	}
	cout << dp[0][w];

	return 0;
}

Measured memory_bytes: 82448
#include <bits/stdc++.h>
#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)

struct edge{ll to,cost;};

vector<ll>prime_count(1001,0);

void func(int a){
   for(int i=2;i<=1001;i++){
      while(a%i==0){
         a /= i;
         prime_count[i]++;
         prime_count[i]%=MOD;
      }
   }
}

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N;
   cin >> N;
   ll ans = 1;
   for(int i=1;i<=N;i++)func(i);
   for(int i=1;i<=N;i++){
      ans *= (prime_count[i]%MOD+1)%MOD;
      ans %= MOD;
   }
   //for(int i=1;i<prime_count.size();i++)cout << prime_count[i] << endl;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
count = 0
search_word = None
while True:
    line = input()
    if line == "END_OF_TEXT":
        break
    
    if search_word is None:
        search_word = line
        continue
    
    for word in line.split():
        word = word.lower()
        if search_word == word:
            count += 1
print(count)


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

int main(void){
    string t;
    cin >> t;

    int i;
    long long result;


    for(i=0;; i++){
        if(t[i] == '\0') break;
        /*
        if(i>0 && t[i] == '?'){
            if(t[i-1] == 'D'){
                t[i] = 'P';
            }
            else{
                t[i] = 'D';
            }
        }*/
        if(t[i] == '?'){
            t[i] = 'D';
        }
    }

    cout << t << endl;


}

Measured memory_bytes: 3752
K, N = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
val = [0, 0]
for i in range(N-1):
    distance = A[i+1]-A[i]
    if distance > val[1]:
        val[0] = i
        val[1] = distance
last = [N, A[0] + (K-A[N-1])]
if A[0] + (K-A[N-1]) > val[1]:
    val = last
print(K-val[1])


Measured memory_bytes: 25792
#include<algorithm>
#include<string>
#include<vector>
#include<iostream>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}
//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin>>n>>m;
    vec<ll> dp(n+10,mod);
    ll coin[50]={0};
    rep(i,m) cin>>coin[i];
    
    dp[0]=0;
    
    rrep(i,n+1){
        rep(j,m){
            if(i>=coin[j]) dp[i]=min(dp[i],dp[i-coin[j]]+1);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}



Measured memory_bytes: 3368
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <array>

using namespace std;
typedef long long ll;
int main()
{
	int N, Y;
	cin >> N >> Y;
	int money[3] = { 10000, 5000, 1000 };
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i; j++) {
			int k = N - i - j;
			if (i*money[0] + j*money[1] + k*money[2] == Y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int sta =0;
		int end =100;
		sta=Math.max(a, c);
		end = Math.min(b, d);
		int show = end-sta;
		if(show<=0) {
			System.out.println(0);
		}else {
		System.out.println(end-sta);
	}
	}
}


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

def calc(n):
    return sum(int(c) for c in str(n))

def check(n):
    for i in range(1, len(str(n))):
        p = 10**i
        m = (n // p + 1) * p - 1
        if n / calc(n) > m / calc(m):
            return False
    return True

def getlist():
    n, prev_n, d = 1, 0, 1
    while 1:
        if check(n):
            yield n
            d = n - prev_n
            prev_n = n
        n += d

from itertools import islice

for n in islice(getlist(), K):
    print(n)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <map>
using namespace std;

int main()
{
	int X,Y,ans;
	cin >> X >> Y;
	ans = X + Y/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
const int dx[9] = { 0, -1, 0, 1, 1,  1,  0, -1, -1 };
const int dy[9] = { 0,  1, 1, 1, 0, -1, -1, -1, 0 };

int main() {
    long long h, w, n; cin >> h >> w >> n;
    vector<pair<long long , long long>> points(n);
    for (int i = 0; i < n; i++) {
        long long a, b; cin >> a >> b;
        points[i] = { a, b };
    }

    map<pair<long long, long long>, long long> mp;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 9; j++) {
            int ny = points[i].first + dy[j];
            int nx = points[i].second + dx[j];

            if (2 <= ny && ny < h && 2 <= nx && nx < w) {
                mp[{ny, nx}]++;
            }
        }
    }
    map<int, long long> ans;
    for (int i = 1; i < 10; i++) {
        ans[i] = 0;
    }
    long long sum0 = 0;
    for (auto pn: mp) {
        auto cnt = pn.second;
        ans[cnt]++;
        sum0++;
    }
    cout << (h - 2) * (w - 2) - sum0 << endl;
    for (auto e: ans) {
        cout << e.second << endl;
    }
}


Measured memory_bytes: 58112
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[2][55];
vector <int> Vin;

int u[55];
ll dp[55];
int main() {
	int N, i, j;
	scanf("%d %s %s", &N, in[0], in[1]);

	for (i = 0; i < N;) {
		if (i + 1 == N || in[0][i] == in[1][i]) {
			Vin.push_back(1);
			i++;
		}
		else {
			Vin.push_back(2);
			i += 2;
		}
	}

	dp[0] = 6;
	if (Vin[0] == 1) dp[0] = 3;
	for (i = 1; i < Vin.size(); i++) {
		if (Vin[i] == 1 && Vin[i-1] == 1) dp[i] = dp[i - 1] * 2 % MOD;
		if (Vin[i] == 1 && Vin[i - 1] == 2) dp[i] = dp[i - 1];
		if (Vin[i] == 2 && Vin[i - 1] == 1) dp[i] = dp[i - 1] * 2 % MOD;
		if (Vin[i] == 2 && Vin[i - 1] == 2) dp[i] = dp[i - 1] * 3 % MOD;
	}
	return !printf("%lld\n", dp[Vin.size() - 1]);
}

Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

good = [True]*N

for i in range(M):
    a, b = [int(i)-1 for i in input().split()]
    if H[a] >= H[b]:
        good[b] = False
    if H[b] >= H[a]:
        good[a] = False

print(sum(good))

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

if H > W:
    H, W = W, H

count = [0] * 26
for i in a:
    for j in i:
        count[ord(j) - ord('a')] += 1

# print (count)
lst = [0] * 5
for c in count:
    lst[4] += c // 4
    c %= 4
    lst[2] += c // 2
    c %= 2
    lst[1] += c

# print (lst)
flag = False
if H >= 2 and W >= 2:
    if (H // 2) * (W // 2) <= lst[4]:
        lst[2] += (lst[4] - (H // 2) * (W // 2)) * 2 
        # print ('A')
        # print (lst)
        if ((H % 2) * (W // 2)) + ((W % 2) * (H // 2)) == lst[2] and (H % 2) * (W % 2) == lst[1]:
            flag = True
            # print ('B')

if H == 1 and W % 2 == 0:
    if lst[1] == 0:
        flag = True
if H == 1 and W % 2 == 1:
    if lst[1] == 1:
        flag = True

if flag:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  string S,T; cin>>S>>T;
  string ans="No";
  T.pop_back();
  if(S==T) ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int main(void)
{int A,B,C,x,i,a,b,l,r,g,m,tmp;
	long long int N,M;
	scanf("%lld%lld",&N,&M);
	a=0;
	if(N>=M)
	N=N;
	else{
	x=N;
	N=M;
	M=x;}
	if(M>=3)
	printf("%lld",(N-2)*(M-2));
	else if(M==2)
	printf("0");
	else if(M==1&&N>=2)
	printf("%d",N-2);
	else if(M==1&&N==1)
	printf("1");
	

	return 0;
}


Measured memory_bytes: 128
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    H, W = list(map(int, sys.stdin.readline().split()))
    L = [list(list(sys.stdin.readline().rstrip())) for i in range(H)]

    L = list(filter(lambda a: any(x == "#" for x in a), L))
    L = list(filter(lambda a : any(x == "#" for x in a), zip(*L)))
    for l in zip(*L):
        print("".join(l))

Measured memory_bytes: 5204
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner input=new Scanner(System.in);
		long N=input.nextInt(),K=input.nextInt(),X=(N/K);
		if(K%2 == 1) {
			System.out.println((N/K)*(N/K)*(N/K));
		}
		else {
			if(N%K>=K/2) {
				X+=1;
			}
			System.out.println((N/K)*(N/K)*(N/K)+X*X*X);
		}
	}
}

Measured memory_bytes: 22868
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
 
using namespace std;
 
vector<int>ans;
vector<int>E[100005];
int visited[100005];
 
void dfs(int v) {
 
	visited[v] = 1;
 
	int i;
 
	for (i = 0; i < E[v].size(); i++) {
		int u = E[v][i];
		if (visited[u] == 0) {
			ans.push_back(u);
			dfs(u);
			break;
		}
	}
 
}
 
int main() {
 
	int N, M;
 
	scanf("%d %d",&N,&M);
 
	int i;
 
	for (i = 0; i < M; i++) {
		int A, B;
		scanf("%d %d",&A,&B);
		E[A].push_back(B);
		E[B].push_back(A);
	}
	ans.push_back(1);
	dfs(1);
	reverse(ans.begin(),ans.end());
	dfs(1);
	cout << ans.size() << endl;
	for (i = 0; i<ans.size(); i++) {
		cout << ans[i];
		if (i != ans.size() - 1) {
			cout << " ";
		}
	}
	cout << endl;
 
	return 0;
}

Measured memory_bytes: 10104
class Factorials:
    def __init__(self, n, mod):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        self.fac = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            self.fac.append(num)

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        self.rec = [1 for i in range(n+1)]
        self.rec[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            self.rec[i] = num

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod
    
    # perm(n, r) ≡ nPr
    def perm(self, n, r):
        return self.fac[n] * self.rec[n-r] % self.mod

n, m = map(int, input().split())
mod = 10**9 + 7

f = Factorials(m, mod)

ans = 0
for i in range(n+1):
    if i % 2 == 0:
        ans += f.comb(n, i) * f.perm(m, i) * f.perm(m-i, n-i) * f.perm(m-i, n-i) % mod
    else:
        ans -= f.comb(n, i) * f.perm(m, i) * f.perm(m-i, n-i) * f.perm(m-i, n-i) % mod
    ans %= mod

print(ans)

Measured memory_bytes: 157256
import numpy as np

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for i in range(N):
    score = np.dot(A[i], B) + C
    if score > 0:
        ans += 1
    
print(ans)

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int len = s.length();
	int ans = 0, final_ans = INT_MIN;
	for (int i = 0; i < len; i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G'
				|| s[i] == 'T') {
			ans++;
		} else {
			ans = 0;
		}
		final_ans = max(final_ans, ans);
	}
	cout << final_ans << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define tenten senbun
#define takaku vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{
		if(f!=p.f)return f<p.f;
		if(s!=p.s)return s<p.s;
		return t<p.t;
	};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
ll gcd(ll n,ll m){
	ll k=n%m;
	while(k!=0){n=m;m=k;k=n%m;}
	return m;
}
void solve(){
	ll a,b;cin>>a>>b;
	cout<<gcd(a,b)<<kai;
}


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

int main(){
  int n, k, d, a, cnt=0; cin>>n >>k;
  vector<int> snuke(n, 0);
  
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>a;
      snuke[a-1]=1;
    }
  }
  
  for(int i=0;i<n;i++){
    if(!snuke[i])cnt++;
  }
  
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int a,b; cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
    return 0;
}


Measured memory_bytes: 256
#define first f
#define second s
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int k, x;
	cin >> k >> x;
	int a = x - k+1;
	int b = x + k - 1;
	for (int i = a; i <= b; i++) {
		cout << i << ' ';
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <math.h>
int main(void){
	double a,b,c,r,S,L,h,i,j,k,m;
	scanf("%lf %lf %lf",&a,&b,&r );
	S=a*b*sin(r/180*M_PI)/2;
	c=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(r/180*M_PI));
	h=b*sin(r/180*M_PI);
	printf("%f\n%f\n%f\n",S,a+b+c,h);

	return 0;
}

Measured memory_bytes: 692
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(){
    
    string T,t1,t2;

    cin >> T;

    int length = T.size();
    int sisuu1 = 0;
    int sisuu2 = 0;

    for(int i=0;i<length;i++)
    {
        t1 = T.substr(i,1);
        t2 = T.substr(i,2);
        if(t1 == "?")
        {
            T[i] = 'P';
            if(t1 == "D")
            {
                 sisuu1++;
            }
            if(t2 == "PD")
            {
                sisuu1++;
            }

            T[i] = 'D';
            if(t1 == "D")
            {
                 sisuu2++;
            }
            if(t2 == "PD")
            {
                sisuu2++;
            }

            if(sisuu1 <= sisuu2)
            {
                T[i] = 'D';
            }
            else
            {
                T[i] = 'P';
            }
        }
    }

    cout << T << endl;
    
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define N 200005
ll mod=1000000007;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(x) x.begin(),x.end()
#define lb lower_bound
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
 
int main(){
    
    fast;
    
    ll n;
    cin>>n;
    ll x=sqrt(n);
    ll ans=n-1;
    for(ll i=1;i<=x;i++){
        if(n%i==0){
            ans = min(ans , i-1 + n/i - 1);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=160;
int a[maxn],b[maxn],c[maxn],d[maxn];
bool used[maxn];
int girl[maxn],line[maxn][maxn];
int n;

bool Find(int x)
{
    for(int j=1;j<=n;j++)
    {
        if(line[x][j]&&!used[j]){
            used[j]=1;
            if(girl[j]==0||Find(girl[j])){
                girl[j]=x;
                return true;
            }
        }
    }
    return false;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    for(int i=1;i<=n;i++) cin>>c[i]>>d[i];
    memset(line,0,sizeof(line));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++){
            if((a[i]<c[j])&&(b[i]<d[j])){
                line[i][j]=1;
            }
        }
    }
    memset(girl,0,sizeof(girl));
    int ans=0;
    for(int i=1;i<=n;i++){
        memset(used,0,sizeof(used));
        if(Find(i)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

static const int  MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

void dijkstra()
{
    int minv,i;
    int d[MAX],color[MAX];

    for(i=0;i<n;i++)
    {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;

    while(1)
    {
        minv = INFTY;
        int u = -1;

        for(i=0;i<n;i++)
        {
            if(minv > d[i] && color[i] != BLACK)
            {
                u = i;
                minv = d[i];

            }
        }

        if(u == -1) break;
        color[u] = BLACK;
        for(int v = 0; v < n; v++)
        {
            if(color[v] != BLACK && M[u][v] != INFTY)
            {
                if(d[v] > d[u] + M[u][v])
                {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }

    for(i = 0; i < n;i++)
    {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }


}

int main()
{
  int e;
  int i,j;
  
 cin >>n;

    for(i = 0; i < n;i++)
        {
        for(j = 0; j < n; j++)
            {
             M[i][j] = INFTY;
            }
        }

    int k,c,u,v;

    for(i = 0; i < n; i++)
    {
        cin >> u >> k;
        for(j = 0; j < k; j++)
        {
            cin >> v >> c;
            M[u][v] = c;
        }
    }

 dijkstra();
 
  return 0;
  
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

bool comp(const string& l, const string& r) {
  return make_pair(l.size(), l) < make_pair(r.size(), r);
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int w, h; cin >> w >> h;
    if (!w) break;
    V<string> s(h); for (auto&& e : s) cin >> e;
    VV<string> dp(h + 1, V<string>(w + 1));
    string res;
    for (int i = h - 1; i >= 0; --i) for (int j = w - 1; j >= 0; --j) {
      if (!isdigit(s[i][j])) continue;
      dp[i][j] = max({dp[i][j], s[i][j] + dp[i][j + 1], s[i][j] + dp[i + 1][j]}, comp);
      if (dp[i][j][0] != '0') {
        res = max(res, dp[i][j], comp);
      }
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 3272
#include <iostream>
using namespace std;
int main(void){
    int a_1, a_2, a_3;
    
    cin >> a_1 >> a_2 >> a_3;
    
    if(a_1 + a_2 + a_3 < 22){
        cout << "win" << endl;
    } else {
        cout << "bust" << endl;
    }
    return 0;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
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 (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();
  map<int, int> m;
  for (int i = 0; i < n; ++i) {
    m[in()]++;
  }

  int64_t ans = 0;
  for (auto p : m) {
    if (p.first > p.second) {
      ans += p.second;
    } else {
      ans += (p.second - p.first);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int main()
{
    int n;
    bool first = true;
    while(cin >> n && n) {
        int a,b,c,d;
        cin >> a >> b >> c >> d;

        int m = a*10 + b*50 + c*100 + d*500;
        m -= n;

        d -= m/500;
        m %= 500;

        c -= m/100;
        m %= 100;

        b -= m/50;
        m %= 50;

        a -= m/10;
        m %= 10;

        if(!first) cout << endl;

        if(a > 0) cout << 10 << " " << a << endl;
        if(b > 0) cout << 50 << " " << b << endl;
        if(c > 0) cout << 100 << " " << c << endl;
        if(d > 0) cout << 500 << " " << d << endl;

        first = false;
    }

    return 0;
}

Measured memory_bytes: 1160