akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)

ll f(ll n) {
    ll ans = 0;
    while (n) {
        ans += n%10;
        n/=10;
    }
    return ans;
}

double g(ll n) {
    return (double)n/f(n);
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<ll> res;
    ll base = 1;
    for (int k = 0; k < 15; k++) {
        for (int l = 1; l < 150; l++) {
            res.push_back(base*(l+1)-1);
        }
        base *= 10;
    }
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());
    
    
    for (ll k = 0; k < res.size(); k++) {
        for (ll l = k+1; l < res.size(); l++) {
            if (g(res[k]) > g(res[l])) {
                res.erase(res.begin() + k--);
                break;
            }
        }
    }
    
    ll num;
    cin >> num;
    for (ll k = 0; k < num; k++)
        cout << res[k] << endl;
  
    return 0;
}





Measured memory_bytes: 384
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var pqan=arr.shift().split(" ").map(Number);
   if(pqan.join(" ")=="0 0 0 0")break;
   var p=pqan[0];
   var q=pqan[1];
   var a=pqan[2];
   var n=pqan[3];
   var ans=0;
   var loop=function(start,P,Q,A,cnt){
      if(cnt>0){
         if(cnt>n)return;
         if(p*Q==P*q){
            ans++;
            return;
         }else if(p*Q<P*q)return;
      }
      for(var i=start;A*i<=a;i++){
         loop(i,1*Q+i*P,Q*i,A*i,cnt+1);
      }
   };
   loop(1,0,1,1,0);
   console.log(ans);
}

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

int main(){
  int n,count=0; cin>>n;
  string s; cin>>s;
  count++; char log=s.at(0);
  for(int i=1;i<n;i++){
    if(s.at(i)==log) continue;
    else{
      count++;
      log=s.at(i);
    }
  }cout<<count<<endl;
}

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

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

  bool flag = false;
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      if (n == i*j) {
        flag = true;
      }
    }
  }

  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

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

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    string S, T;
    cin >> S >> T;

    if (S.size() < T.size()) cout << "UNRESTORABLE" << endl;
    else
    {
        bool is_ok;
        REP(i, S.size()-T.size()+1)
        {
            is_ok=true;
            for(int j=T.size()-1; j>=0; j--)
            {
                if (S[S.size()-T.size()-i+j]=='?') 
                {
                    continue;
                }
                else
                {
                    if (S[S.size()-T.size()-i+j]!=T[j])
                    {
                        is_ok=false;
                        break;
                    }
                }
            }
            if (is_ok)
            {
                REP(n, T.size())
                {
                    S.at(S.size()-T.size()-i+n) = T.at(n);
                }
                for(auto s:S)
                {
                    if (s=='?') cout << 'a';
                    else cout << s;
                }
                cout << endl;
                break;
            }
        }
        if (!is_ok) cout << "UNRESTORABLE" << endl;
    }
  
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,ans=0;
bool ok(int x){
	int t=0;
	while(x){
		t++;
		x/=10;
	}
	if(t&1)return true;
	return false;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		if(ok(i))ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n, m, l;
    cin >> n >> m >> l;
    int dis[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dis[i][j] = i == j ? 0 : l + 1;
        }
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        dis[a][b] = c;
        dis[b][a] = c;
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dis[i][j] = min({dis[i][j], dis[i][k] + dis[k][j], l + 1});
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dis[i][j] = i == j ? 0 : dis[i][j] <= l ? 1 : n;
        }
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dis[i][j] = min({dis[i][j], dis[i][k] + dis[k][j], n});
            }
        }
    }

    int q;
    cin >> q;
    while (q--) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        cout << (dis[s][t] == n ? -1 : dis[s][t] - 1) << "\n";
    }

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;
#define MOD 1000000007

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    long long A, B;
    cin >> N >> A >> B;
    vector<long long> S(N+1);
    S[0] = -(1LL << 60);
    for(int i=1; i<=N; i++) cin >> S[i];
    if(A > B) swap(A, B);
    for(int i=2; i<=N; i++)
        if(S[i] - S[i-2] < A){
            cout << 0 << endl;
            return 0;
        }

    vector<long long> dp1(N+1, 0), dp2(N+1, 0);
    dp1[0] = 1;
    dp2[0] = 1;
    int cur = 0;
    int tail = 0;
    for(int i=1; i<=N; i++){
        for(int j=cur; j<i; j++){
            if(S[i] - S[j] >= B){
                cur = j;
            }else break;
        }

        if(S[i] - S[i-1] < A){
            dp2[i-1] = dp1[i-1];
            int id = min(i-2, cur);
            if(tail <= id) dp1[i] = dp2[id];
            tail = i-1;
        }else if(tail <= cur){
            dp1[i] = dp2[cur];
        }
        dp2[i] = (dp2[i-1] + dp1[i]) % MOD;
    }

    long long ans = 0;
    for(int i=tail; i<=N; i++){
        ans += dp1[i] % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
from itertools import product
D, G = map( int, input().split())
P = []
C = []
SUM = []
for i in range(D):
    p, c = map( int, input().split())
    P.append(p)
    SUM.append(p*100*(i+1) + c)

ans = 1000
for X in product(range(2), repeat = D):
    cnt = 0
    com = 0
    K = []
    for i in range(D):
        if X[i] == 1:
            cnt += P[i]
            com += SUM[i]
        else:
            K.append(i)
    if com >= G:
        ans = min(ans, cnt)
    else:
        for k in K:
            need = min((G-com-1)//(100*(k+1))+1,P[k]-1)
            kcnt = cnt + need
            kcom = com + need*100*(k+1)
            if kcom >= G:
                ans = min(ans,kcnt)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		
		String COO[];
		String CBO[];
		String CSO[];
		String treS = "";
		int CO[];
		int CB[];
		int CS[];
		int treI = 0;
		int minj = 0;
		
		int N = Integer.parseInt(as.next());
		
		COO = new String[N];
		CBO = new String[N];
		CSO = new String[N];
		CO = new int[N];
		CB = new int[N];
		CS = new int[N];
		
		for(int i=0;i<N;i++){
			
			COO[i] = as.next();
			CO[i] = Integer.parseInt(COO[i].substring(COO[i].length()-1));
			
		}
		
		CBO = COO.clone();
		CSO = COO.clone();
		CB = CO.clone();
		CS = CO.clone();
		
		for(int i=0;i<=N-1;i++){
			for(int j=N-1;j>=i+1;j--){
				
				if(CB[j] < CB[j-1]){
					
					treI = CB[j];
					CB[j] = CB[j-1];
					CB[j-1] = treI;
					treS = CBO[j];
					CBO[j] = CBO[j-1];
					CBO[j-1] = treS;
					
				}
				
			}
			
		}
		
		for(int i=0;i<=N-1;i++){
			
			minj = i;
			for(int j=i;j<=N-1;j++){
				
				if(CS[j] < CS[minj]){
					
					minj = j;
					
				}
				
			}
			
			treI = CS[i];
			CS[i] = CS[minj];
			CS[minj] = treI;
			treS = CSO[i];
			CSO[i] = CSO[minj];
			CSO[minj] = treS;
			
		}

		for(int i=0;i<N;i++){
			
			if(i != N-1){
				
				sb.append(CBO[i]).append(' ');
			
			}
			else{
				
				sb.append(CBO[i]);
				
			}
			
		}
		
		System.out.println(sb.toString());
		sb.setLength(0);
		sb.append("Stable");
		System.out.println(sb.toString());
		sb.setLength(0);
		
		for(int i=0;i<N;i++){
			
			if(i != N-1){
				
				sb.append(CSO[i]).append(' ');
			
			}
			else{
				
				sb.append(CSO[i]);
				
			}
			
		}
		
		System.out.println(sb.toString());
		sb.setLength(0);
		for(int i=0;i<N;i++){
			
			if(CBO[i].equals(CSO[i])){
				
				sb.setLength(0);
				sb.append("Stable");
			
			}
			else{
				
				sb.setLength(0);
				sb.append("Not stable");
				break;
				
			}
			
		}
		
		System.out.println(sb.toString());
	}

}

Measured memory_bytes: 26052
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

typedef pair<int,int> Pi;
int main(){
int A, B, C, D ,E ,F;
string S,Sa,Sb,Sc;
long long int V[10000000] = {};
bool ans = false;
cin >> A >> S >> Sa >> Sb;
int sans = 0;
int saans = 0;
int sbans = 0;
for(int i = 0;i < A + 1;i++){
if(S[i] == Sa[i])Sc[i] = S[i];
else if(S[i] == Sb[i])Sc[i] = S[i];
else if(Sa[i] == Sb[i])Sc[i] = Sa[i];
else if(Sa[i] != S[i] && S[i] != Sb[i])Sc[i] = S[i];
}
for(int i = 0;i < A + 1;i++){
if(Sc[i] != S[i])saans++;
if(Sc[i] != Sb[i])saans++;
if(Sc[i] != Sa[i])saans++;
}
cout << saans << endl;
return 0; 
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    string a, b, c;
    cin >> a >> b >> c;
    char turn = 'a';
    while (true) {
        if (turn == 'a') {
            if (a.size() == 0) {
                cout << "A" << endl;
                return 0;
            }
            turn = a[0];
            a.erase(a.begin());
        } else if (turn == 'b') {
            if (b.size() == 0) {
                cout << "B" << endl;
                return 0;
            }
            turn = b[0];
            b.erase(b.begin());
        } else {
            if (c.size() == 0) {
                cout << "C" << endl;
                return 0;
            }
            turn = c[0];
            c.erase(c.begin());
        }
    }

    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, K = ZZ()
    A = sorted(ZZ(), reverse=True)
    F = sorted(ZZ())

    if sum(A) <= K:
        print(0)
        return

    cost = list()
    for a, f in zip(A, F): cost.append(a*f)

    ok = 10 ** 12
    ng = -1

    for _ in range(45):
        mid = (ok+ng)//2
        cc = 0
        for i in range(N): cc += max(0, (cost[i]-mid+F[i]-1)//F[i])
        if cc <= K: ok = mid
        else: ng = mid
    print(ok)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 121036
def main():
    mod = 10**9 + 7
    s = input()
    n = len(s)

    a_num = 0
    c_num = s.count('C')
    q_num = 0
    q_cnt = s.count('?')

    pow3, pow2, pow1, pow0 = 0, 0, 0, 0
    if q_cnt >= 3:
        pow3 = pow(3, q_cnt-3, mod)
        pow2 = pow3 * 3 % mod
        pow1 = pow2 * 3 % mod
        pow0 = pow1 * 3 % mod
    elif q_cnt == 2:
        pow2 = 1
        pow1 = 3
        pow0 = 9
    elif q_cnt == 1:
        pow1 = 1
        pow0 = 3
    else:
        pow0 = 1

    ans = 0
    for x in s:
        if x == 'A':
            a_num += 1
        elif x == 'B':
            ans += pow0 * a_num * c_num
            ans += pow1 * (q_num * c_num + a_num * (q_cnt - q_num))
            ans += pow2 * (q_num) * (q_cnt - q_num)
            ans %= mod
        elif x == 'C':
            c_num -= 1
        else:
            ans += pow1 * a_num * c_num
            ans += pow2 * (q_num * c_num + a_num * (q_cnt - q_num - 1))
            ans += pow3 * (q_num) * (q_cnt - q_num - 1)
            ans %= mod
            q_num += 1

    print(ans)

main()

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
 
int main() {
  int N, R;
  cin >> N >> R;
  cout << (N <= 10 ? R + 100 * (10 - N) : R) << endl;
}

Measured memory_bytes: 3604
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		long X = sc.nextLong();
		long Y = sc.nextLong();

		for (int i = 0; i <= 60; i++) {
			if (Y < X * (long)Math.pow(2, i)) {
				System.out.println(i);
				break;
			}
		}
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23124
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld ans = 1ll;
	lld n; cin >> n;

	while (ans * 2 <= n) {
		ans *= 2;
	}

	cout << ans;
	return;
}


signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3632
n,k = map(int,input().split())
ans = 0
def rep(a,b):
    m = 0
    while a<b:
        a = a * 2
        m += 1
    return m

for i in range(1,n+1):
    if i<k:
        m = rep(i,k)
        ans += 1/(2**m)
    else:
        ans += 1
print(ans/n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N,A,B,C;
    int ans=0,count=0;
    cin>>N;
    ll S[N],D[N];
    rep(i,N){
        cin>>S[i];
    }
    rep1(i,N-1){
        if(S[i]<=S[i-1]){
            count++;
        }else{
            ans=max(ans,count);
            count=0;
        }
    }
    ans=max(ans,count);
    Out(ans);
    return 0;
}

Measured memory_bytes: 1024
def main():
    from itertools import accumulate

    def Eratosthenes(x: int) -> set:
        from math import sqrt
        sup = int(x)
        primes = {i for i in range(2, sup+1)}
        for i in range(2, int(sqrt(sup+1))+1):
            if i in primes:
                mul = 2
                while i*mul <= sup:
                    primes.discard(i*mul)
                    mul += 1
        return primes
    P = Eratosthenes(10**5+5)
    A = [0]*(10**5+5)
    for i in range(3, 10**5+5):
        if i in P and (i+1)//2 in P:
            A[i] += 1
    S = list(accumulate(A))

    Q = int(input())
    LR = [[int(i) for i in input().split()] for j in range(Q)]
    for le, ri in LR:
        print(S[ri] - S[le-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 72676
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

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


int main(void) {
	int maxi = -1;
	int mini = INF + 1;

	int n;
	int a;
	cin >> n;

	FOR(i, 1, n) {
		cin >> a;
		if (a > maxi) {
			maxi = a;
		}
		if (a < mini) {
			mini = a;
		}
	}

	cout << maxi - mini << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

template <class T>
inline void read(T &x)
{
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int a, b, c;

int main()
{
    std::cin >> a >> b >> c;
    if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b)) std::cout << "Yes" << std::endl;
    else    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll m=1e9;

int main(){
  ll n;
  cin >> n;
  cout << 0 << ' ' << 0 << ' ' << (n-1)/m+1 << ' ' << 1 << ' ' << ((n-1)/m+1)*m-n << ' ' << m <<endl; 
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

int main() {

    int a, b;
    cin >> a >> b;

    int x = a + b;
    int y = a - b;
    int z = a * b;

    cout << max(x, max(y, z)) << endl;
}

Measured memory_bytes: 256
### main

while line = gets
  str = ''
  for ch in line.split('')
    if ("A".."Z").include?(ch) || ("a".."z").include?(ch)
      str += ch.upcase
    end
  end
  #p str

  slen = str.length
  pldrms = {}
  ngs = {}
  
  for i in (0...slen)
    d = 1
    while i - d >= 0 && i + d < slen && str[i - d] == str[i + d]
      d += 1
    end
    d -= 1
    if d > 0
      pldrm = str[i]
      for d0 in (1...d)
        pldrm = str[i - d0] + pldrm + str[i + d0]
        ngs[pldrm] = true
      end
      pldrm = str[i - d] + pldrm + str[i + d]
      pldrms[pldrm] = true
    end

    if i + 1 < slen && str[i] == str[i + 1]
      d = 1
      while i - d >= 0 && i + d < slen && str[i - d] == str[i + 1 + d]
        d += 1
      end
      d -= 1
      if d > 0
        pldrm = str[i, 2]
        for d0 in (1...d)
          pldrm = str[i - d0] + pldrm + str[i + 1 + d0]
          ngs[pldrm] = true
        end
        pldrm = str[i - d] + pldrm + str[i + 1 + d]
        pldrms[pldrm] = true
      end
    end
  end

  puts pldrms.keys.select{|pl| ! ngs[pl]}.join(' ')
end

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

typedef struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
}Node;

Node* insert(Node*, int);
Node* find(Node*, int);
Node* delete(Node*, int);
void print(Node *);
void inorderTreeWalk(Node *);
void preorderTreeWalk(Node *);

main(){
  int m, key, i;
  char string[10];
  Node *T, *node;

  T = NULL;

  scanf("%d", &m);
  for(i=0; i<m; i++){
    scanf("%s", string);
    if(strcmp(string, "insert")==0){
      scanf("%d", &key);
      T = insert(T, key);
    }
    else if(strcmp(string, "find")==0){
      scanf("%d", &key);
      if(find(T, key) == NULL) printf("no\n");
      else printf("yes\n");
    }
    else if(strcmp(string, "delete")==0){
      scanf("%d", &key);
      T = delete(T, key);
    }
    else print(T);
  }

  return 0;
}

Node* insert(Node *T, int key){
  Node *x, *y, *z;
  
  //creatNode
  z = malloc(sizeof(Node));
  z->key = key;
  z->left = NULL;
  z->right = NULL;

  y = NULL;  //x??????
  x = T;
  
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  
  if(y==NULL) T = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
  return T;
}

Node* find(Node *T, int key){
  while(T != NULL && T->key != key){
    if(key < T->key) T = T->left;
    else T = T->right;
  }
  return T;
}

Node* delete(Node *T, int key){
  Node *delNode, *x;
  Node *findNode = find(T, key);
  if(findNode == NULL) return T;  //????????????
  
  if(findNode->left == NULL || findNode->right == NULL) delNode = findNode; //??????1,0
  else {  //??????2
    delNode = findNode->right;
    while(delNode->left != NULL) delNode = delNode->left;
  }
  
  if(delNode->left != NULL) x = delNode->left;
  else x = delNode->right;

  if(x != NULL) x->parent = delNode->parent;
  if(delNode->parent == NULL) T = x;
  else if(delNode == delNode->parent->left) delNode->parent->left = x;
  else delNode->parent->right = x;

  if (delNode != findNode){
    findNode->key = delNode->key;
  }

  free(delNode);
  return T;
}

void print(Node *T){
  inorderTreeWalk(T);
  printf("\n");

  preorderTreeWalk(T);
  printf("\n");
}

void inorderTreeWalk(Node *T){
  if(T == NULL) return;

  inorderTreeWalk(T->left);
  printf(" %d", T->key);
  inorderTreeWalk(T->right);
}

void preorderTreeWalk(Node *T){
  if(T == NULL) return;
  printf(" %d", T->key);
  preorderTreeWalk(T->left);
  preorderTreeWalk(T->right);
}

Measured memory_bytes: 19360
n,k = (int(i) for i in input().split())
r,s,p = (int(i) for i in input().split())
t = input()
ans = 0
x = []
for i in range(n):
  if i<k:
    if t[i] == "r":
      x.append("p")
      ans += p
    elif t[i] == "s":
      x.append("r")
      ans += r
    elif t[i] == "p":
      x.append("s")
      ans += s
  else:
    if t[i] == "r":
      if x[i-k] != "p":
        x.append("p")
        ans += p
      else:
        x.append(-1)
    elif t[i] == "s":
      if x[i-k] != "r":
        x.append("r")
        ans += r
      else:
        x.append(-1)
    elif t[i] == "p":
      if x[i-k] != "s":
        x.append("s")
        ans += s
      else:
        x.append(-1)
print(ans)

Measured memory_bytes: 4212
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int X,Y,S;
int tax(int rate,int price){
  int pprice=0;
  pprice=floor(price*(100+rate)/100);
  return pprice;
}
int solve(){
    int maximum=0;
    for(int i=1;i<S;++i){
        for(int j=i;j<S;++j){
          if((tax(X,i)+tax(X,j))==S){
              maximum=max(maximum,tax(Y,i)+tax(Y,j));
          }
        }
    }
    return maximum;
}
int main(){
  while(cin>>X>>Y>>S&&X>0){
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 3092
from collections import OrderedDict
import sys

cnt = OrderedDict()
for i in range(ord('a'), ord('z') + 1):
    cnt[chr(i)] = 0

S = sys.stdin.readlines()
for s in S:
    s = s.lower()
    for i in s:
        if i in cnt:
            cnt[i] += 1

for k, v in cnt.items():
    print('{} : {}'.format(k, v))

Measured memory_bytes: 7672
#include <bits/stdc++.h>
    #define file "gemo"
    using namespace std;
    typedef long long ll;
    const int mod=1000000007;
    int read(){
    	char c=getchar();
    	int x=0;
    	while(c<'0' || c>'9')
    		c=getchar();
    	while(c>='0' && c<='9'){
    		x=x*10+c-'0';
    		c=getchar();
    	}
    	return x;
    }
    int a[15][15];
    ll dp[1<<15],pw[2333];
    int to[16][1<<15],qwq[1<<15];
    int main(){
    	//freopen(file".in","r",stdin);
    	//freopen(file".out","w",stdout);
    	int n=read(),m=read();
    	pw[0]=1;
    	for(int i=1;i<=m;i++)
    		pw[i]=pw[i-1]*2%mod;
    	for(int i=1;i<=m;i++){
    		int u=read()-1,v=read()-1;
    		a[u][v]=1;
    	}
    	for(int i=0;i<n;i++)
    		for(int j=0;j<(1<<n);j++){
    			if (j>>i&1)
    				continue;
    			for(int k=0;k<n;k++)
    				if (j>>k&1)
    					to[i][j]+=a[i][k];
    			//fprintf(stderr,"to[%d][%d]=%d\n",i,j,to[i][j]);
    		}
    	for(int i=0;i<(1<<n);i++)
    		for(int j=0;j<n;j++)
    			if (!(i>>j&1))
    				qwq[i]+=to[j][i];
    	dp[0]=1;
    	for(int i=0;i<(1<<n);i++){
    		int s=(1<<n)-1-i;
    		if ((i&1)!=(i>>1&1))
    			continue;
    		//fprintf(stderr,"i=%d\n",i);
    		if (!dp[i])
    			continue;
    		for(int j=s;j;j=(j-1)&s){ //i->j ~to->j
    			if ((j&1)!=(j>>1&1))
    				continue;
    			ll ans=1;
    			int sm=0;
    			int v=i|j;
    			for(int o=0;o<n;o++)
    				if (!(v>>o&1))
    					ans=ans*((1<<to[o][j])-1)%mod,sm+=to[o][j];
    			ans=ans*pw[qwq[j]-sm]%mod;
    			if (!ans)
    				continue;
    			dp[v]=(dp[v]+dp[i]*ans)%mod;
    		}
    	}
    	ll ans=dp[(1<<n)-1];
    	printf("%lld",((pw[m]-ans)%mod+mod)%mod);
    	//fprintf(stderr,"%.5f",(double)clock()/CLOCKS_PER_SEC);
    }

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

typedef long long ll;

ll H,W;

int main(){
    ll ans = 1e10;
    cin >> H >> W;
    for(int i=1;i<=H-1;i++){
        ll S1 = i * W;
        ll S2 = (H-i)/2 * W;
        ll S3 = (H-i - (H-i)/2) * W;
        ll M = max(S3,max(S1,S2));
        ll N = min(S3,min(S1,S2));
        ans = min(ans,M-N);
        S2 = W/2 * (H-i);
        S3 = (W - W/2) * (H-i);
        M = max(S3,max(S1,S2));
        N = min(S3,min(S1,S2));
        ans = min(ans,M-N);
    }
    ll a = H;
    H = W;
    W = a;
    for(int i=1;i<=H-1;i++){
        ll S1 = i * W;
        ll S2 = (H-i)/2 * W;
        ll S3 = (H-i - (H-i)/2) * W;
        ll M = max(S3,max(S1,S2));
        ll N = min(S3,min(S1,S2));
        ans = min(ans,M-N);
        S2 = W/2 * (H-i);
        S3 = (W - W/2) * (H-i);
        M = max(S3,max(S1,S2));
        N = min(S3,min(S1,S2));
        ans = min(ans,M-N);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N, A, B, C;
vector<int> l;
const int INF = 1000000000;
int dfs(int cur, int a, int b, int c){
    if (cur == N){
        if (min({a, b, c}) > 0)
            return abs(A-a) + abs(B-b) + abs(C-c) - 30;
        else
            return INF;
    }
    int ret0 = dfs(cur+1, a, b, c);
    int ret1 = dfs(cur+1, a+l[cur], b, c) + 10;
    int ret2 = dfs(cur+1, a, b+l[cur], c) + 10;
    int ret3 = dfs(cur+1, a, b, c+l[cur]) + 10;
    return min({ret0, ret1, ret2, ret3});
}
int main(){
    cin >> N >> A >> B >> C;
    l.resize(N);
    for (auto& e : l) cin >> e;
    cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
cnt = 1
for i in itertools.permutations(range(1, n + 1), n):
    if list(i) == p:
        a = cnt
    if list(i) == q:
        b = cnt
    cnt += 1
print(abs(a - b))

Measured memory_bytes: 3064
N = int(input())
A = [int(i) for i in input().split()]; A.sort()

B = []; b = 0
for i in A:
    b += i
    B.append(b)

c = 1; w = True
while w:
    if 2*B[N-1-c] >= A[N-c]:
        c += 1
        if c == N: break
    else:
        w = False

print(c)


Measured memory_bytes: 20204
n = int(input())
block = [list(map(int, input().split())) for _ in range(n)]

block.sort(key=lambda x: x[0] + x[1])

dp = [[-float('inf')] * (2*10**4+1) for _ in range(n+1)]

dp[0][0] = 0

for i in range(n):
    for w in range(2 * 10**4 + 1):
        if w <= block[i][1]:
            dp[i+1][w+block[i][0]] = max(dp[i+1][w+block[i][0]], dp[i][w] + block[i][2])
        dp[i+1][w] = max(dp[i+1][w], dp[i][w])

ans = 0
for w in range(2 * 10**4 + 1):
    ans = max(ans, dp[n][w])

print(ans)

Measured memory_bytes: 572040
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int m = in.nextInt();

		double[][] p = new double[n][3];
		for (int i=0; i<n; i++) {
			for (int j=0; j<3; j++) {
				p[i][j] = in.nextDouble();
			}
		}

		double max = 0;

		for (int k=0; k<1<<n; k++) {
			if (Integer.bitCount(k) != m) continue;
			double sum = 0;
			for (int i=0; i<n; i++) {
				if ((k>>i&1) != 1) continue;
				for (int j=i+1; j<n; j++) {
					if ((k>>j&1) != 1) continue;
					for (int c=0; c<3; c++)
						sum += (p[i][c] - p[j][c])*(p[i][c] - p[j][c]);
				}
			}
			max = Math.max(max, sum);
		}

		out.printf("%.6f\n",max);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> vta(n);
    for (int i = 0; i < n; ++i) {
        cin >> vta[i];

    }

    int m;
    cin >> m;
    vector<int> vtb(m);
    for (int i = 0; i < m; ++i) {
        cin >> vtb[i];
    }

    vector<int> res;
    set_symmetric_difference(vta.begin(), vta.end(), vtb.begin(), vtb.end(),
                             inserter(res, res.end()));

    for (auto x:res) cout << x << endl;
    return 0;
}


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

ds = ((0, 1), (1, 0), (0, -1), (-1, 0))

def move(p, d):
	n = (p[0] + d[0], p[1] + d[1])
	if (0 <= n[0] < H) and (0 <= n[1] < W):
		return n
	return None

def getv(p):
	return STAGE[p[0]][p[1]]

for y in range(H):
	for x in range(W):
		if "#" == STAGE[y][x]:
			for d in ds:
				n = move((y, x), d)
				if n and "#" == getv(n):
					break
			else:
				print("No")
				exit()
print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  long long a[5];
  cin >> N;
  for(int i=0; i<5; i++){
    cin >> a[i];
  }
  sort(a,a+5);
  long long b = N / a[0];
  long long c = N % a[0];
  if(c == 0){
    cout << 5 + b - 1 << endl;
  }else{
    cout << 5 + b << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
double a;
int main()
{
	cin>>a;
	printf("%.12lf\n",(a/3)*(a/3)*(a/3));
	return 0;}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

struct Tree	//create tree(directed) from graph(undirected)
{
    int n;
    int root;
    vector<vector<int>> t;
    vector<int> par;
    vector<int> dpt;
    
    void init(Graph &g, int root_){
        n = g.n;
        root = root_;
        t.resize(n);
        par.resize(n);
        dpt.resize(n);
        fill(dpt.begin(), dpt.end(), -1);
        queue<int> que;
        par[root] = -1;
        dpt[root] = 0;
        que.push(root);
        while(que.size()){
            int pa = que.front();
            que.pop();
            for(int ch : g.g[pa]){
                if(dpt[ch] == -1){
                    t[pa].push_back(ch);
                    par[ch] = pa;
                    dpt[ch] = dpt[pa] + 1;
                    que.push(ch);
                }
            }
        }
    }

    Tree(){}
    
    Tree(Graph &g, int root_){
        init(g, root_);
    }
};

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        g.add_edge(b, a);
    }
    if(n == 2){
        cout << "Second" << endl;
        return 0;
    }
    Tree t(g, 0);
    P p[100002];
    for(int i = 0; i < n; i++) p[i] = P(t.dpt[i], i);
    sort(p, p + n, greater<P>());
    bool del[100002]{0};
    for(int i = 0; i < n; i++){
        int u = p[i].second;
        int k = 0;
        for(int v : t.t[u]){
            if(!del[v]) k++;
            del[v] = true;
        }
        if(k >= 2){
            cout << "First" << endl;
            return 0;
        }
        if(k == 1){
            del[u] = true;
        }
        if(k == 0 && u == 0){
            cout << "First" << endl;
            return 0;
        }
    }
    cout << "Second" << endl;
}

Measured memory_bytes: 11904
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

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

int n,m,h[101],hnum[101],dh[101];///h记录每一列高度 dh记录离散化后的各不相同的高度 hnum记录h对应dh中的位置，即第几高的高度
long long dp[101][101];///记录第i列第n块高度往上的方案数

int pow_(long long x,int y) {///快速幂求 x的y次方
    long long ans = 1;
    if(y > 0) {
        while(y) {
            if(y % 2)ans = ans * x % MOD;
            x = x * x % MOD;
            y /= 2;
        }
    }
    return ans;
}

int main() {
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++) {
        scanf("%d",&h[i]);
        dh[++ m] = h[i];///先把高度存到dh数组 下标从1开始，方便后面dp
    }
    sort(dh + 1,dh + m + 1);///dh数组排序
    m = unique(dh + 1,dh + m + 1) - dh - 1;///dh数组离散化去掉重复的高度 m是不相同的高度数
    for(int i = 1;i <= n;i ++) {
        hnum[i] = lower_bound(dh + 1,dh + m + 1,h[i]) - dh;///每一列高度在dh数组中对应的位置
    }
    dp[0][0]=1;///初始化 当第0列有1个无连续相同的方案
    for(int i = 1;i <= n;i ++) {///对每一列每个高度段进行更新 更新过程为从下往上
        (dp[i][0] += dp[i - 1][0] * 2 % MOD) %= MOD;///无连续相同方案  加上前i - 1列无连续相同方案数*2 因为可以是与前一列对应位置同色或者异色一共两种方案
        for(int j = hnum[i] + 1;j <= hnum[i - 1];j ++)///如果前一列比这一列高，高出的部分也存着接触部分无连续相同的方案 但是可能会重复加上上一步的方案数所以下面更新高出的部分时会避免
            (dp[i][0] += dp[i - 1][j] * 2 % MOD) %= MOD;
        int d = pow_(2,h[i] - h[i - 1]);///比前一列高出部分的涂色方案数，如果比前一列低 d就等于1
        for(int j = 1;j <= min(hnum[i - 1],hnum[i]);j ++) {
            dp[i][j] = dp[i - 1][j] * d % MOD;///有连续相同颜色的方案数 已经分析过接触部分的颜色一定是定下的 所以这一列接触部分有连续相同部分的方案数由高出部分的变化决定 即 乘上d
        }
        for(int j = hnum[i - 1] + 1;j <= hnum[i];j ++) {///更新比前一列高出的部分 j从上一列的高度加1的下标开始
            if(j > 1)(dp[i][j] = dp[i - 1][0] * (pow_(2,dh[j] - dh[j - 1]) - 1) % MOD * 2 % MOD * pow_(2,h[i] - dh[j]) % MOD) %= MOD;
            ///一般情况 前i - 1列无连续方案 * （第j块高度变化方案 -1表示去掉无连续相同方案) * 2 * 剩下几块高度的变化方案数
            else (dp[1][1] = dp[0][0] * (pow_(2,dh[1]) - 2) % MOD * pow_(2,h[i] - dh[1]) % MOD) %= MOD;
            ///第一列的第一块高度 记录随意变化方案数 -2表示除去dp[i][0]已经记录过的无连续相同方案 勿重复记录
        }
    }
    long long ans = 0;
    for(int i = 0;i <= hnum[n];i++)
        (ans += dp[n][i]) %= MOD;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,p[101];
	scan(N);
	rep(i,N){
		scan(p[i]);
	}
	int ans=0;
	rep1(i,N-2){
		vint P; P.push_back(p[i-1]); P.push_back(p[i]); P.push_back(p[i+1]); sort(P.begin(),P.end());
		if(P[1]==p[i]) ans++;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1 == p2)?EOF:*p1++)
using namespace std ;
//char buf[(1 << 22)] , *p1 = buf , *p2 = buf ;
inline int read ()
{
    char c = getchar () ; int x = 0 , f = 1 ;
    while (c < '0' || c > '9') { if (c == '-') f = -1 ; c = getchar () ; }
    while (c >= '0' && c <= '9'){ x = x * 10 + c - '0' ; c = getchar () ; }
    return x * f ;
}
string s ;
int st[200005] , ans , top ;
int main ()
{
//	freopen (".in" , "r" , stdin) ; freopen (".out" , "w" , stdout) ;
	cin >> s ;
	ans = s.size () ;
	for (int i = 0 ; i < s.size () ; i ++)
	{
		if (s[i] == 'S') st[++ top] = 'S' ;
		else if (top) top -- , ans -= 2 ;
	}
	cout << ans ;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll x = a * c;
    ll y = a * d;
    ll z = b * c;
    ll u = b * d;
    ll ans = max(max(max(x, y), z),u);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){

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

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

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

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(b - a <= 0)	printf("delicious\n");
	else if(b - a <= x)	printf("safe\n");
	else printf("dangerous\n");
	return 0;
}


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

using namespace std;
const int N = 300000;

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

bool check(int x)
{
	for (int i=1;i<=n;++i)
		b[i] = a[i]>=x;
	int l = n/2, r = n/2+2;
	for ( ;l >= 1 && r <= n; l --, r ++) {
		if (b[l] ^ b[l+1] && b[r] ^ b[r-1]) continue;
		if (b[l] == b[l+1]) return b[l];
		if (b[r] == b[r-1]) return b[r];
	}
	return b[1];
}

int main(void)
{
	scanf("%d", &n); 
	n = n*2-1;
	for (int i=1;i<=n;++i)
		scanf("%d", a+i);
	int l = 1, r = n, mid;
	while (l+1 < r) {
		mid = l+r >> 1;
		check(mid) ? l = mid : r = mid;
	}
	cout<<(check(r) ? r : l)<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;
 	
#define R register
#define LL long long
#define Maxn 505

int n,m;
LL a[Maxn][Maxn];
int cnt;
LL ans[Maxn*Maxn][7];

int main()
{
	scanf("%d %d",&n,&m);
	for (R int i=1;i<=n;++i)
	 for (R int j=1;j<=m;++j)
	  scanf("%lld",&a[i][j]);
	
	for (R int i=1;i<=n;++i)
	 for (R int j=1;j<=m;++j)
	  {
	  	  if(i==n && j==m) continue;
	  	  if(a[i][j] & 1)
	  	  {
	  	  	    ++cnt;
		  	    if(j!=m)
	  	  	    {
	  	        //	 printf("%d %d %d %d\n",i,j,i,j+1);	
		  	 		ans[cnt][1]=i,ans[cnt][2]=j,ans[cnt][3]=i,ans[cnt][4]=j+1;
					a[i][j+1] ++;	
			    }
		  	    else
		  	    {
		  	        ans[cnt][1]=i,ans[cnt][2]=j,ans[cnt][3]=i+1,ans[cnt][4]=j;	
		  	 	    a[i+1][j] ++;
			    }
		  }
	  }
	
	printf("%d\n",cnt);
	for (R int i=1;i<=cnt;++i) printf("%lld %lld %lld %lld\n",ans[i][1],ans[i][2],ans[i][3],ans[i][4]);
    return 0;
}

Measured memory_bytes: 13824
n = int(input())
ans_list = []

for i in range(1,n+1):
    x = i
    if   x%3  == 0:
        ans_list.append(' {}'.format(i))
    else:
        while x != 0:
            if x%10 == 3:
                ans_list.append(' {}'.format(i))
                break
            else:
                x //= 10

print(''.join(ans_list))


Measured memory_bytes: 5928
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
using LL = long long;
int n,m;
LL down[M], ans[M];
vector<int> e[M];
void dfs1(int cur,int fa) {
    down[cur] = 1;
    for (int i: e[cur]) if (i!=fa) {
        dfs1(i, cur);
        down[cur] = down[cur] * (down[i]+1) % m;
    }
}
void dfs2(int cur,int fa,LL up) {
    ans[cur] = down[cur] * (up+1) % m;
    
    int sz = (int)e[cur].size();
    vector<LL> fr, bk;
    fr = vector<LL> (sz);
    bk = vector<LL> (sz);
    REP(i,0,sz-1)               fr[i] = (i>0 ? fr[i-1] : 1LL)    * (e[cur][i]==fa ? (up+1) : (down[e[cur][i]]+1)) % m;
    for (int i=sz-1; i>=0; i--) bk[i] = (i<sz-1 ? bk[i+1] : 1LL) * (e[cur][i]==fa ? (up+1) : (down[e[cur][i]]+1)) % m;
    
    REP(i,0,sz-1) if (e[cur][i]!=fa) {
        LL nup = 1LL;
        if (i>0) nup = nup * fr[i-1] % m;
        if (i<sz-1) nup = nup * bk[i+1] % m;
        dfs2(e[cur][i], cur, nup);
    }
}
int main()
{
    scanf("%d %d", &n, &m);
    REP(i,1,n-1) {
        int x, y;
        scanf("%d %d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }

    dfs1(1, -1);
    dfs2(1, -1, 0);
    REP(i,1,n) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 21980