akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1e9 + 7)
#define LINF (1e18)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

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

    int n, max_w;
    cin >> n >> max_w;

    ll w[n], v[n];
    REP(i, n) cin >> w[i] >> v[i];

    ll max_v = 100000;
    // dp[i] : 価値iを作れるときの重さの最小値
    vector<ll> dp(max_v + 1, LINF);

    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = max_v; j >= 0; j--) {
            if (j - v[i - 1] >= 0)
                dp[j] = min(dp[j], dp[j - v[i - 1]] + w[i - 1]);
        }
    }

    ll ans = 0;
    for (int i = 0; i <= max_v; i++) {
        if (dp[i] <= max_w)
            ans = max(ans, (ll)i);
    }

    cout << ans << endl;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

int gcd(int a, int b) {
  int r;
  while(b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

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

  int n, X;
  cin >> n >> X;
  vi x(n);
  rep(i, 0, n) {
    cin >> x[i];
    x[i] = abs(x[i] - X);
  }

  int ans = x[0];
  rep(i, 1, n) ans = gcd(ans, x[i]);
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    if (S == "SUN") {
        cout << 7 << endl;
    } else if (S == "MON") {
        cout << 6 << endl;
    } else if (S == "TUE") {
        cout << 5 << endl;
    } else if (S == "WED") {
        cout << 4 << endl;
    } else if (S == "THU") {
        cout << 3 << endl;
    } else if (S == "FRI") {
        cout << 2 << endl;
    } else if (S == "SAT") {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::collections::BinaryHeap;

#[allow(dead_code)]
fn read_line(n: usize) -> String {
    let mut ss = String::new();
    for _i in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        ss.push_str(&s);
    }
    ss
}

macro_rules! parse {
    ($s:expr => $($r:tt)*) => {
        let s = $s;
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        parse!{s => $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    parse!{
        n: usize,
        k: u64,
        hs: [u64; n],
    }
    let mut pq = BinaryHeap::new();
    for h in hs {
        pq.push(h);
    }
    for _i in 0..k {
        pq.pop();
    }
    let sum = pq.iter().fold(0, |sum, v| sum + v);
    println!("{}", sum);
}

Measured memory_bytes: 12540
#include<bits/stdc++.h>
    #include<ext/pb_ds/assoc_container.hpp>
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    # define ll long long
    # define int long long  //comment it out when MLE
    //# define endl "\n"
    #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //# define m 163577857
    # define mo 1000000007
    # define pi acos(-1)
    # define fi first
    # define se second
    #define REP(i,n) for (int i = 1; i <= n; i++)
    const ll mod = 998244353;
    //const int K = 2;
    //typedef vector<vector<int> > matrix;
    /*
    int add(int a, int b,int mod) {
        a%=mod;
        b%=mod;
        a += b;
        if (a >= mod) a -= mod;
        if(a<0)
        {
            a += mod;
            a %= mod;
        }
        return a;
    }

    int mul(ll a, int b,int mod) {
        a%=mod;
        b%=mod;
        a *= b;
        a += mod;
        return a % mod;
    }
    int po(int a,int b,int mod)
    {
        if(b==0)
            return 1;
        if(b%2==0)
            return po(mul(a,a,mod),b/2,mod);
        return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
    }


    ll fact[1000003];
    ll inv[1000003];

    void fact0()
    {
        int i,j;
        fact[0]=1;
        for(i=1;i<=600000;i++)
        {
            fact[i]=i*fact[i-1]%mod;
        }
        inv[0]=1;
        inv[1]=1;
        ll p=mod;
        for (i=2; i<=600000; i++)
            inv[i] = (p - (p/i) * inv[p%i] % p) % p;

        for(i=2;i<=600000;i++)
        {
            inv[i]*=inv[i-1];
            inv[i]%=mod;
        }
    }
    int help(int a,int b)
    {
       // cout<<a<<" "<<b<<endl;
        int an = fact[a];
        //cout<<an<<endl;
        an *= inv[b];
        an %= mod;
        an *= inv[a-b];
        an %= mod;
        return an;
    }
    */

signed main(){
       gok

   int h1,m1,h2,m2,k;;
   cin>>h1>>m1>>h2>>m2>>k;
   int mi = (h2-h1)*60 + (m2-m1);
   cout<<mi-k;




















        return 0;
    }


Measured memory_bytes: 3652
s,t = input(),input()
n,m = len(s),len(t)
dp = [[0 for i in range(m+1)] for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1,m+1):
        cost = 1 if s[i-1]==t[j-1] else 0
        dp[i][j] = max(dp[i-1][j],dp[i][j-1],dp[i-1][j-1]+cost)
ans = ''
while n>0 and m>0:
    if dp[n][m]==dp[n-1][m]:
        n -= 1
    elif dp[n][m]==dp[n][m-1]:
        m -= 1
    else:
        n -= 1
        m -= 1
        ans += s[n]
print(ans[::-1])

Measured memory_bytes: 120412
const fi='';
      fo='';
      oo=trunc(1e18);
      maxn=trunc(1e5);
var   n:longint;
      sol:int64;
      nheapmin,nheapmax:longint;
      heapmax,heapmin:array[0..2*maxn]of longint;
      a:array[0..3*maxn]of longint;
      l,r:array[0..3*maxn]of int64;
function min(i,j:int64):int64; begin if i<j then exit(i); exit(j); end;
function max(i,j:int64):int64; begin if i>j then exit(i); exit(j); end;
procedure swap(var a,b:Longint);
var temp:longint;
begin
      temp:=a;
      a:=b;
      b:=temp;
end;
procedure upmax(i:longint);
begin
      if (i=1)or(heapmax[i div 2]>=heapmax[i]) then exit
      else begin
                  swap(heapmax[i],heapmax[i div 2]);
                  upmax(i div 2);
           end;
end;
procedure upmin(i:longint);
begin
      if (i=1)or(heapmin[i div 2]<=heapmin[i]) then exit
      else begin
                  swap(heapmin[i div 2],heapmin[i]);
                  upmin(i div 2);
           end;
end;
procedure downmax(i:longint);
var gt:longint;
begin
      gt:=i*2;
      if gt>nheapmax then exit;
      if (gt+1<=nheapmax)and(heapmax[gt]<heapmax[gt+1]) then inc(gt);
      if heapmax[i]>=heapmax[gt] then exit;
      begin
                    swap(heapmax[gt],heapmax[i]);
                    downmax(gt);
      end;
end;
procedure downmin(i:longint);
var gt:longint;
begin
      gt:=i*2;
      if gt>nheapmin then exit;
      if (gt+1<=nheapmin)and(heapmin[gt]>heapmin[gt+1]) then inc(gt);
      if heapmin[i]<=heapmin[gt] then exit;
      begin
                  swap(heapmin[gt],heapmin[i]);
                  downmin(gt);
      end;
end;
procedure pushmin(x:longint);
begin
       inc(nheapmin);
       heapmin[nheapmin]:=x;
       upmin(nheapmin);
end;
procedure pushmax(x:longint);
begin
      inc(nheapmax);
      heapmax[nheapmax]:=x;
      upmax(nheapmax);
end;
procedure popmin(x:longint);
begin
      heapmin[1]:=x;
      downmin(1);
end;
procedure popmax(x:longint);
begin
       heapmax[1]:=x;
       downmax(1);
end;
procedure inp;
var i:longint;
begin
      read(n);
      for i:=1 to 3*n do read(a[i]);
end;
procedure main;
var i,j:longint;
    res:int64;
    nmax,nmin:longint;
begin
      res:=0;
      for i:=1 to n do
      begin
          res:=res+a[i];
          pushmin(a[i]);
      end;
      l[n]:=res;
      for i:=n+1 to 2*n do
      begin
          if a[i]>heapmin[1] then
          begin
             res:=res-heapmin[1]+a[i];
             popmin(a[i]);
          end;
          l[i]:=res;
      end;
      res:=0;
      for i:=3*n downto 2*n+1 do
      begin
          res:=res+a[i];
          pushmax(a[i]);
      end;
      r[2*n+1]:=res;
      for i:=2*n downto n+1 do
      begin
          if a[i]<heapmax[1] then
          begin
             res:=res-heapmax[1]+a[i];
             popmax(a[i]);
          end;
          r[i]:=res;
      end;
      sol:=-oo;
      for i:=n to 2*n do sol:=max(sol,l[i]-r[i+1]);
      write(sol);
end;
begin
      assign(input,fi);
      reset(input);
      assign(output,fo);
      rewrite(output);
      inp;
      main;
      close(output);
end.


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

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll ans = W * (H / 2);
    if (H % 2)
        ans += (W + 1) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int n,A[50];

int solve(int i,int m);

int solve (int i,int m){
  if (m == 0) return 1;
  if (i >= n) return 0;
  int res = solve(i + 1,m) || solve(i + 1, m- A[i]);
  return res;

}


int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i = 0; i < q ; i++){
    scanf("%d",&M);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");


}
  return 0;

}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define ll double
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[301][301][301];
ll solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;

    if(dp[one][two][three] > 0)
        return dp[one][two][three];

    int remaining = one + two + three;
    ll exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                    three*solve(one,two+1,three-1,n);

    return dp[one][two][three] = exp_val/remaining;
}

int main(){
    int i,j,t,n,m,p,k;
    //fast_io;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        int one=0,two=0,three=0;

        fr(0,n){
            int x;
            cin >> x;
            if(x == 1)one++;
            else if(x == 2)two++;
            else three++;
        }

        memset(dp, -1, sizeof dp);
        cout<<fixed<<setprecision(9)<<solve(one,two,three,n);
    }
    return 0;
}


Measured memory_bytes: 216868
n = gets.to_i
a = Array.new(n){gets.to_i}
b = 0
cnt = 0
n.times do |i|
  c = a[i]
  d = b + c
  cnt += d / 2
  if d % 2 > 0
    b = c > 0 ? 1 : 0
  else
    b = 0
  end
end
puts cnt

Measured memory_bytes: 15152
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;


int main()
{
    int N,M;
    int ans=0;
    vector<int> X(100000,0);
    vector<int> diffX(100000,0);
    
    cin >> N >> M;

    for (int i = 0; i < M; i++)
    {
        cin >> X[i];
    }
    X.erase(X.begin() + M,X.end());
    diffX.erase(diffX.begin() + M-1,diffX.end());

    sort(X.begin(), X.end());
    for (int i = 0; i < M-1; i++)
    {
        diffX[i]= X[i+1]-X[i];
    }
    sort(diffX.begin(), diffX.end(),greater<int>());
    if (N<M)
    {
        ans = accumulate(diffX.begin()+N-1, diffX.end(), 0);
    }
    else
    {
        ans = 0;
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,p=0,q=0,i;
    string s,t;
    cin>>a>>b;
    for(i=0; i<b; i++)
    {
        p=p*10+a;
    }
    for(i=0; i<a; i++)
    {
        q=q*10+b;
    }
    s=to_string(p);
    t=to_string(q);

    if(s<=t)cout<<s<<endl;
    else
        cout<<t<<endl;





}


Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
const char* solve() {
    int N;
    cin >> N;
    vector<pair<int, int>> AB(N);
    for_each(AB.begin(), AB.end(), [](auto& p) { cin >> p.first >> p.second; });
    sort(AB.begin(), AB.end(), [](const auto& p, const auto& q) { return p.second < q.second; });
    long long now = 0;
    for (const auto& p : AB) {
        now += p.first;
        if (now > p.second) return "No";
    }
    return "Yes";
}
int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main() {
	long long n; cin >> n;
	long long a[10] = {};
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		if		(s[0] == 'M')a[1]++;
		else if (s[0] == 'A')a[2]++;
		else if (s[0] == 'R')a[3]++;
		else if (s[0] == 'C')a[4]++;
		else if (s[0] == 'H')a[5]++;
	}
	unsigned long long ans = 0;
	for (int i = 1; i <= 3; i++) {
		for (int j = i + 1; j <= 4; j++) {
			for (int k = j + 1; k <= 5; k++) {
				ans += a[i] * a[j] * a[k];
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int h, w;
  cin >> h >> w;
  vector<string> field(h);
  rep(i, h) { cin >> field[i]; }

  vector<vector<int>> left(h, vector<int>(w));
  vector<vector<int>> right(h, vector<int>(w));
  rep(row, h) {
    rep(col, w) {
      if (field[row][col] == '#') {
        left[row][col] = 0;
      } else {
        if (col == 0) { left[row][col] = 1; }
        else          { left[row][col] = left[row][col-1] + 1; }
      }
      if (field[row][w-col-1] == '#') {
        right[row][w-col-1] = 0;
      } else {
        if (col == 0) { right[row][w-1] = 1; }
        else          { right[row][w-col-1] = right[row][w-col] + 1;}
      }
    }
  }

  vector<vector<int>> up(h, vector<int>(w));
  vector<vector<int>> down(h, vector<int>(w));
  rep(col, w) {
    rep(row, h) {
      if (field[row][col] == '#') {
        up[row][col] = 0;
      } else {
        if (row == 0) { up[row][col] = 1; }
        else          { up[row][col] = up[row-1][col] + 1; }
      }
      if (field[h-row-1][col] == '#') {
        down[h-row-1][col] = 0;
      } else {
        if (row == 0) { down[h-row-1][col] = 1; }
        else          { down[h-row-1][col] = down[h-row][col] + 1;}
      }
    }
  }

  int ans = 0;
  rep(row, h) {
    rep(col, w) {
      ans = max(ans, left[row][col] + right[row][col] + up[row][col] + down[row][col] - 3);
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
	int n;
    cin >> n;
    vector<int> asi(n+1);
    vector<ll> cos(n+1);
    rep(i, n) cin >> asi.at(i+1);
    asi.at(0) = asi.at(1);
    cos.at(0) = 0;
    cos.at(1) = 0;
    for(int i=2; i<=n; i++){
      cos.at(i) = min(max(asi.at(i-2)-asi.at(i), asi.at(i)-asi.at(i-2))+cos.at(i-2), max(asi.at(i-1)-asi.at(i), asi.at(i)-asi.at(i-1))+cos.at(i-1));
    }
	cout << cos.at(n) << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
   int64_t N,P;
  cin>>N>>P; int c=0;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++){
    int64_t a; cin>>a;
    a%=2;if(a==1)c++;
    A.at(i)=a;
  }if(c==0){
  if(P==1)
    cout<<0<<endl;
    else{int64_t ans=pow(2,N);cout<<ans<<endl;}
  
  }else{int64_t ans=pow(2,N-1); cout<<ans<<endl;}
  return 0;
}

Measured memory_bytes: 3976
import java.util.Scanner;

class Queue {
    int[] data;
    int maxLen;
    int lastEnqueue;
    int queueSize;

    public Queue(int maxLen) {
        this.data = new int[maxLen];
        this.maxLen = maxLen;
        this.lastEnqueue = maxLen - 1;
        this.queueSize = 0;
    }

    public void enqueue(int num) {
        this.queueSize++;
        this.lastEnqueue++;
        if (this.lastEnqueue >= this.maxLen) {
            this.lastEnqueue = 0;
        }
        this.data[this.lastEnqueue] = num;
    }

    public int dequeue() {
        if (this.queueSize == 0) {
            return -1;
        }

        int dequeueIndex = this.lastEnqueue - this.queueSize + 1;
        if (dequeueIndex < 0) {
            dequeueIndex += this.maxLen;
        }
        int num = this.data[dequeueIndex];
        this.queueSize--;
        return num;
    }
}

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nq = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(nq[0]); // num processes
        int q = Integer.parseInt(nq[1]); // quoantum number

        String[] names = new String[n];
        int[] times = new int[n];
        for (int i = 0; i < n; i++) {
            String[] nameTime = scanner.nextLine().split(" ", 2);
            names[i] = nameTime[0];
            times[i] = Integer.parseInt(nameTime[1]);
        }

        new Main().printProcessFinishes(n, q, names, times);
    }

    private void printProcessFinishes(int n, int q, String[] names, int[] times) {
        int now = 0;
        Queue queue = new Queue(n);
        for (int i = 0; i < n; i++) {
            queue.enqueue(i);
        }

        int dequeued;
        while ((dequeued = queue.dequeue()) >= 0) {
            if (times[dequeued] <= q) {
                now += times[dequeued];
                System.out.print(names[dequeued]);
                System.out.print(" ");
                System.out.println(now);
            } else {
                now += q;
                times[dequeued] -= q;
                queue.enqueue(dequeued);
            }
        }
    }
}



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

int main() {
  long long n;
  cin >> n;
  queue<string>que;
  que.push("3");
  que.push("5");
  que.push("7");
  vector<string>ans;
  while(true){
    string a = que.front();
    if(stoll(a) > n) break;
    bool f3 = false,f5 = false,f7 = false;
    for(int i = 0;i < a.size();i++){
      if(a[i] == '3') f3 = true;
      if(a[i] == '5') f5 = true;
      if(a[i] == '7') f7 = true;
    }
    que.pop();
    if(f3 && f5 && f7) ans.push_back(a);
    que.push(a+'3');
    que.push(a+'5');
    que.push(a+'7');
  }
  cout << ans.size() << endl;
}


Measured memory_bytes: 5884
from itertools import groupby, combinations
N = int(input())
Names = [input()[0] for _ in range(N)]
Names.sort()
Initials = {k: len(list(g)) for k, g in groupby(Names) if k in ['M', 'A', 'R', 'C', 'H']}
L = combinations(Initials.keys(), 3)
cnt = 0
for c in L:
    cnt += Initials[c[0]] * Initials[c[1]] * Initials[c[2]]
print(cnt)

Measured memory_bytes: 4652
import java.util.Scanner;
class Main
{
	static boolean isPrime( int x )
	{
		if( x == 2 )return true;
		if( x<2 || x%2==0 )return false;
		for( int i = 3 ; i*i <= x ; i++ )
			if( x%i==0 )return false;
		return true;
	}
	public static void main( String[] args )
	{
		Scanner sc = new java.util.Scanner( System.in );
		
		int n = sc.nextInt(), counter=0;
		for( ; n != 0 ; n-- )
			if( isPrime(sc.nextInt()) )counter++;
		
		System.out.println( counter );
	}
}

Measured memory_bytes: 41344
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
a = na()

s = sum(a)
cnt = 0
for i in range(n):
    if a[i] >= s / (4 * m):
        cnt += 1

if cnt >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int n,m; cin >> n >> m;
  vector<int> c(m);
  rep(i,m) cin >> c[i];

  vector<int> dp(n+1,1e9);
  dp[0] = 0;
  rep(i,n) {
    rep(j,m) {
      if (c[j] <= i+1) dp[i+1] = min(dp[i+1],dp[i+1-c[j]]+1);
    }
  }

  cout << dp[n] << endl;
}


Measured memory_bytes: 3120
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

int main()
{
  string s;
  int K;
  
  getline(cin, s);
  scanf("%d", &K);
  
  set<string> myset;
  
  int N = s.size();
  
  REP(i, 0, N-1)
  {
    for(int j = i; j < N && j < i+5; j++)
    {
      string ss;
      REP(k, i, j) ss.push_back(s[k]);
      myset.insert(ss);
    }
  }
  
  set<string>::iterator it;
  
  it = myset.begin();
  REP(i, 0, K-2) it++;
  
  cout << *it << endl;
    
  return 0;
}

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

int main() {
	int n,build,floor,room,people;
	cin >> n;
	int A[4][3][10];
	
	for (int s = 0; s < 4; s++) {
		for (int r = 0; r < 3; r++) {
			for (int q = 0; q < 10; q++) {
				A[s][r][q] = 0;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cin >> build >> floor >> room >> people;
		A[build-1][floor-1][room-1] += people;
	}

	for (int s = 0; s < 4; s++) {
		if(s!=0)
			cout << "####################" << endl;
		for (int r = 0; r < 3; r++) {
			for (int q = 0; q < 10; q++) {
				cout << " " << A[s][r][q];
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,a,n) for(int i=a;i<n;i++)
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}

  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
  }
};
typedef Point vect;
struct seg{Point p1,p2;};
double norm(Point p){return p.x*p.x+p.y*p.y;}
double abs(Point p){return sqrt(norm(p));}
double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
int CCW(Point p0,Point p1,Point p2){
  Point a=p1-p0;
  Point b=p2-p0;
  if(cross(a,b)>EPS)return 1;
  if(cross(a,b)<-EPS)return -1;
  if(dot(a,b)<-EPS)return 2;
  if(norm(a)<norm(b))return -2;
  return 0;
}
double getDistancePP(Point a,Point b){
  return abs(a-b);
}
double getDistanceLP(seg l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}
double getDistanceSP(seg s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}
bool intersect(Point p1,Point p2,Point p3,Point p4){
  return(CCW(p1,p2,p3)*CCW(p1,p2,p4)<=0&&CCW(p3,p4,p1)*CCW(p3,p4,p2)<=0);
}
bool intersect(seg s1,seg s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}
double getDistance(seg s1,seg s2){
  if(intersect(s1,s2))return 0.0;
  return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),
    min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}
int main(){
  double a,b,c,d;
  int n,ve,al;
  while(cin>>n>>ve>>al,n){
    Point p[n][5];
    seg D[n][5];
    r(i,n){
      cin>>a>>b>>c>>d;
      r(j,5){
        p[i][j].x=a-d*sin(M_PI/180*(72*j+c));
        p[i][j].y=b+d*cos(M_PI/180*(72*j+c));
      }
      D[i][0].p1=p[i][0];D[i][0].p2=p[i][2];
      D[i][1].p1=p[i][1];D[i][1].p2=p[i][3];
      D[i][2].p1=p[i][2];D[i][2].p2=p[i][4];
      D[i][3].p1=p[i][3];D[i][3].p2=p[i][0];
      D[i][4].p1=p[i][4];D[i][4].p2=p[i][1];
    }
    double w[n][n];
    r(i,n)r(j,n)w[i][j]=i==j?0:1000000000;
    r(i,n)R(j,i+1,n){
      double t=1000000000;
      r(k,5)r(l,5)t=min(t,getDistance(D[i][k],D[j][l]));
      w[i][j]=w[j][i]=t;
    }
    r(k,n)r(i,n)r(j,n)w[i][j]=min(w[i][j],w[i][k]+w[k][j]);
    printf("%.11f\n",w[ve-1][al-1]);
  }
}

Measured memory_bytes: 3720
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include <numeric>
using namespace std;
#define MAX_N 10006
#define MAX_M 20000
#define INF 1e9 + 1
int n,m,x;
struct edge {
	int to,dis,cost;
	edge();
	edge(int to,int dis,int cost):to(to),dis(dis),cost(cost) {}

};
int sum;
int ans[MAX_N];
typedef pair<int,int> P;//first??????????????????second?????¶????????????
vector<edge> G[MAX_N];
int d[MAX_N];//??¶?????°??????????????????
int dijkstra(int s) {
	int res = 0;
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+MAX_N,INF);
	fill(ans,ans+MAX_N,INF);
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v]<p.first) continue;
		for(int i=0; i<G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to]>d[v]+e.dis) {
				ans[e.to] =e.cost;
				d[e.to]=d[v]+e.dis;
				que.push(P(d[e.to],e.to));

			}else if(d[e.to]==d[v]+e.dis&&ans[e.to]>e.cost){
				ans[e.to] = e.cost;
			}
		}
	}
	return accumulate(ans+2,ans+n+1,res);
}

int main() {
	while(scanf("%d%d",&n,&m)&&n!=0) {
		int u,v,d,c;
		for(int i=0;i<=n;i++){
			G[i].clear();
		}
		for(int i=0; i<m; i++) {
			scanf("%d%d%d%d",&u,&v,&d,&c);
			G[u].push_back(edge(v,d,c));
			G[v].push_back(edge(u,d,c));

		}
		sum = dijkstra(1);
		printf("%d\n",sum);
	}


}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    ll h;
    cin>>h;

    ll num = 1;
    ll ans = 0;
    while( h )
    {
        ans += num;
        h /= 2;
        num *= 2;
    }
    cout<<ans,nl;


    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

int main(){
	string s;
	int L;
	cin >> s;
	L=s.size();
	for (int i = 0; i < L; i++) {
		if (s[i] == 'L'&&i%2==0) {
			printf("No");
			return 0;
		} else if (s[i] == 'R' && i % 2 == 1) {
			printf("No");
			return 0;
		} 
	}
	printf("Yes");
}

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

int main() {
    int h, w;
    cin >> h >> w;

    // int sy, sx, gy, gx;
    // cin >> sy >> sx >> gy >> gx;

    // sy--; sx--; gy--; gx--;

    vector<string> field(h);
    rep(i, h) cin >> field[i];

    const int dy[4] = {0, 1, 0, -1};
    const int dx[4] = {1, 0, -1, 0};
    
    vector<vector<int>> dist(h, vector<int>(w, -1));
    queue<pair<int, int>> que;

    int ans = -1;
    rep(sy, h) rep(sx, w) rep(gy, h) rep(gx, w) {
        if (field[sy][sx] == '#' || field[gy][gx] == '#') continue;
        rep(i, h) fill(dist[i].begin(), dist[i].end(), -1);

        dist[sy][sx] = 0;
        que.push(make_pair(sy, sx));

        while (!que.empty()) {
            pair<int, int> from = que.front();
            que.pop();

            rep(i, 4) {
                int ny = dy[i] + from.first;
                int nx = dx[i] + from.second;

                if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
                if (field[ny][nx] == '#') continue;
                if (dist[ny][nx] != -1) continue;

                dist[ny][nx] = dist[from.first][from.second] + 1;
                que.push(make_pair(ny, nx));
            }
        }

        ans = max(ans, dist[gy][gx]);
    }
    
    cout << ans << endl;

    return 0;
}

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

int N, six[10], nine[10], minc = 1e9;
bool visited[100009];

int main(void){
    
    cin >> N;
    
    if(N<6) {
        cout << N << endl;
        return 0;
    }
    
    memset( visited, false, sizeof(visited));
    
    int cnt = 0;
    queue<int> now, nxt;
    now.push(0);
    for(int i = 0; i < 200; i++) {
        
        while(!now.empty()) {
            int p = now.front(); now.pop();
            if ( p == N) { cout << cnt << endl; return 0;}
            minc = min( minc, N-p + cnt);
            for (int n = 6; p+n <= N; n*=6 ) {
                if (visited[p+n]) continue;
                nxt.push(p+n);
                visited[p+n] = true;
            }
            for (int n = 9; p+n <= N; n*=9 ) {
                if (visited[p+n]) continue;
                nxt.push(p+n);
                visited[p+n] = true;
            }
        }
        cnt++;
        now.swap(nxt);
        if (cnt > minc) break;
    }
    cout << minc << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

template <typename T> struct BIT { // 1-indexed
private:
    vector<T> array;
    const int n;

public:
    // 初期化
    BIT(int _n) : array(_n + 1, 0), n(_n) {}

    // 1番目からi番目までの累積和を求める
    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i; // LSB減算
        }

        return s;
    }

    // [i, j]の要素の総和
    T sum(int i, int j) {
        T ret_i = sum(i - 1);
        T ret_j = sum(j);

        return ret_j - ret_i;
    }

    // i番目に要素xを追加
    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i; // LSB加算
        }
    }
};

template <typename T> struct BIT2 { // 1-indexed
private:
    vector<vector<T> > array;
    const int n;
    const int m;

public:
    // 初期化
    BIT2(int _n, int _m) : array(_n + 1, vector<T>(_m + 1, 0)), n(_n), m(_m) {}

    // (1, 1)から(x, y)までの累積和を求める
    T sum(int x, int y) {
        T s = 0;
        for (int i = x; i > 0; i -= i & (-i)) {
            for (int j = y; j > 0; j -= j & (-j)) {
                s += array[i][j];
            }
        }

        return s;
    }

    // [(x1, y1), (x2, y2)]の要素の総和
    T sum(int x1, int y1, int x2, int y2) {
        return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1);
    }

    // (x, y)に要素kを追加
    void add(int x, int y, T k) {
        for (int i = x; i <= n; i += i & (-i)) {
            for (int j = y; j <= m; j += j & (-j)) {
                array[i][j] += k;
            }
        }
    }
};

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

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

    int cnt_odd = 0;
    int cnt_even = 0;
    for (int i = 1; i <= k; ++i) {
        if (i % 2 == 0) cnt_even++;
        else cnt_odd++;
    }

    cout << cnt_even * cnt_odd << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

#include<string>



using namespace std;



int main(){

	int a=1,b=2,c=3,s;

	char x,y,z;

	while(cin>>x>>y>>z){

		if((x=='A' && z=='B') || (x=='B' && z=='A')){

			s=a;

			a=b;

			b=z;

		}else if((x=='C' && z=='B') || (x=='B' && z=='C')){

			s=b;

			b=c;

			c=s;

		}else if((x=='A' && z=='C') || (x=='C' && z=='A')){

			s=c;

			c=a;

			a=s;

		}

	}

	if(a==1){
		cout << "A" << endl;

	}else if(a==2){
		cout << "B" << endl;

	}else{
		cout << "C" << endl;

	}
	return 0;

}


Measured memory_bytes: 3088
import java.util.*;
import java.lang.*;
import java.io.*;

class Main{

    private static int[][] used;
    private static int N,M,L;
    private static List<Pox>[] list;
    private static final int INF = 100000000;

    private static class Pox{
	public int B,D,E;
	Pox(){
	    B = D = E = 0;
	}

	Pox(int b,int d,int e){
	    B = b;
	    D = d;
	    E = e;
	}
    }

    private static class Eleac implements Comparable<Eleac>{
	public int id,L,num;

	Eleac(){
	    id = L = num = 0;
	}

	Eleac(int a,int b,int c){
	    id = a;
	    L = b;
	    num = c;
	}

	@Override
	public int compareTo(Eleac a){
	    return 1;
	}

    }

     @SuppressWarnings("unchecked")
      public static void main(String args[])throws IOException{
	  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	  
	  while(true)
	      {
		  String[] elements = in.readLine().split(" ");
		  N = Integer.parseInt(elements[0]);
		  M = Integer.parseInt(elements[1]);
		  L = Integer.parseInt(elements[2]);
		  if(N == 0 && M == 0 && L == 0)
		      break;

		  

		  used = new int[N+1][L+1];
		  list = new ArrayList[N+2];

		  for(int i=0;i<N+1;i++)
		      for(int j=0;j<L+1;j++)
			  used[i][j] = INF;

		  for(int i=0;i<N+1;i++)
		      list[i] = new ArrayList<Pox>();
		  
		  for(int i=0;i<M;i++)
		      {
			 elements = in.readLine().split(" ");
			 int A,B,D,E;
			  A = Integer.parseInt(elements[0]);
			  B = Integer.parseInt(elements[1]);
			  D = Integer.parseInt(elements[2]);
			  E = Integer.parseInt(elements[3]);

			  list[A].add(new Pox(B,D,E));  
			  list[B].add(new Pox(A,D,E));
		      }

		  Queue<Eleac> que = new PriorityQueue<Eleac>();

		  que.offer(new Eleac(1,L,0)); //Eleac(id,money,the number of eemy)
		  used[1][L] = 0;		

		  int men = INF;
		  while(que.size() > 0)
		      {
			  Eleac p = que.poll(); 
			  int now = p.id;
			  int money = p.L;
			  int val = p.num;
			  
			  if(now == N)
			      {
				  used[now][money] = Math.min(used[now][money],val);	
				  continue;
			      }
		      
			 
			  for(int i=0;i<list[now].size();i++)
			      {
				  int need = list[now].get(i).D;

				  int new_pos = list[now].get(i).B;
				  int the_number = list[now].get(i).E;
				  
				  if(money-need >= 0 && used[new_pos][money-need] > val)
				      {
					  used[new_pos][money-need] = val;
					  que.add(new Eleac(new_pos,money-need,val));
				      }				  	
				  if(used[new_pos][money] > val+the_number)
				      {
					  used[new_pos][money] = val+the_number;
					  que.add(new Eleac(new_pos,money,val+the_number));
				      }

			      }

		      
		      }

		  for(int i=0;i<=L;i++)
		      {
			  men = Math.min(men,used[N][i]);
		      }
		  System.out.println(men);
	      }
      }

}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD = 1000000007;
using mint = Fp<MOD>;

int main() {
  int N; cin >> N;
  mint a = 1, b = 1, c = 1;
  REP(i, N) {
    a *= 10;
    b *= 9;
    c *= 8;
  }
  b *= 2;
  cout << a - b + c << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] spa = new int[3];
		int[] juice = new int[2];
		int a=2001;
		for(int i=0; i<3; i++){
			spa[i]=sc.nextInt();
		}
		for(int j=0; j<2; j++){
			juice[j]=sc.nextInt();
		}
		for(int i=0; i<3; i++){
			for(int j=0; j<1; j++){
				int work=spa[i]+juice[j];
				int work2=spa[i]+juice[j+1];
				if(work<work2){
					if(work<a){
						a=work;
					}
				}else if(work2<a){
					a=work2;
				}
			}
		}
		System.out.println(a-50);
		// TODO Auto-generated method stub

	}

}

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

int main(){
  int N;
  cin >> N;
  int AC = 0, WA = 0, TLE = 0, RE = 0;
  vector<string> array(N);
  for(int i=0; i < N; i++){
    cin >> array.at(i);
  } 
  
  for(int i=0; i < N; i++){
    if(array.at(i)=="AC")
      AC++;
    if(array.at(i)== "WA")
      WA++;
    if(array.at(i)== "TLE")
      TLE++;
    if(array.at(i)== "RE")
      RE++;
  }
  
  cout << "AC" << " " << "x" << " " << AC << endl;
  cout << "WA" << " " << "x" << " " << WA << endl;
  cout << "TLE" << " " << "x" << " " << TLE << endl;
  cout << "RE" << " " << "x" << " " << RE << endl;
  
  
  
}

Measured memory_bytes: 6428
#include<stdio.h>
 
int main(){
        int S,h,m,s;
 
        scanf("%d", &S);
 
        h = S / 3600;
        m = S % 3600 / 60;
        s = S % 3600 % 60;
 
        printf("%d:%d:%d\n", h, m, s);
 
        return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define ll long long
#define re register
#define cs const

cs int mod=1e9+7;
inline int add(int a,int b){a+=b-mod;return a+(a>>31&mod);}
inline int mul(int a,int b){ll r=(ll)a*b;return r>=mod?r%mod:r;}
cs int N=1e6+7;

int inv[N],inv3=(mod+1)/3;

int n,ans;
signed main(){
	scanf("%d",&n);inv[0]=inv[1]=1;
	for(int re i=2;i<=n;++i)inv[i]=mul(mod-mod/i,inv[mod%i]);
	int coef=inv[n];
	for(int re i=0;i<n;++i){
		coef=mul(coef,inv3);
		ans=add(ans,mul(coef,inv[n-i]));
	}
	std::cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4096
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
  ($line:expr, $name:ident, $t:tt) => {
    let $name = value!($line, $t);
  };
}

macro_rules! values_def {
  ($lines:expr, $n:expr, $name:ident, $t:tt) => {
    let $name = {
      let mut vec = Vec::new();
      for i in 0..$n {
        let mut next = $lines.next().unwrap().split_whitespace();
        vec.push(value!(next, $t));
      }
      vec
    };
  };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
  let mut input = String::new();
  io::stdin().read_to_string(&mut input).unwrap();
  let output = solve(input.trim().to_string());
  println!("{}", output);
}

fn solve(input: String) -> String {
  input!(input=>(a:i64 b:i64 c:i64));
  std::cmp::min(b / a, c).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "2 11 4\n" => "4\n",
    test2: "3 9 5\n" => "3\n",
    test3: "100 1 10\n" => "0\n",
}


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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}



int main(){
  int A,B;
  cin >> A >> B;
  set<int> s;
  s.insert(A);
  s.insert(B);
  for(int i = 1;i<=3;i++){
    if(!s.count(i)) cout << i << endl;
  }
 }

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

using namespace std;

int main() {
	int n, stu_s, stu_e, total = 0;
	cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> stu_s >> stu_e;
		total += (stu_e - stu_s + 1);
	}
	cout << total << endl;
}

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

int main(){
  int N,price[11],memo,ans=0;
  cin >> N;for(int i=0;i<N;i++)cin >> price[i];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if (price[i] <= price[j]){
        memo = price[i];price[i] = price[j];price[j]=memo;
      }
    }
  }
  for(int i=0;i<N;i++){
    if(i==N-1){
      ans += price[i]/2;
    }else{
    ans += price[i];
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256