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

#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)


using namespace std;
using ll = long long;

template<class T>
bool is_prime(const T n) {
    switch (n) {
        case 0: // fall-through
        case 1:
            return false;
        case 2: // fall-through
        case 3:
            return true;
    }

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


void solve() {
    int q;
    cin >> q;
    vector<int> vec(10e5 + 2);
    for (int i = 0; i < 10e5 + 2; ++i) {
        if (i % 2 == 0)continue;
        if (is_prime((i + 1) / 2) and is_prime(i))++vec[i];
    }
    for (int i = 1; i < 10e5 + 2; ++i) {
        vec[i] += vec[i - 1];
    }
    for (int j = 0; j < q; ++j) {
        int l, r;
        cin >> l >> r;
        cout << (vec[r + 1] - vec[l - 1]) << endl;
    }
}

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

    solve();
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  int max_h = 0, ans = 0;
  rep(i, N) {
    int a; in(a);
    if (max_h <= a)
      ++ans;
    max_h = max(max_h, a);
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var a,b int
  fmt.Scan(&a,&b)
  if a <= 0 && 0 <= b {
    fmt.Println("Zero")
  } else if a > 0 {
    fmt.Println("Positive")
  } else {
    if (b-a+1)%2 == 0 {
      fmt.Println("Positive")
    } else {
      fmt.Println("Negative")
    }
  }
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
  sort(A.begin(), A.end());
  ll x;
  bool f = true;
  if(N%2==1) {
    f = f and A[0]==0;
    x = 2;
    for(int i=1; i+1<N; i+=2) {
      f = f and A[i]==x and A[i+1]==x;
      x+=2;
    }
  } else {
    x = 1;
    for(int i=0; i+1<N; i+=2) {
      f = f and A[i]==x and A[i+1]==x;
      x+=2;
    }
  }
  if(f) {
    ll ans = 1;
    for(ll i = 1; i<=N/2; i++) {
      ans = (ll)(ans*2) % MOD;
    }
    std::cout << ans << std::endl;
  }

  else
    std::cout << 0 << std::endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#define int_inf 1000000000 //10**9
#define ll_inf 100000000000000000 //10**17

using namespace std;





int main(){
	int r, g;
	cin >> r >> g;
	
	cout << 2*g-r << endl;

	return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    string ans = "";
    for (char c : s) {
        switch (c) {
            case '0':
                ans += "0";
                break;
            case '1':
                ans += "1";
                break;
            case 'B':
                if (!ans.empty()) ans.pop_back();
                break;
        }
    }

    cout << ans;
}


Measured memory_bytes: 3576
#include<stdio.h>

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

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

int main(){
    ll N, W;  cin >> N >> W;
    vector<ll> w(N+1), v(N+1);
    for(int i=1; i<=N; i++) cin >> w[i] >> v[i];

    int maxVal =N*1000;
    vector<vector<ll>> dp;
    dp = vector<vector<ll>>(N+1, vector<ll>(maxVal+1, 1e15));
    dp[0][0] = 0;

    for(int i=1; i<=N; i++){
        for(int j=0; j<=maxVal; j++){
            if(v[i] <= j){
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    for(int i=maxVal; i>=0; i--){
        if(dp[N][i] <= W){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 80256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

constexpr int64_t kMaxNumberOfTowns = 200000;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a_jishin, b_funshin;
  int32_t hour, minute;
  cin >> a_jishin >> b_funshin >> hour >> minute;
  double rad_min = static_cast<double>(minute) / 60.0 * 2.0 * M_PI;
  double rad_hour = static_cast<double>(hour % 12) / 12 * 2.0 * M_PI;
  rad_hour += 2 * M_PI / 12.0 * static_cast<double>(minute) / 60.0;
  double hour_x = a_jishin * sin(rad_hour);
  double hour_y = a_jishin * cos(rad_hour);
  double min_x = b_funshin * sin(rad_min);
  double min_y = b_funshin * cos(rad_min);
  double delta_x = hour_x - min_x;
  double delta_y = hour_y - min_y;
  double d = sqrt(delta_x * delta_x + delta_y * delta_y);
  cout << setprecision(20) << d << endl;

  return 0;
}


Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  int N, A, B;
  cin >> N >> A >> B;
  
  if((A-B)%2==0){
    cout << "Alice";
  }else{
    cout << "Borys";
  }
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

const long long MOD = 1000000007;
const int MAX = 2000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void solve(long long x, long long y){
    COMinit();
    if((x+y)%3!=0){cout<<0<<endl;return;}
    cout<<COM((x+y)/3,y-(x+y)/3)<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 47104
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n, s; std::cin >> n >> s;
  std::vector<int> A(n); rep(i,n) std::cin >> A[i];

  constexpr int smax = 3010;
  
  const ll mod = 998244353;
  std::vector<ll> c(smax, 0);
  c[0] = 1;
  rep(i,n) {
    auto d = c;
    rep(j,smax) {
      c[j] *= 2;
      c[j] %= mod;
    }
    rep(j,smax) {
      //std::cout << j << " to " << j+A[i] << " : " << c[j+A[i]] << " + " << d[j] << std::endl;
      if ( j+A[i] > 3010 ) continue;
      c[j+A[i]] += d[j];
      c[j+A[i]] %= mod;
    }
    //std::cout << i << " : ";
    //rep(j,smax) std::cout << c[j] << " ";
    //std::cout << std::endl;
  }
  std::cout << c[s] << std::endl;
  return 0;
}



Measured memory_bytes: 3732
A,B,C=map(int,input().split())
ans=0
d=[]
a=A
b=B
c=C

while 1:
  if a%2!=0 or b%2!=0 or c%2!=0:
    print(ans)
    exit()
  if [a,b,c] in d:
    print(-1)
    exit()
  d.append([a,b,c])
  a1 = b//2 + c//2
  b1 = a//2 + c//2
  c1 = a//2 + b//2
  a=a1
  b=b1
  c=c1
  ans+=1

Measured memory_bytes: 3064
n,T = map(int,input().split())
ct = [0]*n
for i in range(n):
    ct[i] = list(map(int,input().split()))

ct.sort(key=lambda val : val[0])
ans = 0
for i in range(n):
    if ct[i][1] <= T:
        ans = ct[i][0]
        break
if ans == 0:
    print("TLE")
else:
    print(ans)

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

using namespace std;

long long x,y,a,b,c,k,nrx,nry,sum;
vector <long long> A,B,C;

int main() 
{
    cin>>x>>y>>a>>b>>c;
    for (long long i=0; i<a; i++)
    {
        cin>>k;
        A.push_back(k);
    }
    
    for (long long i=0; i<b; i++)
    {
        cin>>k;
        B.push_back(k);
    }
    
    for (long long i=0; i<c; i++)
    {
        cin>>k;
        C.push_back(k);
    }
    
    sort(A.rbegin(),A.rend());
    sort(B.rbegin(),B.rend());
    sort(C.rbegin(),C.rend());
    
    for (long long i=0; i<x; i++)
        C.push_back(A[i]);
        
    for (long long i=0; i<y; i++)
        C.push_back(B[i]);
        
    sort(C.rbegin(),C.rend());
    
    for (long long i=0; i<x+y; i++)
        sum+=C[i];
    
    cout<<sum;
}

Measured memory_bytes: 8048
#include <iostream>
#include <map>
#include<vector>
using namespace std;
int main(){
    int N;
    int counter=0;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<N;i++){
        if(a[i]==a[i+1]){
            counter++;
        }
    }
    if(counter>=1){
        cout<<"NO"<<endl;
        
    }else{
        cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
a,s[9999],t[9999];main(i,n,_){for(;n=~scanf("%d,%*d%*c%[\n]",&a,&_);n+2?i=0:0)i?s[a]++:s[a]&&t[a]++;for(;a=i<9999;i++)t[i]&&printf("%d %d\n",i,s[i]+t[i]);}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{

    int n;
    scanf("%d", &n);
    int i;
    int b, c;
    int N[110];
    for (i = 0; i < n; i++)
    {
        scanf("%d %d", &b,&c);
        if(b==c){
            N[i] = 1;
        }else
            N[i] = 0;
    }

    int Sum = 0;
    for (i = 0; i < n; i++)
    {

        if (N[i] == 1)
        {
            Sum++;
            if (Sum>=3){
                break;
            }
        }
        else
            Sum=0;
    
    }

    if (3<=Sum)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

    printf("\n");
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
 
int main () {
int64_t X;
  cin >> X;
  
  int64_t sum  = 100;
  int year = 0;
  while(sum < X){
  sum = sum*1.01;
    year++;
  }

  cout << year << endl;
}


Measured memory_bytes: 3632
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        s1: Chars,
        s2: Chars,
    }

    let m = 1000000007usize;

    let mut comb;
    let mut direction;

    if s1[0] == s2[0] {
        comb = 3;
        direction = Direction::Vertical;
    } else {
        comb = 6;
        direction = Direction::Horizontal;
    };

    let mut i = 1;
    if s1[0] != s2[0] {
        i = 2;
    }
    while i < n {
        if s1[i] == s2[i] {
            match direction {
                Direction::Horizontal => comb = comb * 1 % m,
                Direction::Vertical => comb = comb * 2 % m,
            }
            direction = Direction::Vertical;
        } else {
            match direction {
                Direction::Horizontal => comb = comb * 3 % m,
                Direction::Vertical => comb = comb * 2 % m,
            }
            i += 1;
            direction = Direction::Horizontal;
        }
        i += 1;
    }
    println!("{}", comb);
}

enum Direction {
    Vertical,
    Horizontal,
}


Measured memory_bytes: 2164
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int a,b;
    cin >> a >> b;
    cout << a*b << endl;
}

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


Measured memory_bytes: 3632
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k == X:
                count+=1
print(count)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string S;
    cin >> S;
    int N = (int)S.size();

    bool ok = true;
    for (int i = 0; i < N; i++) {
        if (S[i] != S[N - 1 - i]) {
            ok = false;
            break;
        }
    }

    for (int i = 0; i < (N - 1) / 2; i++) {
        if (S[i] != S[(N - 1) / 2 - 1 - i]) {
            ok = false;
            break;
        }
    }

    reverse(S.begin(), S.end());

    for (int i = 0; i < (N - 1) / 2; i++) {
        if (S[i] != S[(N - 1) / 2 - 1 - i]) {
            ok = false;
            break;
        }
    }

    cout << (ok ? "Yes\n" : "No\n");

    return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

#define rep(i, n) for(lli i = 0; i < (lli)(n); i++)

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
#define MAX_H 20
#define MAX_W 20
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

int h, w;
char maze[MAX_H][MAX_W];
int depth[MAX_H][MAX_W];

void init(){
    rep(i, h){
        rep(j, w){
            depth[i][j] = -1;
        }
    }
}

int bfs(int x, int y){
    queue<pair<int, int>> q;
    int md = 0;
    if(x < 0 || x >= h || y < 0 || y >= w || maze[x][y] == '#') return 0;
    q.push(make_pair(x, y));
    depth[x][y] = 0;
    while(!q.empty()){
        x = q.front().first;
        y = q.front().second;
        q.pop();
        rep(i, 4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w || maze[nx][ny] == '#') continue;
            if(depth[nx][ny] == -1){
                depth[nx][ny] = depth[x][y] + 1;
                md = max(depth[nx][ny], md);
                q.push(make_pair(nx, ny));
            }
        }
    }
    return md;
}
int main(void){
    cin >> h >> w;
    rep(i, h){
        rep(j, w){
            cin >> maze[i][j];
        }
    }
    int md = 0;
    rep(i, h){
        rep(j, w){
            if(maze[i][j] != '#'){
                init();
                md = max(md, bfs(i, j));
            }
        }
    }
    cout << md << endl;
    return 0;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define SZ(x)  (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 5e5 + 3;
const LL mod = 1e9 + 7;
char a[N];
int main() {
	ios::sync_with_stdio(false);
    cin>>a+1;
    int n=strlen(a+1);
    char x='D';
    for(int i=1;i<=n;i+=2){
        if(a[i]=='L')return cout<<"No\n",0;
    }
    x='D';
    for(int i=2;i<=n;i+=2){
        if(a[i]=='R')return cout<<"No\n",0;
    }
    cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
long int gcd(long int, long int);
int main(void) {
    long int a,b,c,d;
    scanf("%ld%ld%ld%ld",&a, &b, &c, &d);
    long int i;
    long int ac = (a-1)/c;
    long int ad = (a-1)/d;
    long int bc = b/c;
    long int bd = b/d;
    long int gcds = gcd(c,d);
    long int agcd = (a-1)/gcds;
    long int bgcd = b/gcds;
    long int ans = ((bc + bd)-(ac+ad))-(bgcd-agcd);
    long int sum = b-a+1-ans;
    printf("%ld\n",sum);

    return 0;
}
long int gcd(long int a, long int b) {
    long int tmp;
    long int x = a*b;
    if(a<b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    long int r;
    r = a%b;
    while(r!=0) {
        a = b;
        b = r;
        r = a%b;
    }
    return x/b;
}

Measured memory_bytes: 128
def solve():
    inf = 1 << 60
    D, G = map(int, input().split())
    p = []
    c = []
    for i in range(D):
        pi, ci = map(int, input().split())
        p.append(pi)
        c.append(ci)

    bitD = 1 << D
    min_cnt = inf
    for b in range(bitD):
        sc = 0
        cnt = 0
        for i in range(D):
            if (b & (1 << i)) != 0:
                sc += (i + 1) * 100 * p[i] + c[i]
                cnt += p[i]
        if sc < G:
            for i in range(D-1,-1,-1):
                if (b & (1 << i)) == 0:
                    unit = (i + 1) * 100
                    cnt2 = min((G - sc + (unit - 1)) // unit, p[i] - 1)
                    sc += cnt2 * unit
                    cnt += cnt2
                    break
        if sc >= G:
            min_cnt = min(min_cnt, cnt)

    return min_cnt

print(solve())


Measured memory_bytes: 40560
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
SA =[0]
SB =[0]
for i in range(len(A)):
  SA.append(SA[i] + A[i])
for j in range(len(B)):
  SB.append(SB[j] + B[j])

l = M
ans = 0
for k in range(N+1):
  if SA[k] > K:
    break
  while SA[k] + SB[l] > K:
    l -= 1
  ans = max(ans, k + l)
print(ans)

Measured memory_bytes: 47692
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int X, Y;
    cin >> X >> Y;
    if (X > Y)swap(X, Y);
    Y -= X;
    X = 0;
    if (Y <= 1) {
        cout << "Brown" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define LMAX 3005

using namespace std;

char s[LMAX];
char t[LMAX];
int d[LMAX][LMAX];
int ln1, ln2;
string ans;

void dp()
{
    for (int i=1;i<=ln1;++i)
    {
        for (int j=1;j<=ln2;++j)
        {
            if (s[i] == t[j])
            {
                d[i][j] = d[i-1][j-1] + 1;
            }
            else
            {
                d[i][j] = d[i-1][j];
                d[i][j] = max(d[i][j], d[i][j-1]);
            }
        }
    }

    int i = ln1;
    int j = ln2;
    while(i>=1&&j>=1)
    {
        if (s[i] == t[j])
        {
            ans.push_back(s[i]);
            --i, --j;
        }
        else
        if (d[i-1][j] > d[i][j-1])
        {
            --i;
        }
        else
        {
            --j;
        }
    }

    reverse(ans.begin(), ans.end());

    cout<<ans<<'\n';
}

int main()
{
    cin.getline(s+1, LMAX);
    cin.getline(t+1, LMAX);
    ln1 = strlen(s+1);
    ln2 = strlen(t+1);
    dp();
    return 0;
}


Measured memory_bytes: 35456
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

m = 10
a = [A, B, C, D, E]

for i in range(len(a)):

 if a[i] % 10 <= m and a[i] % 10 != 0:
     m = a[i] % 10


for j in range(len(a)):
  if a[j] % 10 != 0:
     a[j] = a[j] + (10 - a[j] % 10)

print(sum(a) - (10 - m))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  string N;
  cin >> N;
  
  string tmp = N;
  reverse(all(N));
  
  cout << (N == tmp ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int unused __attribute__((unused));
  int i, sum = 0;
  char N[200000];
  unused = scanf("%s", N);

  i = 0;
  while(N[i]!='\0'){
    sum += N[i]-48;
    i++;
  }
  if(sum%9==0) printf("Yes");
  else printf("No");

  return 0;
}

Measured memory_bytes: 1892
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << endl;}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
template<typename T>
T ncr(T left, T right) {
	right = min(left - right, right);
	T ans = 1;
	for (T i = 1; i <= right; i++) {
		ans = ans * (left - right + i) / i;
	}
	return ans;
}

const lli MOD = 1000000007;
const lli LIMIT = 10000000000000000 * 5;
const int tenfive = 100000;

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


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

int	main()
{
	int	N;
	int	cnt = 0;
	int	A;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A;
		if (A % 2 == 1)
			++cnt;
	}
	if (cnt % 2 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	map<string, int> mp;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		string inp;
		cin >> inp;
		mp[inp]++;
	}

	int beste = max_element(mp.begin(), mp.end(), [](const pair<string, int>& a, const pair<string, int>& b) {
		return a.se < b.se;
	})->se;
	for(auto el: mp)
		if(el.se == beste)
			cout << el.fi << '\n';
}


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

#define ll  long long int
#define ld  long double
#define MAX 1000001
#define MOD 1000000007
#define pi  3.14159265358979323846264338
#define mp  make_pair
#define pb  push_back
#define pll pair<ll,ll>
#define vl  vector<ll>
#define vi  vector<int>
#define vs  vector<string>
#define vc  vector<char>
#define fst first
#define sec second
#define foi(i, a, b)   for(ll i = a; i<b;i++)
#define fod(i, a, b)   for(ll i = a;i>=b;i--)
#define all(v)         (v).begin(), (v).end()
#define max3(a, b, c)  max(max(a,b), c)
#define min3(a, b, c)  min(min(a,b), c)
#define ump  unordered_map<ll,ll>
#define us   unordered_set<ll>
#define nl  "\n"
#define INF  (ll)1e18
#define s(v) (ll)(v).size()
#define e(v) (v).empty

using namespace std;

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


void solve(){
    int n;
    cin>>n;
    vector<int> h(n);
    foi(i,0,n) cin>>h[i];
    vector<int> dp(n,0);
    dp[1] = abs(h[0]-h[1]);
    foi(i,2,n){
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]) , dp[i-2] + abs(h[i]-h[i-2]) );
    }
    cout<<dp[n-1]<<"\n";
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<ll>> dp(n + 1, vector<ll>(13, 0));
    // 0 % 13 = 0 をカウントする
    dp[0][0] = 1;
    REP(i, n) {
        char c = s[i];
        REP(j, 10) {
            if (c == '?' || c - '0' == j) {
                REP(k, 13) {
                    dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                }
            }
        }
        REP(j, 13) {
            dp[i + 1][j] %= MOD;
        }
    }

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


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
typedef vector<string> vs;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
const ll MOD=1000000007;
const ll mod=998244353;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	ll a,b,c,d,n;
	cin>>a>>b>>c>>d>>n;
	c=min(c,min(a*4,b*2));
	d=min(d,c*2);
	cout<<n/2*d+(n%2)*c;
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3572
import collections

#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s

#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a

def main():
	n = input()
	a = list(map(int,input().split()))
	c = collections.Counter(a)
	cntRem = 0

	for key, val in c.items():
		if key < val:
			cntRem+= val - key
		elif key > val:
			cntRem+= val
	print(cntRem)

if __name__=='__main__':
    main()

Measured memory_bytes: 18676
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int height, width, hpos, wpos;

		for(;;){
			height = scanner.nextInt();
			width = scanner.nextInt();
			if(height == 0||width == 0) break;

			String[] mark = new String[height];

			for(int i = 0; i < height; i++){
				mark[i] = scanner.next();
			}

			hpos = wpos = 0;
			for(int i = 0;; i++){
				if(i == (height * width)){
					System.out.println("LOOP");
					break;
				}else if(mark[hpos].charAt(wpos) == '>'){
					wpos++;
				}else if(mark[hpos].charAt(wpos) == '<'){
					wpos--;
				}else if(mark[hpos].charAt(wpos) == '^'){
					hpos--;
				}else if(mark[hpos].charAt(wpos) == 'v'){
					hpos++;
				}else if (mark[hpos].charAt(wpos) == '.'){
					System.out.printf("%d %d\n", wpos, hpos);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
s = input().rstrip()

gc = 0
pc = 0
ts = 0
ds = 0
for si in s:
    if si == 'g':
        if pc < gc:
            ds += 1
            pc += 1
        else:
            gc += 1
    else:
        if pc < gc:
            pc += 1
        else:
            gc += 1
            ts += 1

print(ds - ts)

Measured memory_bytes: 3316
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    double maxV = -1e20;
    long long ansF = 0;
    long long ansS = 0;

    for (int a = 0; a <= 30; a++) {
        for (int b = 0; b <= 30; b++) {
            long long water = 100 * A * a + 100 * B * b;
            for (int c = 0; c <= 1600; c++) {
                for (int d = 0; d <= 1600; d++) {
                    long long sugar = C * c + D * d;
                    if (water + sugar > F) break;
                    double per = (((double) 100 * sugar) / ((double) (water + sugar)));
                    if (per > maxV && sugar <= (water / 100 * E)) {
                        maxV = per;
                        ansF = water + sugar;
                        ansS = sugar;
                    }
                }
            }
        }
    }

    cout << ansF << " " << ansS << endl;

    return 0;
}




















































































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mul(ll a, ll b){
    // return ((a%mod) * (b%mod))%mod;
    return a*b;
}
ll power(ll a, ll b){
    ll z = 1; ll x = a;
    while(b>0){
        if (b&1)z = mul(z, x);
        x = mul(x, x);
        b >>= 1;
    }
    return z;
}
int main()
{
    ll n; cin>>n;
    vector<ll> pos, neg;
    ll x = 1, ans = 0;
    for (int i=0; i<20 ;i++){
        ans += x;
        x*=4;
        pos.push_back(ans);
    }
    x = 2, ans = 0;
    for (int i=0; i<20; i++){
        ans += x;
        x*=4;
        neg.push_back(ans);
    }
    vector<ll> res(60);
    ll req = n;
    while(req != 0){
        if (req > 0){
            ll idx = lower_bound(pos.begin(), pos.end(), req) - pos.begin();
            res[2*idx] = 1;
            req -= power(2, 2*idx);
        }
        else{
            ll idx = lower_bound(neg.begin(), neg.end(), abs(req)) - neg.begin();
            res[2*idx+1] = 1;
            req += power(2, 2*idx+1);
        }
    }
    ll e;
    for (int i=59; i>=0; i--)if (res[i]==1){
        e = i;break;
    }
    for (int i=e; i>=0; i--)cout<<res[i];
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>

using namespace std;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };

int main(void)
{
    int num;
    cin >> num;

    int t[100001];
    int x[100001];
    int y[100001];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (int i = 0; i < num; i++)
    {
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }

    bool flag = true;
    for (int i = 0; i < num; i++)
    {
        // 最低移動回数
        int d_min = (x[i + 1] - x[i]) + (y[i + 1] - y[i]);

        // 使用する移動回数
        int d_use = t[i + 1] - t[i];

        int deff = d_use - d_min;

        // そもそも移動回数が足りない
        if (deff < 0)
        {
            flag = false;
            break;
        }

        if (deff % 2 == 0)
        {
            flag = true;
        }
        else
        {
            flag = false;
            break;
        }
    }

    if (flag)
    {
        sayYes();
    }
    else
    {
        sayNo();
    }
    return 0;
}

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

int get(int n){
  int sum = 0;
  while(n>0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  int sum = get(N);
  if(N % sum == 0){
    puts("Yes");
  }
  else{
    puts("No");
  }
}


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

const int MAX_S = 8e3;
char s[MAX_S + 1];
int x, y;

vector<int> xf, yf;
vector<int> xl, yl;
bool jdx[MAX_S][2 * MAX_S + 1];
bool jdy[MAX_S][2 * MAX_S + 1];

int main() {
    scanf("%s", s);
    scanf("%d %d", &x, &y);
    int l = strlen(s);
    int ofs = 0;
    if (s[0] == 'F') {
        for (int i = 0; s[i] == 'F'; i++) ofs++;
    }
    x -= ofs;
    bool judge = true;
    int cnt = 0;
    for (int i = ofs; i < l; i++) {
        if (s[i] == 'T') {
            if (judge) {
                if (cnt > 0) {
                    xf.push_back(cnt);
                    cnt = 0;
                }
                judge = false;
            }
            else {
                if (cnt > 0) {
                    yf.push_back(cnt);
                    cnt = 0;
                }
                judge = true;
            }
        }
        else cnt++;
    }
    if (cnt > 0) {
        if (judge) xf.push_back(cnt);
        else yf.push_back(cnt);
    }
    
    xl.push_back(0);
    yl.push_back(0);
    for (int i = 0, n = xf.size(); i < n; i++) {
        for (auto &j : xl) {
            jdx[i][j + xf[i]+ MAX_S] = true;
            jdx[i][j - xf[i] + MAX_S] = true;
        }
        xl.clear();
        for (int j = 0; j <= MAX_S * 2; j++) {
            if (jdx[i][j]) xl.push_back(j - MAX_S);
        }
    }
    for (int i = 0, n = yf.size(); i < n; i++) {
        for (auto &j : yl) {
            jdy[i][j + yf[i] + MAX_S] = true;
            jdy[i][j - yf[i] + MAX_S] = true;
        }
        yl.clear();
        for (int j = 0; j <= MAX_S * 2; j++) {
            if (jdy[i][j]) yl.push_back(j - MAX_S);
        }
    }
    
    sort(xl.begin(), xl.end());
    sort(yl.begin(), yl.end());
    vector<int>::iterator itx = lower_bound(xl.begin(), xl.end(), x);
    vector<int>::iterator ity = lower_bound(yl.begin(), yl.end(), y);
    if (itx != xl.end() && *itx == x && ity != yl.end() && *ity == y) {
        printf("Yes\n");
    }
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 64384
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a,g):
    global cnt
    for i in range(g,len(a)):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt+=1
            a[j+g] = v


def shellSort(a):
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= len(a):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(a,g[i])


a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)

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

#define LIMIT 20

struct Puzzle {
  int cont[25];
  int space[2];
};

int limit;

Puzzle puzzle;

int tx[12]={0,1,2,3,0,1,2,3,4,1,2,3};
int ty[12]={0,1,1,1,2,2,2,2,2,3,3,3};
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};

int heuris[12][25];

int getHeuristic(){
  int res=0;
  for(int i=0;i<25;i++){
    if(puzzle.cont[i]==-1||puzzle.cont[i]==0)continue;
    res+=heuris[puzzle.cont[i]][i];
  }
  return res;
}

bool dfs(int depth,int prev0,int prev1){
  
  int heuri;
  heuri=getHeuristic();
  /*
  cout<<depth<<' '<<heuri<<endl;
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(puzzle.cont[i*5+j]!=-1)printf("%3d",puzzle.cont[i*5+j]);
      else cout<<"???";
    }
    cout<<endl;
  }
  */
  if(heuri==0){
    cout<<depth<<endl;
    return true;
  }
  if(depth + heuri>limit)return false;

  int px,py,nx,ny;
  Puzzle tmp=puzzle;

  py=puzzle.space[0]/5;
  px=puzzle.space[0]%5;
  for(int i=0;i<4;i++){
    if(max(prev0,i)-min(prev0,i)==2)continue;
    ny=py+dy[i];nx=px+dx[i];
    if(ny<0||ny>=5||nx<0||nx>=5)continue;
    if(puzzle.cont[ny*5+nx]==-1)continue;
    if(puzzle.cont[ny*5+nx]==0)continue;
    puzzle.cont[py*5+px]=puzzle.cont[ny*5+nx];
    puzzle.cont[ny*5+nx]=0;
    puzzle.space[0]=ny*5+nx;
    if(dfs(depth+1,i,-100))return true;
    puzzle=tmp;
  }

  py=puzzle.space[1]/5;
  px=puzzle.space[1]%5;
  for(int i=0;i<4;i++){
    if(max(prev1,i)-min(prev1,i)==2)continue;
    ny=py+dy[i];nx=px+dx[i];
    if(ny<0||ny>=5||nx<0||nx>=5)continue;
    if(puzzle.cont[ny*5+nx]==-1)continue;
    if(puzzle.cont[ny*5+nx]==0)continue;
    puzzle.cont[py*5+px]=puzzle.cont[ny*5+nx];
    puzzle.cont[ny*5+nx]=0;
    puzzle.space[1]=ny*5+nx;
    if(dfs(depth+1,-100,i))return true;
    puzzle=tmp;
  }
  return false;
}

void solve(){
  Puzzle tmp=puzzle;
  for(limit=getHeuristic();limit<=LIMIT;limit++){
    puzzle=tmp;
    if(dfs(0,-100,-100))return;
  }
  cout<<"NA"<<endl;
}

int main(){
  int x,y,c=0;

  for(int i=1;i<=11;i++){
    for(int j=0;j<25;j++){
      y=j/5;
      x=j%5;
      heuris[i][j]=abs(tx[i]-x)+abs(ty[i]-y);
    }
  }
  /*
  for(int i=1;i<=11;i++){
    for(int j=0;j<5;j++){
      for(int k=0;k<5;k++){
	cout<<heuris[i][j*5+k]<<' ';
      }
      cout<<endl;
    }
    cout<<endl;
  }
  */


  while(1){
    c=0;
    for(int i=0;i<25;i++)puzzle.cont[i]=-1;

    cin>>puzzle.cont[2];
    if(puzzle.cont[2]==-1)break;
    if(puzzle.cont[2]==0)puzzle.space[c++]=2;
    
    
    for(int i=6;i<=8;i++){
      cin>>puzzle.cont[i];
      if(puzzle.cont[i]==0)puzzle.space[c++]=i;
    }
    for(int i=10;i<=14;i++){
      cin>>puzzle.cont[i];
      if(puzzle.cont[i]==0)puzzle.space[c++]=i;
    }
    
    for(int i=16;i<=18;i++){
      cin>>puzzle.cont[i];
      if(puzzle.cont[i]==0)puzzle.space[c++]=i;
    }
    
    cin>>puzzle.cont[22];
    if(puzzle.cont[22]==0)puzzle.space[c++]=22;
    solve();
  }

  return 0;
}

Measured memory_bytes: 1164
using System;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int i; (i = int.Parse(Console.ReadLine())) != 0; Console.WriteLine((int)Enumerable.Range(0, i).Select(q => int.Parse(Console.ReadLine())).OrderBy(q => q).Skip(1).Take(i - 2).Average()));
        }
    }
}

Measured memory_bytes: 6444
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static class Key{
		int price;
		int pattern;
		Key(int pr , int pa){
			price = pr;
			pattern = pa;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Key keys[] = new Key[M];
		for(int i = 0 ; i < M ; ++i){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int pat = 0;
			for(int j = 0 ; j < b ; ++j){
				int c = sc.nextInt();
				c = c - 1;
				int p = 1 << c;
				pat |= p;
			}
//			System.out.println(pat);
			keys[i] = new Key(a, pat);
		}
		int dp[] = new int[(1 << N) + 1];
		int MAX = 1000000000;
		Arrays.fill(dp, MAX);
		dp[0] = 0;
		for(Key key : keys){
			int next[] = dp.clone();
			for(int i = 0 ; i < dp.length ; ++i){
				if(dp[i] == MAX){
					continue;
				}
				int np = i | key.pattern;
				int ncost = dp[i] + key.price;
//				System.out.println(i+" "+np+" "+ncost);				
				next[np] = Math.min(dp[i] + key.price, next[np]);
			}
			dp = next;
//			System.out.println(Arrays.toString(dp));
		}
//		System.out.println(Arrays.toString(dp));
		int ri = (1 << N) -1;
		if(dp[ri] == MAX){
			System.out.println(-1);
		}else{
			System.out.println(dp[ri]);
		}
	}
}


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

int main(){
    char s[99];
    scanf("%s",s);
    int n = strlen(s);
    for(int i = 0;i < n / 2;i++){
        if(s[i] == s[n - i - 1] && s[i] == s[((n - 1) / 2) - i - 1] && s[n - i - 1] == s[((n + 3) / 2) + i - 1]) continue;
        printf("No");
        return 0;
    }
    printf("Yes");
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    char b;
    cin >> b;
    if(b == 'A') cout << "T" << endl;
    else if(b == 'T') cout << 'A' << endl;
    else if(b == 'G') cout << 'C' << endl;
    else if(b == 'C') cout << 'G' << endl; 

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip> // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main()
{
    double N;
    cin >> N;

    double oddNum;

    if ((int)N % 2 == 0) {
        oddNum = N / 2.0;
    } else {
        oddNum = (N+1.0) / 2.0;
    }

    cout << oddNum / N << endl;
    return 0;
}

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

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            String X = in.next();
            String Y = in.next();
            String ans = "=";
            int compare = X.compareTo(Y);
            if (compare < 0) ans = "<";
            else if (compare > 0) ans = ">";
            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 21332