akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef long long ll;

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int k; cin >> k;
    k--;

    queue<ll> q;
    FOR(i, 1, 10) {
        q.push(i);
    }
    rep(i, k) {
        ll a = q.front(); q.pop();
        ll a1 = a % 10;
        if (a1 >= 1) { q.push(a * 10 + a1 - 1); }
        q.push(a * 10 + a1);
        if (a1 <= 8) { q.push(a * 10 + a1 + 1); }
    }
    cout << q.front() << endl;

    return 0;
}


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization ("Ofast")
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()

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;
}
template<class T> inline int getidx(vector<T> &v, T a) {
	return lower_bound(all(v), a) - v.begin();
}

constexpr int mod=998244353;
constexpr int inf=3e18;


signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int a,b;cin>>a>>b;
	if(b>=a)cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
}


Measured memory_bytes: 3648
N = int(input())
numbers = [int(n) for n in input().split(' ')]

counter = -1
last_h = float('inf')
_max = 0
for h in numbers:
    if h <= last_h:
        counter += 1
    else:
        if _max < counter:
            _max = counter
        counter = 0
    last_h = h
if _max < counter:
    _max = counter
print(_max)


Measured memory_bytes: 14224
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

struct node {
	ll distance;
	int pre;
	vector<int> conected;
};

void dikstra(node* nodes, int n) {
	priority_queue<pli, vector<pli>, greater<pli>> que;
	rep(i, n) que.push(pli(nodes[i].distance, i));

	while (!que.empty()) {
		pli t = que.top();
		que.pop();
		if (t.first > nodes[t.second].distance) continue;

		rep(i, nodes[t.second].conected.size()) {
			if (nodes[nodes[t.second].conected[i]].distance > nodes[t.second].distance + 1) {
				nodes[nodes[t.second].conected[i]].distance = nodes[t.second].distance + 1;
				nodes[nodes[t.second].conected[i]].pre = t.second;

				que.push(pli(nodes[nodes[t.second].conected[i]].distance, nodes[t.second].conected[i]));
			}
		}
	}
}

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

	int h, w;
	cin >> h >> w;
	string* s = new string[h];
	rep(i, h) cin >> s[i];

	node* nodes = new node[h*w];

	int sum = 0;
	rep(i, h) {
		rep(j, w) {
			nodes[i*w + j].distance = _MOD;
			
			if (s[i][j] == '.') {
				++sum;

				if (i != 0 && s[i - 1][j] == '.') nodes[i*w + j].conected.push_back((i - 1)*w + j);
				if (i != h - 1 && s[i + 1][j] == '.') nodes[i*w + j].conected.push_back((i + 1)*w + j);
				if (j != 0 && s[i][j - 1] == '.') nodes[i*w + j].conected.push_back(i*w + j - 1);
				if (j != w - 1 && s[i][j + 1] == '.') nodes[i*w + j].conected.push_back(i*w + j + 1);
			}
		}
	}

	nodes[0].distance = 0;
	dikstra(nodes, h*w);
	if (nodes[h*w - 1].distance != _MOD) {
		cout << sum - nodes[h*w - 1].distance - 1 << "\n";
	}
	else {
		cout << "-1" << "\n";
	}

	return 0;
}



Measured memory_bytes: 512
k,q = map(int,input().split())
d = [int(i) for i in input().split()]
#print(d)
for i in range(q):
    n,x,m = map(int,input().split())
    cum = [0]*(k+1)
    cnt = [0]*(k+1)
    for i in range(k):
        cum[i] = cum[i-1]+d[i]%m
        cnt[i] = cnt[i-1]
        if d[i]%m == 0:
            cnt[i]+=1
    res = x%m+cum[k-1]*((n-1)//k)+cum[((n-1)%k)-1]
    s = res//m
    print(n-1-s-cnt[k-1]*((n-1)//k)-cnt[(n-1)%k-1])

Measured memory_bytes: 56412
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    k = NI()

    a = k // 50
    p = [49+a] * 50
    b = k % 50

    for i in range(b):
        for j in range(50):
            if i == j:
                p[j] += 50
            else:
                p[j] -= 1


    print(50)
    print(*p,sep=' ')



if __name__ == '__main__':
    main()

Measured memory_bytes: 40472
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=8020;
const ll mod=1000000007;
int n;
ll jie[N],inv[N],ans,dp[N][N],vis[N][N];

inline ll KSM(ll a,ll p){
	ll ret=1;
	while(p){
		if(p&1) ret=(ret*a)%mod;
		p>>=1;
		a=(a*a)%mod;
	}
	return ret;
}

inline ll C(int n,int m){
	ll ret=(inv[m]*inv[n-m])%mod;
	return ret*jie[n]%mod;
}

int main()
{
//	freopen("1.in","r",stdin);
	jie[0]=1;
	for(ll i=1;i<=8000;i++) jie[i]=(jie[i-1]*i)%mod;
	for(int i=0;i<=8000;i++) inv[i]=KSM(jie[i],mod-2ll);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int ai,bi;
		scanf("%d%d",&ai,&bi);
		ans-=C((ai+bi)*2,ai*2);
		ans%=mod;
		vis[2001-ai][2001-bi]+=1;
		dp[2001+ai][2001+bi]+=1;
//		cout<<2001+ai<<" "<<2001+bi<<" "<<endl;
	}
//	cout<<ans<<endl;
	for(int s=8002;s>=1;s--)
		for(int i=1;i<=4001;i++){
			int j=s-i;
			if(j<1 || j>4001 || dp[i][j]==0) continue;
//			cout<<i<<" "<<j<<endl;
			if(vis[i][j]) ans=(ans+vis[i][j]*dp[i][j]%mod)%mod;
			dp[i-1][j]=(dp[i-1][j]+dp[i][j])%mod;
			dp[i][j-1]=(dp[i][j-1]+dp[i][j])%mod;
		}
//	cout<<ans<<endl;
	ans=ans*KSM(2ll,mod-2ll)%mod;
	ans=(ans+mod)%mod;
	printf("%d\n",(int)ans);
	return 0;
}

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

using namespace std ;

int main ()
{
   int x;
 int  sum=0;
   int n=0,r=0;
   cin>>x;
vector<int> A(x + 1);
   vector<int> s(x + 1);
  for(int i=0;i<x;i++)
  {

      cin>>s[i];



  }





   vector<int> k(x + 1);
  for(int i=0;i<x;i++)
  {

      cin>>k[i];



  }
  for(int i=0;i<x;i++)
  {
      n=s.at(0)+s.at(x-1);
  }

  for(int i=0;i<x;i++)
  {
      r=k.at(0)+k.at(x-1);
  }


  for(int i=0;i<x;i++)
    {
    A.at(i)=s.at(i)-k.at(i);
    if(A.at(i)>0) {
      sum=sum+A.at(i);
    }
  }
  cout<<sum<<endl;

  //if(n-r<=0) cout<<0<<endl;
  //else cout<<n-r;



    return 0 ;
}


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

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    long long l = lcm(n, m);
    long long N = l/n, M = l/m;
    map<long long, char> cnt;
    map<long long, bool> used;
    for(int i = 0; i < n; i++){
        cnt[i*N] = s[i];
        used[i*N] = true;
    }
    bool ok = true;
    for(int i = 0; i < m; i++){
        if(used[i*M] && cnt[i*M] != t[i]) ok = false;
    }
    if(ok) cout << l << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 15616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(void) {
    int k, s;
    cin >> k >> s;

    int cnt = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (0 <= z && z <= k) ++cnt;
        }

    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=60,Mod=1000000007;
int n,type[N],tot;
char s[N];
ll f[N][10],ans;
int main(){
	scanf("%d\n%s",&n,&s);
	for(int i=0;i<n;i++){
		if(s[i]==s[i+1]) type[++tot]=1,i++;
		else type[++tot]=0;
	}
	if(type[1]){
		for(int i=3;i<=8;i++) f[1][i]=1;
	}else{
		for(int i=0;i<=2;i++) f[1][i]=1;
	}
	for(int i=2;i<=tot;i++)
		if(type[i]){
			if(type[i-1]){
				f[i][3]=(f[i-1][5]+f[i-1][6]+f[i-1][7])%Mod;
				f[i][4]=(f[i-1][5]+f[i-1][7]+f[i-1][8])%Mod;
				f[i][5]=(f[i-1][3]+f[i-1][4]+f[i-1][8])%Mod;
				f[i][6]=(f[i-1][3]+f[i-1][7]+f[i-1][8])%Mod;
				f[i][7]=(f[i-1][3]+f[i-1][4]+f[i-1][6])%Mod;
				f[i][8]=(f[i-1][4]+f[i-1][5]+f[i-1][6])%Mod;
			}else{
				f[i][3]=f[i-1][2];
				f[i][4]=f[i-1][1];
				f[i][5]=f[i-1][2];
				f[i][6]=f[i-1][0];
				f[i][7]=f[i-1][1];
				f[i][8]=f[i-1][0];
			}
		}else{
			for(int j=0;j<=2;j++){
				if(type[i-1]){
					f[i][0]=(f[i-1][6]+f[i-1][8])%Mod;
					f[i][1]=(f[i-1][4]+f[i-1][7])%Mod;
					f[i][2]=(f[i-1][3]+f[i-1][5])%Mod;
				}else{
					f[i][0]=(f[i-1][1]+f[i-1][2])%Mod;
					f[i][1]=(f[i-1][0]+f[i-1][2])%Mod;
					f[i][2]=(f[i-1][0]+f[i-1][1])%Mod;
				}
			}
		}
	if(type[tot]){
		ans=(f[tot][3]+f[tot][4]+f[tot][5]+f[tot][6]+f[tot][7]+f[tot][8])%Mod;
	}else{
		ans=(f[tot][0]+f[tot][1]+f[tot][2])%Mod;
	}
	scanf("%s",&s);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

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

	int X, N;
	map<int, int> MP;

	cin >> X >> N;
	if(N == 0){
		printf("%d\n", X);
		return 0;
	}

	for(int i=0; i<N; i++){
		int p;
		cin >> p;
		MP[p] = 1;
	}

	int ans = 200;
	int d = 200;
	for(int i=0; i<=101; i++){
		if(MP.count(i) == 0){
			int tmp = abs(X - i);
			if(tmp < d){
				d = tmp;
				ans = i;
			}
		}
		else{
			continue;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3720
K, N = map(int, input().split())
A = list(map(int, input().split()))
 
D = [0]*N
 
for i in range(N-1):
  D[i] = A[i+1] - A[i]
D[N-1] = A[0] - A[N-1] + K
      
D.sort()
print(K - D[N-1])

Measured memory_bytes: 26444
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(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 ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int asta[10] = { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 };
	int n;
	cin >> n;
	string s;
	cin >> s;
	int calc = 0;
	int count1 = 0;
	int count2 = 0;
	REP(i, s.length()){
		if ((s.length() - i) % 2){
			if (s[i] == '*'){
				count1++;
			}
			else{
				calc += s[i] - '0';
			}
		}
		else{
			if (s[i] == '*'){
				count2++;
			}
			else{
				calc += asta[s[i] - '0'];
			}

		}
	}
	calc %= 10;
	cin >> n;
	vi able;
	REP(i, n){
		int a;
		cin >> a;
		able.push_back(a);
	}
	int numcount1[10] = { 0 };
	int numcount2[10] = { 0 };
		REP(j,able.size()){
			numcount1[able[j]]++;
		}
		REP(j, able.size()){
			numcount2[asta[able[j]]] ++;
		}

		int numcount3[10] = { 0 };

		REP(i, 10){
			numcount3[i] = numcount1[i];
		}
	REP(k, count1-1){
		int numcount4[10] = { 0 };
		REP(i, 10){
			REP(j, 10){
				numcount4[(i + j) % 10] += numcount3[i] * numcount1[j];
			}
		}
		REP(i, 10){
			numcount3[i] = numcount4[i];
		}
	}
	REP(i, 10){
		numcount1[i] = numcount3[i];
	}

	REP(i, 10){
		numcount3[i] = numcount2[i];
	}
	REP(k, count2-1){
		int numcount5[10] = { 0 };
		REP(i, 10){
			REP(j, 10){
				numcount5[(i + j) % 10] += numcount3[i] * numcount2[j];
			}
		}
		REP(i, 10){
			numcount3[i] = numcount5[i];
		}
	}
	REP(i, 10){
		numcount2[i] = numcount3[i];
	}
	int numcount6[10] = { 0 };
	REP(i, 10){
		REP(j, 10){
			numcount6[(i + j) % 10] += numcount1[i] * numcount2[j];
		}
	}
	cout << numcount6[(10-calc)%10]<<endl;

}

Measured memory_bytes: 1356
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>

using namespace std;

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

int N;
int x[1100];
vector<int> v[1100];

P dfs(int s){
    ll mi = 0;
    ll su = 0;
    vector<int> dif;
    for(int i = 0; i < v[s].size(); i++){
        P p = dfs(v[s][i]);
        if(p.first == -1 && p.second == -1){
            return P(-1, -1);
        }
        mi += min(p.first, p.second);
        su += p.first + p.second;
        dif.push_back(max(p.first, p.second) - min(p.first, p.second));
    }
    int y = x[s];
    if(y < mi){
        return P(-1, -1);
    }
    int value_dp[2][5500];
    fill(value_dp[0], value_dp[0]+5500, 0);
    fill(value_dp[1], value_dp[1]+5500, 0);
    value_dp[0][0] = 1;
    value_dp[1][0] = 1;

    for(int i = 0; i < v[s].size(); i++){
        for(int j = dif[i]; j <= y-mi; j++){
            if(value_dp[0][j-dif[i]] == 1){
                value_dp[1][j] = 1;
            }
        }
        for(int j = 0; j < 5500; j++){
            value_dp[0][j] = value_dp[1][j];
        }
    }

    for(int i = y-mi; i >= 0; i--){
        if(value_dp[0][i] == 1){
            mi += i;
            break;
        }
    }

    return P(y, su - mi);
}


int main(){
    cin >> N;
    for(int i = 1; i < N; i++){
        int p;  cin >> p;
        p--;
        v[p].push_back(i);
    }
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }

    P res = dfs(0);
    if(res.first == -1 && res.second == -1){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        cout << "POSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll Q,H,S,D,N;
ll A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>Q>>H>>S>>D>>N;
	A=min({4*Q,2*H,S});
	
	if(2*A<=D) cout<<N*A<<endl;
	else cout<<(N/2)*D+(N%2)*A<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 764
@H, @W = gets.chomp.split.map(&:to_i)

grids = []
@H.times do
  grids << gets.chomp
end

def replace(y, x, grids)
  return if grids[y][x] == "#"
  count = 0
  count += 1 if y - 1 >= 0 && grids[y - 1][x] == "#"
  count += 1 if y + 1 <= @H - 1 && grids[y + 1][x] == "#"
  count += 1 if x - 1 >= 0 && grids[y][x - 1] == "#"
  count += 1 if x + 1 <= @W - 1 && grids[y][x + 1] == "#"
  count += 1 if y - 1 >= 0 && x - 1 >= 0 && grids[y - 1][x - 1] == "#"
  count += 1 if y - 1 >= 0 && x + 1 <= @W - 1 && grids[y - 1][x + 1] == "#"
  count += 1 if y + 1 <= @H - 1 && x - 1 >= 0 && grids[y + 1][x - 1] == "#"
  count += 1 if y + 1 <= @H - 1 && x + 1 <= @W - 1 && grids[y + 1][x + 1] == "#"
  grids[y][x] = count.to_s
end

for j in 0..(@H - 1) do
  for i in 0..(@W - 1) do
    replace(j, i, grids)
  end
end

puts grids

Measured memory_bytes: 1788
// 別解

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ri()
	}

	cs := make([]int, 0, 200000)
	x := a[0]
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			cs = append(cs, i, x/i)
		}
	}
	y := a[1]
	for i := 1; i*i <= y; i++ {
		if y%i == 0 {
			cs = append(cs, i, y/i)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(cs)))

	for i := 0; i < len(cs); i++ {
		indivisible := 0
		for _, aa := range a {
			if aa%cs[i] != 0 {
				indivisible++
			}
			if indivisible >= 2 {
				break
			}
		}
		if indivisible <= 1 {
			fmt.Println(cs[i])
			return
		}
	}
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int N = 1e5+10;

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int i,dp[N]={0};
  	dp[0]=1;
    for (i=0;i<s.size();i++)
    {
        if (!dp[i])
            continue;
        if (i+5<=s.size() && s.substr(i,5)=="dream")
            dp[i+5]=1;
        if (i+5<=s.size() && s.substr(i,5)=="erase")
            dp[i+5]=1;
        if (i+6<=s.size() && s.substr(i,6)=="eraser")
            dp[i+6]=1;
        if (i+7<=s.size() && s.substr(i,7)=="dreamer")
            dp[i+7]=1;
    }
    if (dp[s.size()])
        cout<<"YES\n";
    else
        cout<<"NO\n";
}


Measured memory_bytes: 848
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 1e5+5;

template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int ac[N], wa[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m, k;
	int a, b;
	string s;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> k >> s;
		if (s[0] == 'W' && ac[k] == 0) {
			wa[k]++;
		} else {
			ac[k]++;
		}
	}

	a = b = 0;
	for (int i = 0; i <= n; ++i) {
		if (ac[i]) {
			++a;
			if (wa[i]) b += wa[i];
		}
	}

	cout << a << ' ' << b << '\n';
}
		

Measured memory_bytes: 4412
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

LL f[100010];
int n, w, x, y;

inline void work() {
    memset(f, -1, sizeof(f));
    f[0] = 0;
    cin >> n >> w;
    int totv = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        totv += y;
        for (int j = totv; j >= y; --j) {
            if (f[j - y] != -1) {
                f[j] = min(f[j] == -1 ? LONG_MAX : f[j], f[j - y] + x);
            }
        }
    }
    int ans = 0;
    for (int i = totv; i >= 0; --i) {
        if (f[i] != -1 && f[i] <= w) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

int main() {
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   char x,y;
   cin>>x>>y;
   if(x<y)cout<<'<'<<endl;
   else if(x==y)cout<<'='<<endl;
   else cout<<'>'<<endl;
   
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop

class UnionFind:
    def __init__(self, n):
        self.root = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    def find(self, x):
        if self.root[x] == x:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.root[x] = y
        else:
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

def kruskal(D, n):
    G = []
    UF = UnionFind(n)
    while len(D) > 0:
        cost, n1, n2 = heappop(D)

        if UF.is_same(n1, n2):
            continue
        else:
            G.append((cost, n1, n2))
            UF.unite(n1, n2)

    return G

def main():
    input = sys.stdin.readline
    N = int(input())
    C = []
    for i in range(N):
        x, y = map(int, input().split())
        C.append((i, x, y))

    X = sorted(C, key=lambda x: x[1])
    Y = sorted(C, key=lambda x: x[2])

    D = []
    for i in range(N-1):
        a, xa, _ = X[i]
        b, xb, _ = X[i+1]

        c, _, yc = Y[i]
        d, _, yd = Y[i+1]


        heappush(D, (xb - xa, a, b))
        heappush(D, (yd - yc, c, d))

    G = kruskal(D, N)
    ans = 0
    for g in G:
        ans += g[0]

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 49628
import sys
r=sys.stdin.readline
for e in iter(r,'0\n'):
 R=[[]for _ in[0]*-~int(e)]
 for _ in[0]*int(r()):
  a,b=map(int,r().split())
  R[a]+=[b];R[b]+=[a]
 for m in R[1][:]:R[1]+=R[m]
 print(len({*R[1]}-{1}))


Measured memory_bytes: 6300
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int max = 0;
    int min = 1000000000;

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      max = Math.max(max,a[i]);
      min = Math.min(min,a[i]);
    }

    System.out.println(max-min);
  }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
using namespace std;
int l,r,mid,sum=0,ok,graph[305][305],i,j,n,m,ch[305],vis[305],tt;
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)scanf("%d",&graph[i][j]);
	l=1;r=n;
	while(l<r)
	{
		mid=(l+r)/2;
		memset(vis,0,sizeof(vis));
		for(i=1;i<=n;i++)ch[i]=1;
		ok=tt=0;
		while(!ok&&!tt)
		{
			ok=tt=1;
			for(i=1;i<=m;i++)
			{
				if(vis[i])continue;
				sum=tt=0;
				for(j=1;j<=n;j++)if(graph[j][ch[j]]==i)sum++;
				if(sum>mid)
				{
					vis[i]=1;ok=0;
					for(j=1;j<=n;j++)while(vis[graph[j][ch[j]]])ch[j]++;
				}
			}
		}
		if(tt)l=mid+1;
		else r=mid;
	}
	printf("%d",l);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
long long n,m,i,j,l,r,mid,ans1,ans2,num[100005];
int main()
{
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>num[i];
	}
	ans1=ans2=2;
	for (i=n;i;i--)
	{
		if (ans1%num[i]!=0)
		{
			ans1-=ans1%num[i];
		}
		if (ans2%num[i]!=0)
		{
			ans2+=num[i]-ans2%num[i];
		}
		if (ans2>ans1) {cout<<-1;return 0;}
		ans1+=num[i]-1;
	}
	cout<<ans2<<' '<<ans1;
	return 0;
}

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

int x[1000000], n;

int func(int t, int r) {
	int p, a, b, j;
	p = x[r];
	j = t - 1;
	for (int i = t; i < r; i++) {
		if (x[i] <= p) {
			j = j + 1;
			a = x[i];
			b = x[j];
			x[i] = b;
			x[j] = a;
		}
	}
	a = x[j + 1];
	b = x[r];
	x[j + 1] = b;
	x[r] = a;
	return j + 1;
}

int main() {
	int c;
	cin >> n;
	for (int k = 0; k < n; k++) {
		cin >> x[k];
	}
	c = func(0, n - 1);
	for (int k = 0; k < n; k++) {
		if (k) {
			cout << ' ';
		}
		if (k == c) {
			cout << '[';
		}
		cout << x[k];
		if (k == c) {
			cout << ']';
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
#define vin vector<long long>
#define vch vector<char>
#define vst vector<string>
#define vbo vector<bool>
#define vvin vector<vin>
#define vvch vector<vch>
#define int long long
#define pin pair<int,int>
#define ppin pair<int,pin>
#define mkp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define repf(i,f,n) for(int i=f;i<n;i++)
#define maxel(vec, j) *max_element(vec.begin(), vec.begin()+j)

using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
int vsum(vin v){ return accumulate(v.begin(), v.end(), 0); }
int msum(vvin v){
    int ans = 0;
    rep(i, v.size()){
        ans += vsum(v[i]);
    }
    return ans;
}
const int MOD = 1000000007;
signed main() {
    int N, M;
    cin >> N;
    set<int> a;
    multiset<int> b;
    rep(i, N){
        int c;
        cin >> c;
        a.insert(c);
        b.insert(c);
    }
    if(a.size() == 1){
        set<int>::iterator i = a.begin();
        int x = *i++;
        if(x == 0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    if((N%3) == 0){
        if(a.size() == 2){
            set<int>::iterator i = a.begin();
            int x = *i++;
            int y = *i++;
            if(b.count(x) == (2 * b.count(y))){
                if((y == 0)){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
            if((2 * b.count(x)) == b.count(y)){
                if((x == 0)){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    if((N%3) == 2){
        if(a.size() == 2){
            set<int>::iterator i = a.begin();
            int x = *i++;
            int y = *i++;
            if(b.count(x) == (2 * b.count(y))-1){
                if((y == 0)){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
            if((2 * b.count(x))-1 == b.count(y)){
                if((x == 0)){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    if((N%3) != 0){
        cout<<"No"<<endl;
        return 0;
    }
    if(a.size() != 3){
        cout<<"No"<<endl;
        return 0;
    }
    set<int>::iterator i = a.begin();
    int x = *i++;
    int y = *i++;
    int z = *i++;
    if(!(b.count(x) == b.count(y) && b.count(y) == b.count(z))){
        cout<<"No"<<endl;
        return 0;
    }
    if(((x ^ y) == z) || ((y ^ z) == x) || ((z ^ x) == y)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
 
    return 0;
}
/*
 *
 *
4
1 2 4 8
 */


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s,t;
  cin>>s;
  cin>>t;

  ll ans=0;
  REP(i,s.size()){
    if(s[i]!=t[i])
      ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3788
#include<stdio.h>
int main(void)
{
	int a=0,i;
	char s[32],t[32]="CODEFESTIVAL2016";
	scanf("%s",&s);
	for(i=0;i<16;i++){
		if(s[i]!=t[i]){
			a++;
		}
	}
	printf("%d\n",a);
	return 0;
}

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

 typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   
    #endif
}
int fact[200005] , inv[200005];


int nck(int n,int k)
{
  int an = fact[n];
  an = (an%M * inv[k]%M)%M;
  an = (an%M * inv[n-k]%M)%M;
  return an;
}

int ras(int a,int b)
{
  int an = 1;
  while(b>0)
  {
    if(b%2!=0) an = (a%M * an%M)%M;
    b/=2;
    a = (a%M * a%M)%M;
  }
  return an;
}

void fill()
{
  fact[0]=1 , fact[1]=1;
  inv[0] = 1 , inv[1]=1;

  for(int i=2;i<=200002;i++)
  {
    fact[i] = (i%M *fact[i-1]%M);
    inv[i] = (inv[i-1]%M * ras(i,M-2)%M)%M;
  }
}

void solve()
{

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

fill();

if(n==1)
{
  cout<<m<<endl;
  return ;
}

int rs = 0;

for(int i=0;i<=k;i++)

{
  int an = m%M;
  an = (an % M * nck(n-1,i) % M ) % M;
  // cout<<an<<endl;
  an = (an % M* ras(m-1,n-i-1) %M ) % M;
  rs += an;
  rs %= M;
  //cout<<an<<endl;
}


cout<<rs<<endl;
}

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

 }

Measured memory_bytes: 6748
#include <iostream>
using namespace std;
typedef long long ll;
ll ans, res;
string str;
int main(void){
    // Your code here!
    cin >> str;
    for (ll i = 0; i < str.length(); i++) {
        if (str[i] == 'S') {
            ans++;
        } else if (str[i] == 'T' && ans > 0) {
            res += 2, ans--;
        } else {
            ans = 0;
        }
    }
    cout << str.length() - res << endl;
}


Measured memory_bytes: 640
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll K, Q;
    cin >> K >> Q;
    vector<ll> Ds(K);
    rep(i,0,K) {
        cin >> Ds[i];
    }
    rep(q,0,Q) {
        ll N, X, M;
        cin >> N >> X >> M;
        vector<ll> mod_ds(K);
        rep(k,0,K) {
            mod_ds[k] = Ds[k] % M;
            if (mod_ds[k] == 0) {
                mod_ds[k] = M;
            }
        }
        ll inc = 0;
        ll sum = 0;
        rep(i,0,K) {
            if ((N-1) % K == i) {
                inc += sum;
            }
            sum += mod_ds[i];
        }
        inc += (N-1)/K * sum;
        X = X % M;
        ll dec_cnt;
        if (inc < M - X) {
            dec_cnt = 0;
        } else {
            inc -= (M - X);
            dec_cnt = 1 + inc/M;
        }
        cout << N - 1 - dec_cnt << endl;
    }
}


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

//0093
int main(){
	int y1, y2, n=0;
	while(cin >> y1 >> y2, y1||y2){
		int count = 0;
		if(n){
			cout << endl;
		}
		++n;
		for(int i=y1; i<y2+1; ++i){
			if( (i%4)==0 && (i%100)!=0 || i%400==0 ){
				cout << i << endl;
				++count;
			}
		}

		if(!count){
			cout << "NA" << endl;
		}
		
	}
}

Measured memory_bytes: 0
function main()
	lines=readlines()
	N,M=map(x->parse(Int,x),split(shift!(lines)))
	G=[Array{Int}(0) for _=1:N]
	for s=lines
		u,v,w=map(x->parse(Int,x),split(s))
		push!(G[u],v)
		push!(G[v],u)
	end
	used=[false for _=1:N]
	function dfs(u)
		used[u]=true
		for v=G[u]
			if !used[v]
				dfs(v)
			end
		end
	end
	ans=0
	for i=1:N
		if !used[i]
			dfs(i)
			ans+=1
		end
	end
	println(ans)
end
main()


Measured memory_bytes: 191960
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
a = list(map(int, input().split()))

posit = [0]*n
arrive_time = [0]*n

loop_len = 0
preloop_len = 0

post_posit = 1
for i in range(n):
    next_posit = a[post_posit-1]
    # print("PostPosit: " + str(post_posit) + ", NextPosit: " + str(next_posit))
    if arrive_time[next_posit-1] == 0:
        arrive_time[next_posit-1] = i+1
        posit[i] = next_posit
        post_posit = next_posit
    else:
        preloop_len = arrive_time[next_posit-1]
        loop_len = i+1 - preloop_len
        # print("Already Visited")
        # print("PreloopLen: " + str(preloop_len) + ", LoopLen: " + str(loop_len))
        break

if k <= preloop_len:
    print(posit[k-1])
else:
    move_in_loop = k-preloop_len
    posit_in_loop = move_in_loop % loop_len
    # print(posit_in_loop)
    print(posit[preloop_len+posit_in_loop-1])

Measured memory_bytes: 92580
def distance(i,j,X,Y):
    return min([abs(i-j), abs(X-i)+1+abs(Y-j), abs(Y-i)+1+abs(X-j)])

N,X,Y=[int(e) for e in input().split(' ')]
cnt=[0]*(N-1)

for i in range(1,N):
    for j in range(i+1,N+1):
        #print('i={},j={}'.format(i,j))
        d=distance(i,j,X,Y)
        cnt[d-1]+=1
for c in cnt:
    print(c)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
    int n;  cin >> n;
    vector<long long> a(n), s(n+1, 0);
    map<long long, long long> m;
    m[0] = 1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s[i+1] = s[i] + a[i];
        m[s[i+1]]++;
    }

    long long ans = 0;
    for (auto itr: m) {
        long long c = itr.second;
        ans += c*(c-1)/2;
    }
    cout << ans << endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int ab[2];
	rep(i,2) cin >> ab[i];
	for(int i = 1; i <= 3; i++){
		if(ab[0] != i && ab[1] != i){
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include"stdio.h"
#include<iostream>
#include<cmath>
using namespace std;

#define Pi 3.1415926535

typedef struct Point
{
	double x;
	double y;
};

Point rotate(Point center,Point target,double angle)
{
	double ans_x;
	double ans_y;
	ans_x = (target.x - center.x)*cos(angle) - (target.y - center.y)*sin(angle) + center.x;
	ans_y = (target.x - center.x)*sin(angle) + (target.y - center.y)*cos(angle) + center.y;
	Point P = { ans_x,ans_y };
	return P;
}

void func(Point previous, Point next,int n)
{
	if (n <= 0);
	else
	{
		double x1 = previous.x;
		double y1 = previous.y;
		double x2 = next.x;
		double y2 = next.y;
		double lx = x2 - x1;
		double ly = y2 - y1;
		Point P1 = { x1 + lx / 3,y1 + ly / 3 };
		Point P2;
		Point P3 = { x1 + lx / 3 * 2,y1 + ly / 3 * 2 };
		P2 = rotate(P1, P3, Pi / 3);
		func(previous, P1, n - 1);
		printf("%.8lf %.8lf\n", P1.x, P1.y);
		func(P1, P2, n - 1);
		printf("%.8lf %.8lf\n", P2.x, P2.y);
		func(P2, P3, n - 1);
		printf("%.8lf %.8lf\n", P3.x, P3.y);
		func(P3, next, n - 1);
	}
}

int main()
{
	int n;
	cin >> n;
	Point point_start = { 0,0 };
	Point point_end = { 100,0 };
	printf("%.8lf %.8lf\n", point_start.x, point_start.y);
	func(point_start, point_end, n);
	printf("%.8lf %.8lf\n", point_end.x, point_end.y);
	return 0;
}

Measured memory_bytes: 3352
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//ABC 143B
int main() {
	int n;
	int a[100];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			int point = a[i] * a[j];
			sum += point;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Lamp_switch = []
for _ in range(M):
    S = list(map(int, input().split()))[1:]
    Lamp_switch.append(S)
 
Pon = list(map(int, input().split()))
ans = 0

for i in range(2**N):
  Cou = [0]*M
  for j in range(N):
    if (i>>j)&1:
      for k in range(M):
        if (j+1) in Lamp_switch[k]:
          Cou[k] += 1
          Cou[k] %= 2
  if Cou == Pon:
    ans += 1
    
print(ans)
        
    

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct S{
  int idx, val;
  double score;
  S(int i, int v, double s) :
    idx(i), val(v), score(s) {}
  bool operator < (const S& st) const {
    if(score != st.score) return score > st.score;
    if(idx != st.idx) return idx < st.idx;
    return val > st.val;
  }
};

int main(){
  int N;
  while(cin>>N && N){
    int a[20];
    REP(i, N) cin>>a[i];
    priority_queue<S> que;
    FOR(v, 1, 100001) que.push(S(1, v, (double)abs(a[0] - v) / a[0]));
    while(!que.empty()){
      S s = que.top(); que.pop();
      if(s.idx == N){
        printf("%.12f\n", s.score);
        break;
      }
      for(int k = 1; k * s.val <= 150000; k++){
        int nv = k * s.val;
        que.push(S(s.idx + 1, nv, max(s.score, (double)abs(a[s.idx] - nv) / a[s.idx])));
      }
    }
  }
  return 0;
}

Measured memory_bytes: 11224
use proconio::{fastout, input};

use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: usize,
        aa: [i64; n]
    };

    let mut v = Vec::new();

    for (i, a) in aa.iter().enumerate() {
        v.push((a, i));
    }

    v.sort();
    v.reverse();

    let mut dp = vec![vec![0; n + 1]; n + 1];

    for i in 0..n {
        let (a, p) = v[i];
        let p = p as i64;
        for x in 0..=i {
            let y = i - x;
            let i = i as i64;
            dp[x + 1][y] = max(dp[x + 1][y], dp[x][y] + (p - x as i64).abs() * a);
            dp[x][y + 1] = max(
                dp[x][y + 1],
                dp[x][y] + (p - (n as i64 - 1 - y as i64)).abs() * a,
            );
        }
    }

    let mut ans = 0;
    for v in dp {
        for v in v {
            if ans < v {
                ans = v;
            }
        }
    }

    println!("{}", ans);
}


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

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

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();

            int ans = 753;
            for (int i = 0; i < S.length() - 2; i++) {
                int temp = Math.abs(753 - Integer.parseInt(S.substring(i, i + 3)));
                if (temp < ans) {
                    ans = temp;
                }
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll f(ll st,vector<vector<ll> >& v,vector<ll>& h)
{
    if(h[st]!=-1)
        return h[st];
    if(v[st].size()==0)
        return h[st]=0;
    ll mx=0,dep;
    for(ll i=0;i<v[st].size();i++)
    {
        if(h[v[st][i]]!=-1)
            dep=h[v[st][i]];
        else
        {
            h[v[st][i]]=f(v[st][i],v,h);
            dep=h[v[st][i]];
        }
        mx=max(mx,dep);
    }
    h[st]=mx+1;
    return h[st];
}
int main()
{
    ll n,m,x,y,c=0,ans=0;
    cin>>n>>m;
    vector<vector<ll> >v(n+1);
    vector<ll>vis(n+1,0);
    for(ll i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    vector<ll>h(n+1,-1);
    for(ll i=1;i<=n;i++)
          int x=f(i,v,h);
    
    ll mx=0;
    for(ll i=1;i<=n;i++)
    {
        mx=max(mx,h[i]);
    }
        
    cout<<mx<<endl;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i,M)
  {
    cin >> B[i];
  }
  vector<vector<int>> A(N,vector<int>(M));
  rep(i,N)
  {
    rep(j,M)
    {
      cin >> A[i][j];
    }
  }
  int count = 0;
  rep(i,N)
  {
    int sum = C;
    rep(j,M)
    {
      sum += A[i][j]*B[j];
    }
    if(sum > 0)
    {
      count ++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Integer count = 0;
		int flag = 0;
		Scanner sc = new Scanner(System.in);

		//入力する数
		int number = sc.nextInt();
		int blackbord[] = new int[number];

		for (int i = 0; i < number; i++){
			blackbord[i] = sc.nextInt();
			//System.out.println(blackbord[i]);
		}
		
		while(flag == 0){
			for(int i = 0; i < number; i++){
				if (blackbord[i] % 2 != 0){
					flag = 1;
					break;
				}
			blackbord[i] = blackbord[i]/2;
			
			count += 1;
			
		}
	}

	count = count / number;
	System.out.println(count);


	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int x;
  cin>>x;
  if(x==5||x==7||x==3)
    yes;
  else
    no;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3560