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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> s(m),c(m);
  for(int i=0;i<m;i++){
    cin >> s.at(i) >> c.at(i);
  }
  bool frag=true;
  vector<int> a(n,-1);
  for(int i=0;i<m;i++){
    if(a.at(n-s.at(i))==-1||a.at(n-s.at(i))==c.at(i)){
      a.at(n-s.at(i))=c.at(i);
    }else{
      frag=false;
    }
  }
  if(a.at(n-1)==0&&n==1){
    cout << 0;
    return 0;
  }else if(a.at(n-1)==0){
    frag=false;
  }
  if(frag==true&&n==1&&m==0){
    cout << 0;
  }else if(frag==true){
    if(a.at(n-1)==-1){
      cout << 1;
      }else{
      cout << a.at(n-1);
    }
    for(int i=0;i<n-1;i++){
      if(a.at(n-i-2)==-1){
        cout << 0;
        }else{
        cout << a.at(n-i-2);
      }
    }
  }else{
    cout << -1;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a[100], b = 0, n, c[100], sum2 = 1;
	long long sum = 1;
	while (sum <= 1000000) {
		a[b] = sum;
		c[b] = sum2;
		b++;
		sum *= 4;
		sum2 *= 10;
	}
	while (cin >> n&&n != -1) {
		char sum3[100];
		bool e = false, f = false;
		sum2 = 0;
		for (int i = b - 1; i >= 0; i--) {
			if (n >= a[i]) {
				e = true;
				f = true;
				int d = (n - (n%a[i])) / a[i];
				sum3[sum2] = (char)d+'0';
				sum2++;
				n -= (a[i] * d);
			}
			if (e&&!f) {
				sum3[sum2] = '0';
				sum2++;
			}
			f = false;
		}
		for (int i = 0; i < sum2; i++) {
			cout << sum3[i];
		}
		if (sum2 == 0) cout << 0;
		cout << endl;
	}
}

Measured memory_bytes: 3076
N = int(input())
W = []
for _ in range(N):
    W += [input()]

wordset = set()

for i, word in enumerate(W):
    if i == 0:
        wordset.add(word)
        continue
    # print(f"i:{i} word:{word[0]} W[i - 1][-1]:{W[i-1][-1]}", file=sys.stderr)
    if word in wordset or word[0] != W[i - 1][-1]:
        print("No")
        break

    wordset.add(word)
else:
    print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

    int N, M;
    cin>> N>> M;
    vector<vector<char> > fld;
    for(int i=0; i<N; i++){
        vector<char> v;
        for(int j=0; j<M; j++){
            char c;
            cin>> c;
            v.push_back(c);
        }
        fld.push_back(v);
    }

    int ans=51*51;
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            int cnt=0;
            for(int k=0; k<=i; k++){
                cnt+=count(fld[k].begin(), fld[k].end(), 'B');
                cnt+=count(fld[k].begin(), fld[k].end(), 'R');
            }
            for(int k=i+1; k<=j; k++){
                cnt+=count(fld[k].begin(), fld[k].end(), 'W');
                cnt+=count(fld[k].begin(), fld[k].end(), 'R');
            }
            for(int k=j+1; k<N; k++){
                cnt+=count(fld[k].begin(), fld[k].end(), 'W');
                cnt+=count(fld[k].begin(), fld[k].end(), 'B');
            }
            ans=min(ans, cnt);
        }
    }

    cout<< ans<< endl;

    return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<algorithm>
#include<cstdint>
using namespace std; // 575

int main() {
	int N;
	cin >> N;
	static int A[100000], B[100000], C[100000];
	for (int i = 0;i < N;++ i) cin >> A[i];
	for (int i = 0;i < N;++ i) cin >> B[i];
	for (int i = 0;i < N;++ i) cin >> C[i];
	sort(A, A+N);
	sort(B, B+N);
	sort(C, C+N);
	int64_t l = 0, r = 0, ans = 0;
	for (int i = 0;i < N;++ i) {
		while (l < N && A[l] < B[i]) ++ l; // lはB[i]より小さいAの個数
		while (r < N && B[i] >= C[r]) ++ r; // rはB[i]以下のCの個数
		ans += l * (N - r);
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

*/

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

int main() {
    while (1) {
        int ans = 0;
        string number;
        cin >> number;
        
        if (number == "0") {
            return 0;
        } else {
            for (int i = 0; i < number.size(); i++) {
                ans += number[i] - '0';
            }
            cout << ans << endl;
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> V;
  V.push_back(1);
  for (int i = 6; i <= 1e6; i *= 6) V.push_back(i);
  for (int i = 9; i <= 1e6; i *= 9) V.push_back(i);
  vector<int> DP(N + 1, 2e9);
  DP.at(0) = 0;
  for (auto v : V) {
    for (int i = 0; i < N + 1; i++) {
      if (DP.at(i) != 2e9 && i + v < N + 1) {
        DP.at(i + v) = min(DP.at(i + v), DP.at(i) + 1);
      }
    }
  }
  cout << DP.at(N) << "\n";
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define all(a) a.begin(),a.end()
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){x=x>y?y:x;}
template<class T> inline void gmax(T &x,const T &y){x=x<y?y:x;}
template<class T> inline bool Gmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T> inline bool Gmax(T &x,const T &y){return x<y?x=y,1:0;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=200005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,a[N],b[N];

int main(){
#ifdef rqgao2014
	assert(freopen("input.txt","r",stdin));
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	int ans=0;
	for(int i=1;i<=n;i++){
		int res=0;
		for(int j=1;j<=i;j++)
			res+=a[j];
		for(int j=i;j<=n;j++)
			res+=b[j];
		gmax(ans,res);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	vector<int>a;
	int n;
	int x;
	long long ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &x);
		x -= i;
		a.push_back(x);
	}

	sort(a.begin(), a.end());
	x = a[((n - 1) / 2)];
	f(i, n){
		ans += abs(a[i] - x);
	}


	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 1400
N = int(input())
red = []
for i in range(N):
    a, b = map(int, input().split())
    red.append((a, b))
red = sorted(red, key=lambda x: (x[1]), reverse=True)
# print(red)

blue = []
for i in range(N):
    a, b = map(int, input().split())
    blue.append((a, b))
blue = sorted(blue, key=lambda x: (x[0], x[1]))
# print(blue)

count = 0
for i in range(N):
    b = blue[i]
    # print("{}".format(b))
    for j in range(len(red)):
        r = red[j]
        # print("{}".format(r))
        if r[0] < b[0] and r[1] < b[1]:
            # print("{}:{}".format(b, r))
            count += 1
            red.pop(j)
            break

print(count)


Measured memory_bytes: 38768
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

let n : Int = arr[0]

class table99 {
  private var table: [ Int : Bool ] = [:]
  
  init () {
    for i in 1...9 {
      for j in 1...9 {
        table[ i * j ] = true
      }
    }
  }
  
  func is99able (number: Int) -> Bool {
    return table.keys.contains(number)
  }
}

let t = table99()
if( t.is99able(n) ) {
  print( "Yes" )
} else {
  print( "No" )
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

bool isKaibun(string t) {
    int m = t.length();
    for (int i = 0; i < m / 2; i++) {
        if (t[i] != t[m - 1 - i]) {
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int n = s.length();
    string sub1 = s.substr(0, (n - 1) / 2);
    string sub2 = s.substr((n + 3) / 2 - 1);
    if (isKaibun(sub1) && isKaibun(sub2) && isKaibun(s)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,w,p,q;
    ans=0;
    string s;
    cin>>s;
    if(s[1]!=s[2]||s[0]!=s[1]||s[0]!=s[2])
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    
    
}


Measured memory_bytes: 256
a,b,c = map(int, raw_input().split())
ans = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
  newa = b/2 + c/2
  newb = a/2 + c/2
  newc = a/2 + b/2
  if a == b == c == newa == newb == newc:
    print '-1'
    exit()
  a = newa
  b = newb
  c = newc
  ans += 1

print ans

Measured memory_bytes: 2568
#include<stdio.h>

int main(void){
    
 int x,y;
 scanf("%d %d",&x,&y);
 while( x != 0 || y != 0) {
     
    if (x>y)
    printf("%d %d\n",y,x);
    else
    printf("%d %d\n",x,y);
    scanf("%d %d", &x,&y);
}


return 0;
   
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

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

template <std::uint_fast64_t Modulus>
class modint {
    using u64 = std::uint_fast64_t;
    u64 x;

public:
    constexpr modint(const u64 x = 0) noexcept : x(x % Modulus) {}
    constexpr u64 &value() noexcept { return x; }
    constexpr const u64 &value() const noexcept { return x; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
        if((x += rhs.x) >= Modulus) x -= Modulus;
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if((x += Modulus - rhs.x) >= Modulus) x -= Modulus;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        x = x * rhs.x % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) *this *= rhs;
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    bool operator==(const modint &rhs) const { return x == rhs.x; }
    bool operator!=(const modint &rhs) const { return x != rhs.x; }
    friend ostream& operator<<(ostream& os, const modint &m){
        return os << m.x;
    }
    friend istream &operator>>(istream &is, modint &m) {
        u64 x;
        is >> x;
        m = modint<Modulus>(x);
        return (is);
    }
};

modint<MOD> dp[55][55][55*55];

int main(){
    int n, k;
    cin >> n >> k;
    dp[0][0][0] = 1;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            for(int k=0; k<=n*n; k++){
                dp[i+1][j+1][k+2*(j+1)] += dp[i][j][k];
                dp[i+1][j][k+2*j] += modint<MOD>(2*j+1)*dp[i][j][k];
                if(j-1>=0)
                    dp[i+1][j-1][k+2*(j-1)] += modint<MOD>(j*j)*dp[i][j][k];
            }
        }
    }
    cout << dp[n][0][k] << endl;
    return 0;
}

Measured memory_bytes: 66560
#include <cstdio>
#include <algorithm>
using namespace std;

int a,b,ans;

int main(void){
	scanf("%d %d",&a,&b);
	if(b==1){
		printf("0");
		return 0;
	}
	for(int i=1;i<=b;i++){
		if(a*i-(i-1)>=b){
			printf("%d\n",i);
			return 0;
		}
	}
}

Measured memory_bytes: 128
ss = list(input())
ts = list(input())

def check():
    global ss
    global ts
    d = {}
    for s,t in zip(ss,ts):
        if s in d:
            if d[s] != t:
                return False
        else:
            d[s] = t
    
    ss, ts = ts, ss
    d = {}    
    for s,t in zip(ss,ts):
        if s in d:
            if d[s] != t:
                return False
        else:
            d[s] = t
    return True

if check():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 70348
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] array = new int[N];
    	for (int i = 0; i < N; i++) {
    		array[i] = sc.nextInt();
    	}
    	List<String> pattern = new ArrayList<>();
    	for (int i = 0; i < Math.pow(3, N); i++) {
    		String p = Integer.toString(i, 3);
    		if (p.length() < N) {
    			while (p.length() != N) {
    				p = "0" + p;
    			}
    		}
    		pattern.add(p);
    	}
    	int count = 0;
    	for (String s : pattern) {
    		int pro = 1;
    		for (int i = 0; i < s.length(); i++) {
    			if (s.charAt(i) == '0') {
    				pro *= array[i]-1;
    			} else if (s.charAt(i) == '1') {
    				pro *= array[i];
    			} else {
    				pro *= array[i]+1;
    			}
    		}
    		if (pro%2 == 0) {
    			count++;
    		}
    	}
    	System.out.println(count);
    }
}

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

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans=0;
    for(int i=0;i<=a;i++){
        int tempa= x-i*500;
        for(int j=0;j<=b;j++){
                int tempb=tempa-j*100;
            for(int k=0;k<=c;k++){
                    int tempc=tempb-k*50;    
                    if(tempc == 0){
                        //cout << i << j << k << endl;
                        ans++;
                    }
            }
        }
    }
    cout << ans<<endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// get a integer
		int a = sc.nextInt();
		// get two integers separated with half-width break
		int b = sc.nextInt();
		int c = sc.nextInt();
		// output
		System.out.println(a * b / 2);
	}
}

Measured memory_bytes: 25172
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1241>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
ll n;
void rec(ll N,ll sum,ll dep,ll& res){
    if(sum == n){
        res++;
        return;
    }
    if(dep == 3) return;
    for(ll i = N; i*i+sum <= n;i++){
        rec(i,sum+i*i,dep+1,res);
    }
}
ll solve(){
    ll res = 0;
    for(ll i = 1; i*i <= n;i++){
        rec(i,i*i,0,res);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> n,n){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<double> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        v[i] = (v[i] + 1)/2;
    }
    double res = 0;
    for (int i = 0; i < k; i++) {
        res += v[i];
    }
    double ans = res;
    for (int i = k; i < n; i++) {
        res += v[i];
        res -= v[i - k];
        ans = max(ans, res);
    }
    cout << setprecision(10) << ans;
    return 0;
} 

Measured memory_bytes: 1792
let () =
  Scanf.scanf "%s" @@ fun s ->
  let len = String.length s in 
  let rec loop idx =
    if idx >= len-1 then None
    else if idx+2 <= len && s.[idx] = s.[idx+1] then Some (idx+1, idx+2)
    else if idx+3 <= len && s.[idx] = s.[idx+2] then Some (idx+1, idx+3)
    else loop (idx+1)
  in
  match loop 0 with
  | None -> print_endline "-1 -1"
  | Some (s, t) -> Printf.printf "%d %d\n" s t

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n, m, r;
ll d[201][201];
ll ans = 1e15;
int city[10];
void warshall_floyd()
{
    for (int k = 1; k <= n; k++)
    {
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main()
{
    cin >> n >> m >> r;
    for (int i = 0; i < r; i++)
    {
        cin >> city[i];
    }
    for (int i = 0; i <= n; i++)
    {
        /* code */
        for (int j = 0; j <= n; j++)
        {
            /* code */
            d[i][j] = ans;
        }
    }
    for (int i = 0; i < m; i++)
    {
        int x, y, c;
        cin >> x >> y >> c;
        d[x][y] = c;
        d[y][x] = c;
    }
    warshall_floyd();
    int enu[10];
    for (int i = 0; i < r; i++)
        enu[i] = i;
    do
    {
        ll dist = 0;
        for (int i = 0; i < r - 1; i++)
        {
            dist += d[city[enu[i]]][city[enu[i + 1]]];
        }
        ans = min(ans, dist);
    } while (next_permutation(enu, enu + r));
    cout << ans << endl;
}

Measured memory_bytes: 512
H, W = map(int, input().split())

A = [input() for _ in range(H)]


def f1(x):
    for i in range(W):
        if A[x][i] == '#':
            return False
    return True


def f2(x):
    for i in range(H):
        if A[i][x] == '#':
            return False
    return True


ng_col = [i for i in range(H) if f1(i)]
ng_row = [i for i in range(W) if f2(i)]

for i in range(H):
    if i in ng_col:
        continue
    for j in range(W):
        if j in ng_row:
            continue
        print(A[i][j], end='')
    print()


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

lli n;

int main(void){
    cin >> n;
    vector<lli> a(n), s(n+1);
    unordered_map<lli, lli> mp;
    rep(i, n) cin >> a[i];
    rep(i, n) s[i+1] = s[i]+a[i];
    for(int i = 0; i <= n; i++) mp[s[i]]++;
    lli ans = 0;
    for(auto i : mp){
        ans+=i.second*(i.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14404
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		System.out.println(Math.min(a, b) + Math.min(c, d));
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<cassert>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
string s;
vector<int>a[26];
int b[26];
int c[26];
int d[300000];
int e[300000];
bool f[26];
signed main() {
	cin >> s;
	bool l = 0;
	int res = 0, rep = 1, sum = 0;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (l) {
			rep++;
			l = 0;
		}
		int t = (int)(s[i] - 'a');
		a[t].push_back(i);
		if (!f[t]) {
			sum++;
			f[t] = 1;
		}
		if (sum == 26) {
			res++;
			l = 1;
			for (int i = 0; i < 26; i++) {
				f[i] = 0;
			}
			sum = 0;
		}
		e[i] = rep;
	}
	for (int i = 0; i < 26; i++) {
		a[i].push_back(250000);
		sort(all(a[i]));
	}
	res++;
	rep = res - 1;
	int k = 0;
	string h = "";
	for (int i = 0; i < res; i++) {
		for (int j = 0; j < 26; j++) {
			while (a[j][b[j]] < k) {
				b[j]++;
			}
			if (e[a[j][b[j]]] == rep) {
				h += (char)(j + 'a');
				k = a[j][b[j]] + 1;
				rep--;
				break;
			}
		}
	}
	cout << h << endl;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
int n,k,a[200005],b[200005],bit[530000];
long long pre[200005],ans;
vector<long long> v;
map<long long,int> m;
void upd(int x,int val) {
    while (x!=0) {
        bit[x]+=val; x-=(x&(-x));
    }
}
int que(int x) {
    int ret=0;
    while (x!=2*524288) {
        ret+=bit[x]; x+=(x&(-x));
    }
    return ret;
}
int main() {
    cin>>n>>k;
    for (int i=1; i<=n; i++) {cin>>a[i]; b[i]=a[i]-k;}
    v.push_back(0);
    for (int i=1; i<=n; i++) {pre[i]=pre[i-1]+b[i]; v.push_back(pre[i]);}
    sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
    for (int i=0; i<v.size(); i++) m[v[i]]=i+1;
    for (int i=1; i<=n; i++) upd(m[pre[i]],1);
    for (int i=1; i<=n; i++) {
        ans+=que(m[pre[i-1]]);
        upd(m[pre[i]],-1);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 21332
def solve(s,n)
	que = [0]
	while k = que.pop
		return true if k == n
		que << k+5 if n >= k+5 && (s[k,5] == "dream" || s[k,5] == "erase")
		que << k+7 if n >= k+7 && s[k,7] == "dreamer"
		que << k+6 if n >= k+6 && s[k,6] == "eraser"
	end
	return false
end
s = gets.chomp
puts solve(s,s.length) ? "YES" : "NO"

Measured memory_bytes: 2044
#include <iostream>
#include <stack>

using namespace std;

void solve()
{
	int n;
	stack<int> Stack;
	while(cin >> n)
	{
		if(n != 0)
		{
			Stack.push(n);
		}
		else
		{
			cout << Stack.top() << endl;;
			Stack.pop();
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<stdio.h>
#include<ctype.h>

int main(void)
{
	char moji;
	char az[27];
	int counter[26] = {};
	int i,j,n;

	for(i = 0;i < 26;i++){
		az[i] = 'a' + i;
	}
	while(scanf("%c",&moji) != EOF){
		moji = tolower(moji);
		n = moji - 'a';
		counter[n]++;
	}
	for(j = 0;j < 26;j++){
		printf("%c : %d\n",az[j],counter[j]);
	}
	return 0;
}

Measured memory_bytes: 544
#include<stdio.h>
int main(void)
{
    int a,b;char c='!';
	while(1){
    scanf("%d %c %d",&a,&c,&b);
    if(c=='+'){printf("%d\n",a+b);}
    if(c=='-'){printf("%d\n",a-b);}
    if(c=='*'){printf("%d\n",a*b);}
    if(c=='/'){printf("%d\n",a/b);}
	if(c=='?')break;
	}
return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

    int a, b;
    cin >> a >> b;
    if (a * b == 15)
        cout << "*" << endl;
    else if (a + b == 15)
        cout << "+" << endl;
    else
        cout << "x" << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
X=input()
Y=int(X,2)
Z=Y
C=X.count('1')
if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()
Y,Z=Y%(C+1),Z%(C-1)
def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))
 
for i in range(N):
  if X[i]=='1':
    print(1+f((Z-pow(2,N-i-1,C-1))%(C-1)))
  else:
    print(1+f((Y+pow(2,N-i-1,C+1))%(C+1)))

Measured memory_bytes: 79564
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double pi = Math.PI;
        double area = a * a * pi;
        double length = 2 * a * pi;
        System.out.printf("%f %f", area, length);
        sc.close();
    }
}


Measured memory_bytes: 28204
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

// 二分探索（改）
// judge を満たすような下限を求める
// left:[X] 定義域の下限
// right:[X] 定義域の上限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X left, X right, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (right - left > eps) {
        X mid = (right + left) / 2;
        if (judge(mid) == lower) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return lower ? right : left;
}
int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double S = x / a;
    double ans;
    double threshold = atan2(b, sqrt(a));
    ans = BinSearch<double>(0, M_PI / 2, [&](double theta) -> bool {
        double l;
        double theta_deg = theta * 180 / M_PI;
        double thresh_deg = threshold * 180 / M_PI;
        l = S / a + a * tan(theta) / 2.0;
        if(tan(theta) > l / a) {
            l = sqrt(2.0 * S * tan(theta));
        }
        return l < b;
    }, false, 1e-10);
    cout << std::fixed << std::setprecision(10) << (ans * 180 / M_PI) << endl;
    return 0;
}

Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc171/abc171_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a = i2s()
    print('A' if a.isupper() else 'a')
    return

main()


Measured memory_bytes: 9132
n,p=input().split()
a=list(input().split())
n,p=int(n),int(p)
num0=0
for i in range(0,n):
	a[i]=int(a[i])%2
	if a[i]<1:num0+=1
num1=n-num0
ans,mul=1<<num0,0
def fac(n):
	res=1
	for i in range(1,n+1):res*=i
	return res
def C(n,m):return fac(n)//fac(m)//fac(n-m)
for i in range(p,num1+1,2):mul+=C(num1,i)
print(ans*mul)

Measured memory_bytes: 3316
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

#include <boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define CINT boost_multiprecision::cpp_int

int main(){
    iostream::sync_with_stdio(false);
    
    int H, A, B;
    cin >> H >> A >> B;
    int ans = 0;
    for(int i=A; i<=B; i++){
        if(H % i == 0) ans++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3116
from collections import deque

n,c,k = map(int, input().split())
t = [int(input()) for _ in range(n)]

tk = [(ti, ti+k) for ti in t]
tk.sort(key=lambda x:x[1])
tk = deque(tk)
#print(tk)


ans = 0
# tkが尽きるまで
while tk:
    _, bus = tk[0]
    
    # バスの時刻より早く来ている客をカウント
    cnt = 0
    while (tk[cnt][0] <= bus):
        cnt += 1
        
        if cnt == len(tk):
            break
        
        
    # バスの定員もしくはいる人数を乗せていく
    for _ in range(min(cnt,c)):
        tk.popleft()
    
    ans += 1
        
print(ans)
    

Measured memory_bytes: 59096
INF = 2000000000
"""
メモ : Pythonでは無限大を表す float('inf') があるが, 処理がかなり重たいので
       代わりにsum(v)より真に大きい 2*10^9 を INFとする.
       (https://atcoder.jp/contests/dp/tasks/dp_e において,PyPyを使用して,
        前者だと1060ms, 後者だと570msで2倍近く差が出ている.)
"""
n,W = map(int,input().split())
w = [0]*n
v = [0]*n
for i in range(n):
    w[i], v[i] = map(int, input().split())
sum_v = sum(v)
dp = [[INF for i in range(sum_v + 1)] for j in range(n + 1)]
# dp[i][j]には重さが入る.
# dp[i][j]=(i番目までの品物から価値がちょうどｊになるための重さの最小値)

# ここからメイン
dp[0][0] = 0
for i in range(n):
    for j in range(sum_v + 1):
        if j < v[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])

# n個まで使って,重さがlimit_wを超えないで価値が最大のものを求める.
max_value = 0
for i in range(sum_v + 1):
    if dp[n][i] <= W:
        max_value = i
print(max_value)

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

using namespace std;
#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f3f3f
#define ll  long long
#define db long double
#define eps 1e-3
#define bin(x) cerr << bitset<10>(x) << endl
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 1e9 + 7;
const ll maxn = 1e6 + 10;
const db pi = acos(-1.0);

ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

vector<ll> f(maxn), invf(maxn);

ll inv(ll a) {
    return qpow(a, mod - 2);
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }
}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    prework();
    ll n;
    cin >> n;
    cout << (((qpow(10, n) - qpow(9, n)*2)%mod + qpow(8, n))%mod + mod)%mod << endl;
}

Measured memory_bytes: 18688
package main

import (
	"fmt"
)

func DupToken(x string) []string {
	tokens := []string{}

	i := 0
	for ; i < len(x); {
		j := i+1
		for ; j < len(x); {
			if x[i] != x[j] {
				break
			}
			j ++
		}

		tokens = append(tokens, x[i:j])
		i = j
	}

	return tokens
}

func Max(x ...int) int {
	max := x[0]
	for _, v := range x {
		if v > max {
			max = v
		}
	}
	return max
}

func Range(i, j int) []int {
	ints := make([]int, j - i)
	for x := i; x<j; x++ {
		ints[x-i] = x
	}
	return ints
}

func Reverse(l []int) []int {
	n := len(l)
	x := make([]int, n)
	for i := 0; i<n; i++ {
		x[n-i-1] = l[i]
	}
	return x
}

func main() {
	var s string
	fmt.Scanf("%s", &s)

	tokens := DupToken(s)
	ts := make([][]int, len(tokens))
	for i, token := range tokens {
		if token[0] == '<' {
			ts[i] = Range(0, len(token) + 1)
		} else {
			ts[i] = Reverse(Range(0, len(token) + 1))
		}
	}

	for i := 0; i<len(ts) - 1; i++ {
		if ts[i][len(ts[i])-1] >= ts[i+1][0] {
			ts[i+1] = ts[i+1][1:len(ts[i+1])]
		} else {
			ts[i] = ts[i][0:len(ts[i])-1]
		}
	}

	total := 0
	for i := 0; i<len(ts); i++ {
		for j := 0; j<len(ts[i]); j++ {
			total += ts[i][j]
		}
	}
	fmt.Printf("%d", total)
}


Measured memory_bytes: 23040
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vi xs(n);
    for (int i=0; i<n; i++) {
        cin >> xs[i];
    }
    vi lost(k+1, 1);
    for (int i=1; i<=k; i++) {
        for (int x : xs) {
            if (x <= i && lost[i-x]) {
                lost[i] = 0;
            }
        }
    }
    cout << (lost[k]? "Second\n" : "First\n");
}


Measured memory_bytes: 640
n,k=map(int,input().split())
v=list(map(int, input().split()))

if k<n*2:
    ans=0
    for i in range(k+1):
        for j in range(k-i+1):
            v_r=v[:i]
            v_l=v[(n-j):]
            sute_cnt=k-(i+j)
            v_new=v_r+v_l
            v_new.sort()
            # print(i, j, v_r, v_l, sute_cnt, v_new)
            s=sum(v_new)
            if not v_new:
                continue
            for indx in range(len(v_new)):
                if v_new[indx]<0 and sute_cnt>0:
                    s-=v_new[indx]
                    sute_cnt-=1
                else:
                    break
            ans=max(ans,s)
    print(ans)

else:
    ans=0
    for i in range(n):
        if v[i]>=0:
            ans+=v[i]
    print(ans)


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

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

    int a,b,c,d;
    cin >> a>>b>>c>>d;
    if(a < c){
    if(b-c>0){
        if(b < d){
        cout << b-c << '\n';
        }else{
            cout << d-c << '\n';
        }
    }else{
        cout << "0\n";
    }
    }else{
        if(d-a>0)
        {
            if(b < d){
                cout << b-a<<"\n";
            }else{
                cout << d-a << "\n";
            }
        }else{
            cout << "0\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    print(min(B // A, C))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
for h in range(1, 3500 + 1):
        for n in range(h, 3500 + 1):
                if (4 * h * n - N * n - N * h) <= 0:
                        continue
                if N * h * n % (4 * h * n - N * n - N * h) == 0:
                        w = N * h * n // (4 * h * n - N * n - N * h)
                        print("{} {} {}".format(h, n, w))
                        exit()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef double ld;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=305;
ld f[N][35],ans,tot;
int n,c,a[9];

int main(){
	read(n),read(c);
	REP(i,n)read(a[i]);
	sort(a,a+n);
	do{
		memset(f,0,sizeof f);
		f[n*a[n-1]][0]=1;
		REP(i,n*c)if(i%n){
			int p=i%n-1;
			for(int j=i;j<=n*c;j++)
				for(int s=0;s<(1<<(n-1));s++)
					if(!(s>>p&1))
						f[min(n*c,max(j,i+n*a[p]))][s|(1<<p)]+=f[j][s];
		}
		ans+=f[n*c][(1<<(n-1))-1];
		tot+=1;
	}while(next_permutation(a,a+n-1));
	printf("%.12lf\n",ans/tot/pow(c,n-1));
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  string S; cin >> S;
  for (ll i = 0; i < S.size(); i++) {
    if (S[i] == 'P') cout << 'P';
    else cout <<'D';
  }
  return 0;
}

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

int main() {
  ll n,a,b; cin>>n>>a>>b;
  vector<ll> x(n);
  rep(i, n) cin>>x[i];

  ll ans=0;
  rep(i, n-1) {
    if (a*(x[i+1]-x[i])<b) ans+=a*(x[i+1]-x[i]);
    else ans+=b;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(void)
{
	int n;
	int a[101]={0};
	int i,j;
	int temp;
	int x=0,y=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		
	}
for(i=0;i<n;i++){
	
	for(j=n-1;j>i;j--){
		
		if(a[j]>a[j-1]){
			temp=a[j];
			a[j]=a[j-1];
			a[j-1]=temp;
		}
		
	}
	
}
for(i=0;i<n;i++){
	
	if((i+1)%2==0){
		
		y+=a[i];
		
		
	}else if((i+1)%2!=0){
		
		
		x+=a[i];
		
		
	}
	
	
	
	
	
	
	
	
	
}
printf("%d\n",x-y);

return 0;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int MIN = 0;
	int cnt = 0;
	rep(i,n){
		cnt += (s[i]=='('?1:-1);
		mins(MIN, cnt);
	}
	cout<<string(-MIN,'(')<<s<<string(cnt-MIN,')')<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    for(int i = 0; i < abs(tx - sx); i++){
        cout << 'R';
    }
    for(int i = 0; i < abs(ty - sy); i++){
        cout << 'U';
    }
    for(int i = 0; i < abs(tx - sx); i++){
        cout << 'L';
    }
    for(int i = 0; i < abs(ty - sy); i++){
        cout << 'D';
    }

    cout << 'D';
    for(int i = 0; i < abs(tx - sx) + 1; i++){
        cout << 'R';
    }
    for(int i = 0; i < abs(ty - sy) + 1; i++){
        cout << 'U';
    }
    cout << 'L';

    cout <<'U';
     for(int i = 0; i < abs(tx - sx) + 1; i++){
        cout << 'L';
    }
    for(int i = 0; i < abs(ty - sy) + 1; i++){
        cout << 'D';
    }
    cout << 'R' << endl;


    

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = adjust(sc.nextInt());
        int B = adjust(sc.nextInt());
        if(A==B){
            System.out.println("Draw");
        }else if(A>B){
            System.out.println("Alice");
        }else{
            System.out.println("Bob");
        }
    }
    static int adjust(int N){
        if(N==1)N+=13;
        return N;
    }
}


Measured memory_bytes: 21972
N = int(input())
B = list(map(int, input().split()))
A = list()
sum = 0
for i in range(N-1):
    A.append(B[i])
    if i > 0 and B[i] > B[i-1]:
        A[i] = B[i-1]
    sum += A[i]
sum += B[N-2]
print(sum)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3644