akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string s;

void solve(){
    cin >> s;
    rep(i,s.length()){
        if(s[i]=='P') cout << "P" ;
        else cout << "D"; 
    }
    cout << "" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    CIN2(a,b)
    int ans = (a<=5)?0:(a<=12)?b/2:b;
    cout << ans << endl;
}

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

bool checknum(int n) {
  if (n % 3 == 0) {
    return 1;
  } else {
    return 0;
  }
}

bool include3(int n) {
  if (n % 10 == 3) {
    return 1;
  }

  int m = n / 10;
  if (m) {
    include3(m);
  } else {
    return 0;
  }
}

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

  for (int i = 1; i <= n; i++) {
    if (checknum(i) || include3(i)) {
      cout << " " << i;
    }
  }

  cout << endl;

  return 0;
}



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

#define ll long long

const ll mod = 1e9 + 7;

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

    int n;
    cin >> n;

    int let[26] = {};
    int unique = 0;

    while(n-- > 0)
    {
        char c;
        cin >> c;

        int pos = c - 'a';

        if (++let[pos] == 1)
            ++unique;
    }

    ll ans = 1;

    for(int i = 0; i < 26; ++i)
        if (let[i] > 0)
        {
            ans *= (let[i] + 1);
            ans %= mod;
        }

    cout << ans - 1;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (){
	int A1,A2,A3,total;
	scanf ("%d %d %d",&A1,&A2,&A3);
	total = A1 + A2 + A3;
	if (total>= 22 ){
		printf ("bust\n");
    }
	else {
		printf ("win\n");
	}
	return 0;	
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN
 main() {
ll n,y;
cin >> n >> y;
bool ans = false;

  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
        ll che = i*10000+j*5000;
        if(y>=che&&y-che==(n-i-j)*1000&&!ans){
          cout << i <<" "<< j <<" "<<n-i-j<<endl;
          ans = true;
        }
    }
  }
  if(!ans){
    cout << -1 << " "<<-1<<" "<<-1<<endl;
  }
 }
 


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

using namespace std;

template <class T>
using lim = numeric_limits<T>;

typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int cost[10][10];
	
	int h, w; cin >> h >> w;
	
	// grabbing cost matrix
	for (int i = 0; i < 10; i++){
		for (int j = 0; j < 10; j++){
			cin >> cost[i][j];
		}
	}
	
	// minimizing cost matrix
	for (int x = 0; x < 10; x++){
		for (int i = 0; i < 10; i++){
			for (int j = 0; j < 10; j++){
				cost[i][j] = min(cost[i][j], cost[i][x]+cost[x][j]);
			}
		}
	}
	
	int total = 0;
	// grabbing wall
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			int digit; cin >> digit;
			if (digit != -1){
				total += cost[digit][1];
			}
		}
	}
	
	cout << total << endl;
}


Measured memory_bytes: 256
x, y = map(int,input().split())
S1 = [1, 3, 5, 7, 8, 10, 12]
S2 = [4, 6, 9, 11]
ans = False
for i in range(len(S1)):
  for j in range(len(S1)):
    if S1[i] == x and S1[j] == y:
      ans = True
for i in range(len(S2)):
  for j in range(len(S2)):
    if S2[i] == x and S2[j] == y:
      ans = True
if ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 8816
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define sc(x) scanf("%lld",&x);
#define int long long
#define fi first
#define se second
#define endl '\n'
#define P pair<int,int>
#define fi first
#define se second



int A[200004];
int B[200005];
map<int,int> mp;
signed main()
{
    int n;sc(n)
    for(int i=1;i<=n;i++){sc(A[i])B[i]=A[i]-i;mp[B[i]]++;}
    int a = 0;

    for(int i=1;i<=n;i++){
        a += mp[-(A[i]+i)];

    }
    cout<<a;
    return 0;
}


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

int main(){
  string S; cin>>S;
  int ans=0;
  int l=S.length();
  if(l%2==1)l+=1;
  for(int i=0; i<l/2; i++){
    if(S[i]!=S[S.length()-i-1])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(void){
	int a,b,c,d;
	while(scanf("%1d%1d%1d%1d",&a,&b,&c,&d)!=EOF,!(a==0&&b==0&&c==0&&d==0)){
		if(a==b&&b==c&&c==d&&d==a){
			cout<<"NA"<<endl;
		}else{
			int count=0;
			while(!(a==6&&b==1&&c==7&&d==4)){
				vector<int> nums,numl;
				nums.push_back(a);
				nums.push_back(b);
				nums.push_back(c);
				nums.push_back(d);
				numl = nums;
				sort(nums.begin(),nums.end());
				sort(numl.begin(),numl.end(),greater<int>());
				int s = nums[0]*1000+nums[1]*100+nums[2]*10+nums[3];
				int l = numl[0]*1000+numl[1]*100+numl[2]*10+numl[3];
				int N = l-s;
				a=N/1000;
				b=(N%1000)/100;
				c=(N%100)/10;
				d=N%10;
				++count;
			}
			cout<<count<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2);
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------
// decayed bridge

class UnionFind{

public:
  vector<int> parents;

  UnionFind(int n){
    parents.assign(n, -1);
  }
  ~UnionFind(){}

  int find(int x){
    if(parents[x]<0){
      return x;
    } else {
      return find(parents[x]);
    }
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x==y){return;}

    if(parents[x]>parents[y]){
      int tmp = x;
      x = y;
      y = tmp;
    }

    parents[x] += parents[y];
    parents[y] = x;
  }

  int size(int x){
    return -parents[find(x)];
  }

  int count_roots(){
    int ct=0;
    for(int i=0; i<parents.size(); i++){
      if(parents[i]<0){ct++;}
    }
    return ct;
  }

  bool is_same(int x, int y){
    return find(x) == find(y);
  }
};

int main(void) {
  int n, m;
  cin >> n >> m;

  UnionFind uf(n);

  int a[m], b[m];
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }

  vecll ans;
  ll cnt = ll(n)*ll(n-1)/2;
  rep(i,m){
    ans.push_back(cnt);
    if(uf.is_same(a[m-i-1], b[m-i-1])){
      //uf.unite(a[m-1-i], b[m-i-1]);
      continue;
    } else {
      ll n_1 = uf.size(a[m-i-1]);
      ll n_2 = uf.size(b[m-i-1]);
      cnt -= n_1*n_2;
      uf.unite(a[m-1-i], b[m-i-1]);
    }
  }

  rep(i,m){
    prt(ans[m-i-1]);
  }

}


Measured memory_bytes: 3444
s = raw_input().split()
maxLength = 0
word1 = ""
word2 = ""
count = {}
maxCount = 0
for i in range(len(s)):
    count[s[i]] = 0
for i in range(len(s)):
    count[s[i]] += 1
    if(len(s[i]) > maxLength):
        maxLength = len(s[i])
        word2 = s[i]
for i in range(len(s)):
    if(count[s[i]] > maxCount):
        maxCount = count[s[i]]
        word1 = s[i]
print(word1),
print(word2)

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
     
int main(){
    #ifdef LOCAL
    	freopen("in.txt","r",stdin);
    	freopen("out.txt","w",stdout);
    #endif
     
   	
   	int n;
   	string str;
   	cin >> n >> str;
   	map<int,bool> blue;
   	vector<int> v[4];
   	for(int i = 0;i < str.size();i++){
   		if(str[i] == 'R') v[1].push_back(i);
   		if(str[i] == 'G') v[2].push_back(i);
   		if(str[i] == 'B') {
   			v[3].push_back(i);
   			blue[i] = true;
   		}
   	}

   	long long sum = 0;
   	for(int i = 0;i < v[1].size();i++){
   		for(int j = 0;j < v[2].size();j++){
   			
   			sum += v[3].size();

   			if( (v[1][i] + v[2][j]) % 2 == 0 and blue[ ( v[1][i] + v[2][j] )  / 2] ) sum--;

   			if( blue[ abs(v[1][i] - v[2][j]) + max(v[2][j],v[1][i]) ]) sum--;

   			if( blue[ min(v[2][j],v[1][i]) - abs(v[1][i] - v[2][j])]) sum--; 

   		}
   	}
   	cout << sum;
 }

Measured memory_bytes: 4200
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

template <int mod>
struct ModInt {
    int val;
    ModInt() : val(0) {}
    ModInt(long long x) : val(x >= 0 ? x % mod : (mod - (-x) % mod) % mod) {}
    int getmod() { return mod; }
    ModInt &operator+=(const ModInt &p) {
        if ((val += p.val) >= mod) {
            val -= mod;
        }
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((val += mod - p.val) >= mod) {
            val -= mod;
        }
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        val = (int)(1LL * val * p.val % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-val); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return val == p.val; }
    bool operator!=(const ModInt &p) const { return val != p.val; }
    ModInt inverse() const {
        int a = val, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(long long n) const {
        ModInt ret(1), mul(val);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.val; }
    friend istream &operator>>(istream &is, ModInt &a) {
        long long t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
    static int get_mod() { return mod; }
};
const int MOD = 1000000007;  // if inv is needed, this shold be prime.
using modint = ModInt<MOD>;

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    map<char, int> m;
    modint ans = 1;
    for (int l = 0; l < N; l++) {
        m[S[l]]++;
    }
    for (auto p : m) {
        ans *= modint(p.second + 1);
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    
	public static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] c = new int[N];
		int[] t = new int[N];
		int min = Integer.MAX_VALUE;
		int count = -1;
		
		for(int i = 0;i < N ; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		
		for(int i = 0; i < N ; i++){
		    if(min > c[i] && T >= t[i]){
		    min = Math.min(min,c[i]);
		    count = i;
			}
	    }
	
		if(count == -1){ System.out.println("TLE");}
		else{System.out.println(c[count]);}
    }
}

Measured memory_bytes: 23764
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

A,B,C = MI()
K = I()

a = 0
while B <= A:
    B *= 2
    a += 1
while C <= B:
    C *= 2
    a += 1

if a <= K:
    print('Yes')
else:
    print('No')


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    string s;
    cin>>s;
    //cout <<fixed<<setprecision(16)<< << endl;

    if(s == "ABC")cout << "ARC" <<endl;
    else cout << "ABC" <<endl;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const double eps=0.000025;
int main(){
    int N;
    cin>>N;
    for(register double h=1;h<=3500;++h)
        for(register double n=1;n<=3500;++n){
            double sum=(N*h*n/(4*h*n-N*n-N*h));
            if(sum<0)continue;
            if(sum-(double)((int)sum)<eps){
                cout<<h<<' '<<n<<' '<<(int)sum;
                return 0;
            }
        }
    return 0;
}

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

int main(){
  int a,b,n;
  while(cin >> a >> b >> n){
    int k = a % b * 10;
    int s = 0;
    for(int i=0;i<n;i++){
      s += k / b;
      k = k % b * 10;
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
	"math"
)

func main() {

	var a, b, C float64

	fmt.Scanln(&a, &b, &C)

	S := a * b * math.Sin(C/180.0*math.Pi) / 2

	L := a + b + math.Sqrt(a*a+b*b-2*a*b*math.Cos(C/180.0*math.Pi))

	h := S * 2 / a

	fmt.Printf("%f %f %f\n", S, L, h)

}



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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

ll mod_pow(ll x,ll e){
  return e? e&1? x*mod_pow(x,e-1)%MOD:mod_pow(x*x%MOD,e/2):1;
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string L;cin>>L;
  ll ans = 0;
  ll tmp = 1;
  for(ll i=0;i<(ll)L.length();i++){
    if(L[i]=='1'){
      ans = (ans+mod_pow(3,L.length()-1-i)*tmp%MOD)%MOD;
      tmp = tmp*2%MOD;
    }
  }
  ans=(ans+tmp)%MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    int K; cin >> K;
    vector<ll> L(max(10, K+2));
    for (int i = 1; i <= 9; i++) {
        L[i] = i;
    }
    int l = 1, r =10;
    while (r <= K) {
        int d1 = L[l]%10;
        ll x10 = L[l] * 10;
        if (d1 != 0) L[r++] = x10 + d1 - 1;
        L[r++] = x10 + d1;
        if (d1 != 9) L[r++] = x10 + d1 + 1;
        l++;
    }
    cout << L[K] << endl;
}


Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    string num[]={
        "0111111",  //0
        "0000110",  //1
        "1011011",  //2
        "1001111",  //3
        "1100110",  //4
        "1101101",  //5
        "1111101",  //6
        "0100111",  //7
        "1111111",  //8
        "1101111"   //9
    };
    
    while(cin>>n){
        if(n==-1)break;
        
        string now="0000000";
        
        rep(i,n){
            int a;
            cin>>a;
            rep(i,7){
                if(now[i]!=num[a][i])cout<<"1";
                else cout<<"0";
            }
            cout<<endl;
            now=num[a];

        }
        
    }
    return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	ll a[200020];
	for(int i=0; i<n; i++) cin>>a[i];
	ll dp[4][200020];
	for(int i=0; i<4; i++) fill(dp[i], dp[i]+n+1, -1e18);
	dp[0][0]=0;
	for(int i=0; i<=3 && i<n; i++){
		dp[(i+2)/2-1][i+1]=a[i];
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<4; j++){
			if((i+1)/2-j<0) continue;
			for(int k=i+1; k<=i+3 && k<n; k++){
				int t=(k+2)/2-((i+1)/2-j+1);
				if(t<0 || t>=4) continue;
				dp[t][k+1]=max(dp[t][k+1], dp[j][i]+a[k]);
			}
		}
	}
	ll ans=-1e18;
	for(int i=n; i>=0; i--){
		if((i+1)/2-n/2<0) break;
		ans=max(ans, dp[(i+1)/2-n/2][i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11444
import math
def calc(x, y, z):
    return x * x + y * y + z * z + x * y + y * z + z * x

def calc_combination_num(x, y, z):
    if x == y and y == z:
        # 全部同じ数字なら組み合わせの個数は1個
        return 1
    if x == y or y == z:
        # どれか2つが同じ数字なら組み合わせの個数は3C2 = 3個
        return 3
    # 全部違う数字なら組み合わせの個数は3P2 = 6個
    return 6

N = int(input())

result_map = {}
for i in range(1, N + 1):
    result_map[i] = 0

# x <= y <= zとしてループを回し
for x in range(1, N):
    tempFn1 = calc(x, 0, 0)
    if tempFn1 > N:
        # もう数値は増える一方なのでやる必要なし
        break
    for y in range(x, N):
        tempFn2 = calc(x, y, 0)
        if tempFn2 > N:
            # もう数値は増える一方なのでやる必要なし
            break
        for z in range (y, N):
            fn = calc(x, y, z)
            if fn > N:
                # もう数値は増える一方なのでやる必要なし
                break
            # 組み合わせの個数の算出
            combination_num = calc_combination_num(x, y, z)
            result_map[fn] = result_map[fn] + combination_num

for result in result_map.values():
    print(result)


Measured memory_bytes: 9704
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int func(int N){
	int ret=0;
	for(int i=1;i<=N;i++){
		if(N%i==0)
			ret++;
	}
	return ret;
}
int main(){
	int N;
	cin>>N;
	int ans=0;
	for(int i=0;i<=N;i++){
		if(i%2 && func(i)==8)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#n = int(input())
#n, k = map(int, input().split())
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(h)]
s = list(input())


def isACGT(s):
    A = s.count('A')
    C = s.count('C')
    G = s.count('G')
    T = s.count('T')
    if A+C+G+T == len(s):
        return True
    else:
        return False


ans = 0
n = len(s)
for i in range(n):
    for j in range(i, n):
        tempstring = s[i:j+1]
        if isACGT(tempstring):
            ans = max(ans, len(tempstring))
print(ans)


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

using namespace std;

int main(){
    string str;

    cin >> str;

    int i = 0;
    int cnt = 0;

    while (i != str.length()){
        if (str[i] == 'C' && cnt == 0){
            cnt++;
        }
        else if (str[i] == 'F' && cnt == 1){
            cout << "Yes" << endl;

            return (0);
        }
        i++;
    }

    cout << "No" << endl;

    return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
int main(){
	cin>>n;
	for(long long i=1;i<=n;i++){
		if (i*i>n){
			ans=(i-1)*(i-1);
			break;
		}
		if(i*i==n){
			ans=i*i;
			break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
package main
import "fmt"

func main() {

 var b string;
  fmt.Scan(&b)
  switch b {
    case "A":
    fmt.Printf("T")
    case "T":
    fmt.Printf("A")
    case "G":
    fmt.Printf("C")
    case "C":
    fmt.Printf("G")
  }
  
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

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

  int n; cin >> n;
  vi as(n); F0R (i, n) cin >> as[i];
  as.pb(0);
  ll cur = 1000;

  int last = as[0];
  int mn = as[0];
  for (int i : as) {
    if (last > i) {
      ll get = cur / mn * last;
      cur %= mn;
      cur += get;
      mn = i;
    }
    last = i;
  }
  cout << cur << endl;
  
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N,K; cin >> N >> K;
  string S; cin >> S;
  v<int> b,w;
  int ans=0;
  int wcnt=0,bcnt=0;
  if(S[0]=='0') w.push_back(0);
  rep(i,N){
    if(S[i]=='0'){
      if(wcnt!=0){
        w.push_back(wcnt);
        wcnt=0;
      }
      bcnt++;
    }
    else{
      if(bcnt!=0){
        b.push_back(bcnt);
        bcnt=0;
      }
      wcnt++;
    }
  }
  if(wcnt!=0){
    w.push_back(wcnt);
    wcnt=0;
  }
  if(bcnt!=0){
    b.push_back(bcnt);
    bcnt=0;
  }
  if(S[SZ(S)-1]=='0') w.push_back(0);
  if(SZ(b)==0){
    cout << w[0] << endl;
    return 0;
  }
  //fore(i,w) cout << i << endl;
  chmin(K,SZ(b));
  for(int i=0;i<SZ(b);i++){
    if(i+K>SZ(b)) break;
    int tmp=0;
    for(int j=i;j<i+K;j++){
      tmp+=b[j];
    }
    for(int j=i;j<i+K+1;j++){
      tmp+=w[j];
    }
    //cout << tmp << endl;
    chmax(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define maxi INT_MAX
#define mini INT_MIN
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};

vector<vector<int>> g;
vector<int> parent, depth, subsize;

ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    ll n,m;
    cin>>n>>m;
    ll sum = 0;
    for(int i=0;i<m;i++)
    {
        int temp;
        cin>>temp;
        sum+=temp;
    }
    cout<<max((ll)-1, n-sum);
    
    
} 

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int dx[] = {0,0,1,1,1,-1,-1,-1}, dy[] =  {1,-1,1,0,-1,-1,0,1};
char dxy[51][51];
int main() {
    int y,x; cin >> y >> x;
    rep(i,y){
        rep(j,x){
            cin >> dxy[j][i];
        }
    }
    rep(i,x){
        rep(j,y){
            if(dxy[i][j]=='#'){
                continue;
            }
            else{
                int count = 0;
                rep(k,8){
                    int wx = i + dx[k], wy = j + dy[k];
                    if(wx<0 || wx>x-1 || wy<0 || wy>y-1){
                        continue;
                    }else{
                        if(dxy[i+dx[k]][j+dy[k]]=='#'){
                            count++;
                        }
                    }
                }
                dxy[i][j] = count+'0';
            }
        }
    }
    rep(i,y){
        rep(j,x){
            cout << dxy[j][i];
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
M=max(a)
K=str(format(k,'b'))
MM=str(format(M,'b'))
x=max(len(K),len(MM))
K=str(format(k,'b').zfill(x))
l=[]
for i in range(n):
  l.append(str(format(a[i],'b').zfill(x)))

ctMz=0
for z in range(len(K)):
  if K[z]=='0':
    ctMz+=1
  else:
    break

l2=[]


ct=0
for j in range(x):
  ctz=0
  cto=0
  for m in range(n):
    if l[m][j]=='0':ctz+=1
    else:cto+=1
  if j+1<=ctMz:
    ct+=(2**(x-j-1))*cto
    l2.append('0')
  else:
    if ctz>cto:
      ct+=(2**(x-j-1))*ctz
      l2.append('1')
    else:
      ct+=(2**(x-j-1))*cto
      l2.append('0')
      
y=int(''.join(l2))
y2=int(str(format(k,'b')))
if y2>=y:
  print(ct)
else:
  l2=['0' for aa in range(x)]
  ct=0
  for j in range(x):
    ctz=0
    cto=0
    for m in range(n):
      if l[m][j]=='0':ctz+=1
      else:cto+=1
    if j+1<=ctMz:
      ct+=(2**(x-j-1))*cto
      l2[j]='0'
    else:
      if ctz>cto:
        l2[j]='1'
        if y2>=int(''.join(l2)):
          ct+=(2**(x-j-1))*ctz
        else:
          ct+=(2**(x-j-1))*cto
          l2[j]='0'
      else:
        ct+=(2**(x-j-1))*cto
        l2[j]='0'
  print(ct)

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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) REP (i, 0, n)
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;

int main() {
	double n;
	while (cin >> n) {
		double t = n / 9.8;
		double y = 4.9 * t * t;
		// 繰り上げ関数ceil
		int ans = ceil((y + 5) / 5);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
int counta=0;
int64_t N;
void div(int y){
    int k=0;
    while(true){
        if(N%y==0){
            N/=y;
            k++;
        }
        else{
            break;
        }
    }
    int i=1;
    while(k>=((i+1)*i)/2){
        counta++;
        i++;
    }
}



int main(){
    cin>>N;
    for(int i=2;i<1000001;i++){
        if(N%i==0){
            div(i);
        }
    }
    if(N>1000000){
        counta++;
    }
    cout<<counta<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<string>
#include<list>
using namespace std;

typedef long double ld;

int main() {
  int N; cin >> N;
  ld P[N]; for (int i = 0; i < N; i++) cin >> P[i];
  ld dp[N+1][N+1];
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= i; j++) dp[i][j] = 0;
    for (int j = 0; j < i; j++) {
      dp[i][j] += (1 - P[i-1]) * dp[i-1][j];
      dp[i][j+1] += P[i-1] * dp[i-1][j];
    }
  }
  ld sum = 0;
  for (int j = N/2+1; j <= N; j++) sum += dp[N][j];
  cout << setprecision(15) << sum << endl;
}

Measured memory_bytes: 85688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_N = 200100;
int N; ll K;
ll A[MAX_N];
const ll INF = (ll)1e18 + 10LL;
int minus_num = -1, plus_num = -1;

void minus_init(){
    int ok = -1;
    int ng = N;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng)/2;
        if(A[mid] < 0) ok = mid;
        else ng = mid;
    }
    minus_num = ok;
    ok = N, ng = -1;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng)/2;
        if(A[mid] > 0) ok = mid;
        else ng = mid;
    }
    plus_num = ok;
    return ;
}

bool cmp(ll a, ll b, ll X) {
    return a*b < X;
}

ll order_ascending(ll X) { // 積がX未満になるのが何個あるか
    ll res = 0;
    // 尺取りをする場合には、単調減少性、単調増加性があるように配慮する必要がある
    if(X > 0) { //尺取り法でここの計算量をO(nlogn)->O(n)にしたかった なんかWAになっている
        int left = -1, right = N;
        for(int i = 0; i <= minus_num; ++i) {
            while(right-1 >= 0 && cmp(A[i], A[right-1], X)) --right;
            int candidate = right;
            if(candidate <= i) ++candidate;
            res += ll(N) - (ll)candidate;
        }
        for(int i = N-1; i > minus_num; --i) {
            while(left+1 < N && cmp(A[i], A[left+1], X)) ++left;
            int candidate = left;
            if(i <= candidate) --candidate;
            res += (ll)candidate + 1LL;
        }
    }
    else if(X == 0) {
        res += ll(minus_num + 1)*(N - plus_num)*2LL;
    }
    else {
        int left = -1, right = N;
        for(int i = minus_num; i >= 0; --i) {
            while(right-1 >= 0 && cmp(A[i], A[right-1], X)) --right;
            int candidate = right;
            if(candidate <= i) ++candidate;
            res += ll(N) - (ll)candidate;
        }
        for(int i = minus_num + 1; i < N; ++i) {
            while(left+1 < N && cmp(A[i], A[left+1], X)) ++left;
            int candidate = left;
            if(i <= candidate) --candidate;
            res += (ll)candidate + 1LL;
        }
    }
    return res/2LL;
}

int main()
{
    scanf("%d %lld", &N, &K);
    for(int i = 0; i < N; ++i) scanf("%lld", &A[i]);
    sort(A, A + N);
    minus_init();
    ll low = -INF, high = INF;
    while(abs(high - low) > 1) {
        ll mid = (low + high)/2;
        if(order_ascending(mid) < K) low = mid;
        else high = mid;
    }
    printf("%lld\n", low);
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
int main(){
  long N;cin>>N;
  vector<string>S(2);cin>>S[0]>>S[1];
  long ans=1;
  for(int i=0;i<N;i++){
    if(S[0][i]!=S[1][i]){
      if(i==0)ans=(ans*6)%MOD;
      else if(S[0][i-1]!=S[1][i-1])ans=(ans*3)%MOD;
      else ans=(ans*2)%MOD;
      i++;
    }else {
      if(i==0)ans=(ans*3)%MOD;
      else if(S[0][i-1]==S[1][i-1])ans=(ans*2)%MOD;
    }
  }
  cout<<ans;
}
  

Measured memory_bytes: 256
from collections import deque

N=int(input())
S=input()
edge=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

depth=[0]*N
num=[0]*N
sd=[0]*N

a=10**18

for i in range(N):
    depth=[0]*N
    num=[0]*N
    sd=[0]*N
    parent=[-1]*N

    que=deque([(i,-1)])
    ans=[i]
    while que:
        v,pv=que.popleft()
        for nv in edge[v]:
            if nv!=pv:
                depth[nv]=depth[v]+1
                parent[nv]=v
                que.append((nv,v))
                ans.append(nv)
    ans=ans[::-1]
    #print(depth)

    for v in ans:
        res=depth[v]*(S[v]=="1")
        n=int(S[v])
        for nv in edge[v]:
            if nv!=parent[v]:
                res+=sd[nv]
                n+=num[nv]
        sd[v],num[v]=res,n

    res=[0]*N

    for v in ans:
        hosei=depth[v]
        s=sd[v]-num[v]*hosei
        if s%2==0:
            check=0
            node=-1
            for nv in edge[v]:
                if nv!=parent[v]:
                    if sd[nv]-num[nv]*hosei>s//2:
                        check=sd[nv]-num[nv]*hosei
                        node=nv
            if not check:
                res[v]=s//2
            else:
                minus=res[node]
                if check-2*minus<=s-check:
                    res[v]=s//2
                else:
                    res[v]=s-check+minus
        else:
            check=0
            node=-1
            k=s//2
            for nv in edge[v]:
                if nv!=parent[v]:
                    if sd[nv]-num[nv]*hosei>k+1:
                        check=sd[nv]-num[nv]*hosei
                        node=nv
            if not check:
                res[v]=k
            else:
                minus=res[node]
                if check-2*minus<=s-check:
                    res[v]=k
                else:
                    res[v]=s-check+minus

    test=res[i]
    #print(i,test,sd[i],sd)
    if 2*test==sd[i]:
        a=min(a,test)

if a==10**18:
    print(-1)
else:
    print(a)


Measured memory_bytes: 87032
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    map<string,ll> m;
    ll N;
    string S;
    cin>>N>>S;

    rep(i,0,N){
        ll now = ll(S[i]-'0');
        rep(j,0,100){
            string l = j<=9?"0" + to_string(j):to_string(j);
            if(m[l] > 0){
                if(m[l+to_string(now)] == 0)m[l+to_string(now)]++;
                //cout<<l<<now<<endl;
            }
        }
        rep(j,0,10){
            if(m[to_string(j)] > 0){
                if(m[to_string(j)+to_string(now)] == 0)m[to_string(j)+to_string(now)]++;
            }
        }
        if(m[to_string(now)] == 0)m[to_string(now)]++;
    }
    ll ans=0;
    rep(i,0,1000){
        string l;
        if(i <= 9)l += "0";
        if(i <= 99)l += "0";
        l += to_string(i);
        if(m[l] >= 1){
            ans++;
            //cout<<l<<endl;
        }
    }
    cout<<ans;
    return 0;
}

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

int N, M;
int a[1010], b[1010], c[5000];
int dp[1010][5050];

int main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            int t;
            cin >> t; t--;
            c[i] += (1<<t);
        }
    }

    fill(dp[0], dp[1010], 1e8);
    dp[0][0] = 0;
    for (int i=0; i<M; ++i) {
        for (int j=0; j<(1<<N); ++j) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][j | c[i]] = min(dp[i+1][j | c[i]], dp[i][j] + a[i]);
        }
    }

    cout << (dp[M][(1<<N)-1] < 1e8 ? dp[M][(1<<N)-1] : -1) << endl;

    return 0;
}


Measured memory_bytes: 20224
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
char in[110];
string name[110];
string author[110];
int y[110];
int m[110];
int d[110];
int ok[110];
bool contain(string a,string b){
	if(a.size()<b.size())return false;
	for(int i=0;i<=a.size()-b.size();i++){
		bool OK=true;
		for(int j=0;j<b.size();j++)if(a[i+j]!=b[j])OK=false;
		if(OK)return true;
	}
	return false;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%s",in);
		name[i]=in;
		scanf("%s",in);
		author[i]=in;
		scanf("%d/%d/%d",y+i,m+i,d+i);
	}
	int b;scanf("%d",&b);
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++)ok[j]=1;
		scanf("%s",in);
		if(in[0]!='*'){
			string now=in;
			for(int j=0;j<a;j++){
				if(!contain(name[j],now))ok[j]=0;
			}
		}
		scanf("%s",in);
		if(in[0]!='*'){
			string now=in;
			for(int j=0;j<a;j++){
				if(!contain(author[j],now))ok[j]=0;
			}
		}
		scanf("%s",in);
		if(in[0]!='*'){
			int Y,M,D;
			sscanf(in,"%d/%d/%d",&Y,&M,&D);
			for(int j=0;j<a;j++){
				if(Y*10000+M*100+D>y[j]*10000+m[j]*100+d[j])ok[j]=0;
			}
		}
		scanf("%s",in);
		if(in[0]!='*'){
			int Y,M,D;
			sscanf(in,"%d/%d/%d",&Y,&M,&D);
			for(int j=0;j<a;j++){
				if(Y*10000+M*100+D<y[j]*10000+m[j]*100+d[j])ok[j]=0;
			}
		}
		for(int j=0;j<a;j++)if(ok[j])printf("%s\n",name[j].c_str());
		if(i<b-1)printf("\n");
	}
}

Measured memory_bytes: 1092
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int h, a;
    cin >> h >> a;
    int ans = 0;
    while(h > 0){
        h -=a;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
def f(x,y):
  while y!=0:
    x,y=y,x%y
  else:return x
l,r = [0],[0]
for i in range(n-1):
    l.append(f(l[-1],a[i]))
    r.append(f(r[-1],a[n-i-1]))
    
ans = 0
for i in range(n):
    ans = max(ans,f(l[i],r[n-i-1]))
print(ans)

Measured memory_bytes: 14052
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
using namespace std;
typedef long long LL;
   
inline int read() {
	int x=0,f=1; char ch=getchar();
	while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
	return x*f;
}

const int N = 11+1;

int can[N<<1][N<<1];
bool p=0;

/*bool game(int x,int y) {
	//if (p) cout<<x<<" "<<y<<" "<<can[x][y]<<endl;
	if (x==0&&y==0) return false;
	if (x==0&&y==1) return false;
	if (x==1&&y==1) return false;
	//if (can[x][y]!=-1) return can[x][y];
	bool flag=1;
	rep(i,1,x/2) {
		int tmpx=x-i*2,tmpy=y+i;
		if (tmpx>tmpy) swap(tmpx,tmpy);
		flag&=game(tmpx,tmpy);
	}
	rep(i,1,y/2) {
		int tmpx=x+i,tmpy=y-i*2;
		if (tmpx>tmpy) swap(tmpx,tmpy);
		flag&=game(tmpx,tmpy);
	}
	//if (flag) can[x][y]=0; else can[x][y]=1;
	//return can[x][y];
	if (flag) return false;
	return true;
}*/

int main() {
	
	#ifndef ONLINE_JUDGE
	//	freopen("data.in","r",stdin);
	//	freopen("data.out","w",stdout);
	#endif
	
	/*rep(i,0,N-1) rep(j,0,N-1) can[i][j]=-1;
	rep(i,0,N-1) {
		rep(j,i,N-1) {
			//if (i==6&&j==6) p=1;
			cout<<game(i,j)<<" ";
		}
		puts("");
	}*/
	LL x,y;
	scanf("%lld%lld",&x,&y);
	if (abs(x-y)>=2) puts("Alice"); else puts("Brown");
	
	return 0;
}

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

const int S = 100010;
int N, C;
int s[S], t[S], c[S];
int imos[2 * S], sum[2 * S];

int main() {
    scanf("%d%d", &N, &C);
    for(int i=0; i<N; i++) {
        scanf("%d%d%d", &s[i], &t[i], &c[i]);
    }

    for(int k=1; k<=C; k++) {
        memset(imos, 0, sizeof(imos));
        for(int i=0; i<N; i++) {
            if(c[i] != k) continue;
            imos[2*s[i] - 1]++; imos[2*t[i]]--;
        }
        for(int i=0; i<2*S; i++) {
            if(i != 0) imos[i] += imos[i-1];
            if(imos[i]) sum[i]++;
        }
    }

    printf("%d\n", *max_element(sum, sum + 2*S));
    return 0;
}

Measured memory_bytes: 2944
N, K = map(int, input().split())
x_list = list(map(int, input().split()))

ans = 10**9

for i in range(N-K+1):
    left = x_list[i]
    right = x_list[i+K-1]
    ans_temp = min(abs(left), abs(right)) + right - left
    ans = min(ans, ans_temp)

print(ans)

Measured memory_bytes: 85472
/*
	ID: Loxilante
	Time: 2020/08/29
	Prog: A
	Lang: cpp
*/
#ifdef ONLINE_JUDGE
#pragma GCC optimize("O3")
#endif
#include <bits/extc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...) 97
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn = int> inline tn next(void) { tn k; cin>>k; return k; }
signed main(void)
{
	clock_t Begin = clock();

	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c;
	cin>>a>>b>>c;
	
	clock_t InputFinished = clock();
	
	double time = (double)a/c;

	if (time > b) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
	clock_t End = clock();
	
	D((double)(End-Begin)/CLOCKS_PER_SEC);
	D((double)(End-InputFinished)/CLOCKS_PER_SEC);
	
	return 0;
}
/*

 */

Measured memory_bytes: 3648