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

#define ll long long
#define INF 1000000000000000

typedef pair<ll, int> pi;
typedef vector<vector<int>> vv;

/********************************
  dijkstra
   - dist:  グラフの枝（隣接行列）
   - s:     出発点
   - n:     頂点数
********************************/
vector<ll> dijkstra(vector<vector<pi>> dist, int s, int n) {
    vector<ll> cost(n, INF); //sから各枝への最小コスト
    for (int i = 0; i < n; i++) {
        cost[i] = INF;
    }
    
    for (int i = 0; i < dist[s].size(); i++){
        cost[dist[s][i].first] = dist[s][i].second;
    }
    cost[s] = 0;

    priority_queue<pi, vector<pi>, greater<pi>> pq; //ヒープ　各ノードの型は <cost, vartex_num>
    //全ての頂点をヒープに入れる
    for(int i = 0; i < n; i++) {
        if(i == s)continue;
        pq.push(make_pair(cost[i], i));
    }

    while (!pq.empty()) {
        pi min_v = pq.top(); //コスト最小のノード
        pq.pop();

        // cout << "min_v:" << min_v.first << " " << min_v.second << endl;
        //     cout << "cost:" << endl;
        // for(int i = 0; i < n; i++) {
        //     cout << cost[i] << " ";
        // }
        // cout << endl;

        int w = min_v.second;
        if (cost[w] < min_v.first) continue; //更新済みのノードのため無視

        //cout << "size:" << dist[w].size() << endl;
        for (int i = 0; i < dist[w].size(); i++) {
            int k = dist[w][i].first; //見ているノードの番号
            //cout << cost[w] << " " << dist[w][i].second << " " << cost[k] << endl;
            
            if(cost[w] + dist[w][i].second < cost[k]){
                cost[k] = cost[w] + dist[w][i].second;
                pq.push(make_pair(cost[k], k));  //元々あるノードは無視してとりあえずヒープに入れておく
            }
        }
    }
    return cost;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;

    int u[m], v[m], a[m], b[m];
    for (int i = 0; i < m; i++) {
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--;
        v[i]--;
    }
    
    //隣接行列
    vector<vector<pi>> dist_a(n); // <node_num, cost>
    vector<vector<pi>> dist_b(n);

    for(int i = 0; i < m; i++) {
        dist_a[u[i]].push_back({v[i], a[i]});
        dist_b[u[i]].push_back({v[i], b[i]});
        dist_a[v[i]].push_back({u[i], a[i]});
        dist_b[v[i]].push_back({u[i], b[i]});
    }

    // for(int i = 0; i < n; i++) {
    //     cout << "dist[" << i << "]" << endl;
    //     for(int j = 0; j < dist_a[i].size(); j++) {
    //         cout << dist_a[i][j].first << " " << dist_a[i][j].second << endl;
    //     }
    // }

    vector<ll> cost_a = dijkstra(dist_a, s, n);
    vector<ll> cost_b = dijkstra(dist_b, t, n);

    vector<ll> cost_sum(n);
    for(int i = 0; i < n; i++) {
        cost_sum[i] = cost_a[i] + cost_b[i];
    }

    ll M = 1000000000000000;

    ll min_array[n];

    min_array[n-1] = cost_sum[n-1];
    for(int i = n-2; i >= 0; i--) {
        if(min_array[i+1] > cost_sum[i]){
            min_array[i] = cost_sum[i];
        }else{
            min_array[i] = min_array[i+1];
        }
    }

    for(int i=0; i<n;i++){
        cout << M - min_array[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 31792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N, K;
    cin >> N;
    cin >> K;
    int now = 1;

    for (int i=0; i<N; i++){
        if (2*now <= now+K)now *= 2;
        else now += K;
    }
    cout << now << endl;
}

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

int main() {
    string s;
    cin>>s;
    int n = s.size();
    ll ans = 0;
    int m = 2019;
    reverse(s.begin(), s.end());
    vector<int> cnt(m);
    int x = 1, tot = 0;
    rep(i,n){
        cnt[tot]++;
        tot += (s[i]-'0')*x;
        tot %= m;
        ans += cnt[tot];
        x = x * 10 % m;
    } 
    cout<<ans<<endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=20;
int n,a[N],b[N];
struct node
{
    int x,p;
    node(int x=0,int p=0):x(x),p(p){}
}c[N];
int d[N];
int solve(int x)
{
    for(int i=0;i<n;i++)
        if(x>>i&1)
            c[i+1]=node(b[i+1],1),d[i+1]=b[i+1];
        else
            c[i+1]=node(a[i+1],0),d[i+1]=a[i+1];
    sort(d+1,d+1+n);
    int ans=0;
    for(int i=n;i>=1;i--)
    {
        bool flag=false;
        for(int j=i;j>=1;j--)
            if(c[j].x==d[i]&&c[j].p==(i-j&1))
        {
            flag=true;
            ans+=i-j;
            for(int k=j;k<i;k++)
            {
                c[k+1].p^=1;
                swap(c[k],c[k+1]);
            }
            break;
        }
        if(!flag) return inf;
    }
    return ans;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) scanf("%d",&b[i]);
    int ans=inf;
    for(int i=0;i<1<<n;i++)
        ans=min(ans,solve(i));
    if(ans==inf) ans=-1;
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    vector<ll> x(3);
    REP(i, 3) cin >> x[i];
    sort(x.begin(), x.end());

    ll P = x[2] - x[0];
    ll Q = x[2] - x[1];

    dump(P)
    dump(Q)

    ll res = 0;
    res += P/2;
    res += Q/2;

    if(P%2==1 and Q%2==1){
        res += 1;
    }else if(P%2==0 and Q%2==0){
        res += 0;
    }else{
        res += 2;
    }
    cout << res << endl;

    return 0;
}

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

int main()
{
    int N, a, d, M;
    std::cin >> N >> a >> d >> M;

    std::vector<int> x(M), y(M), z(M);
    for (int i = 0; i < M; i++) {
        std::cin >> x[i] >> y[i] >> z[i];
        y[i]--; z[i]--;
    }
    
    int K;
    std::cin >> K; K--;
   
    for (int i = M - 1; i >= 0; i--) {
        if (x[i] == 0) {            
            if (y[i] == K) {
                K = z[i];
            } else if (z[i] == K) {
                K = y[i];
            }
        } else {
            if (y[i] == K) {
                K = z[i];
            }
        }
    }

    std::cout << a + K * d << std::endl;
    
    return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;

vector<long long> vec[100000+3];
long long cnt=0,mx=INT_MIN,ans=INT_MIN;
long long count1[100000+3];

long long dfs2(long long u, long long vertex)
{
    for(long long i=0; i<vec[u].size(); i++)
    {
        long long v=vec[u][i];
        if(count1[v]==-1)
        {
            count1[u]=max(1+dfs2(v,vertex), count1[u]);
        }
        else
        {
            count1[u]=max(1+count1[v], count1[u]);
        }
    }
    if(vec[u].size()==0)
    {
        count1[u]=0;
        return count1[u];
    }
    else
    {
        return count1[u];
    }
}

void dfs(long long vertex, long long n)
{
    cnt=0;
    mx=INT_MIN;
    if(count1[n]==-1)
    {
        mx=dfs2(n,vertex);
    }
    else
    {
        mx=count1[n];
    }
    if(mx>ans)
    {
        ans=mx;
    }
}

int main()
{
    fastio;
    long long vertex,edge,i,x,y;
    cin>>vertex>>edge;
    memset(count1,-1,sizeof(count1));
    for(i=0; i<edge; i++)
    {
        cin>>x>>y;
        vec[x].push_back(y);
    }
    for(i=1; i<=vertex; i++)
    {
        dfs(vertex,i);
    }
    cout<<ans;
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

int main() {
  
    char S[3];

    rep(i, 3) {
        cin >> S[i];
    }

    if (S[0] == S[1] && S[1] == S[2]) {
        cout << "No" << endl;

    }

    else {
        cout << "Yes" << endl;
    }
    return 0;

    
    }
    
    


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n,k;
    int h[100010];
    int dp[100010];
    cin>>n>>k;
    for(int i=0;i<=n;i++){
        dp[i] = 0;
    }
    for(int j=0;j<n;j++){
        cin>>h[j];
    }
    for(int i=1;i<n;i++){
        dp[i] = dp[i-1] + abs(h[i-1]-h[i]);
        for(int j=1;j<=min(i,k);j++){
            dp[i] = min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


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

char check(vector<vector<char>> &mine,int i,int j,int a,int b){
  int count=0;
  if(i>0){
    if(mine.at(i-1).at(j)=='#')
      count++;
    if(j>0&&mine.at(i-1).at(j-1)=='#')
      count++;
    if(j<b&&mine.at(i-1).at(j+1)=='#')
      count++;
  }
  if(i<a){
    if(mine.at(i+1).at(j)=='#')
      count++;
    if(j>0&&mine.at(i+1).at(j-1)=='#')
      count++;
    if(j<b&&mine.at(i+1).at(j+1)=='#')
      count++;
  }
  if(j>0&&mine.at(i).at(j-1)=='#')
    count++;
  if(j<b&&mine.at(i).at(j+1)=='#')
    count++;
  char sum ='0'+count ;
  return sum;
}

int main(){
  int a,b;
  cin>>a>>b;
  vector<vector<char>> mine(a,vector<char>(b));
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cin>>mine.at(i).at(j);
    }
  }
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      if(mine.at(i).at(j)=='.')
        mine.at(i).at(j)=check(mine,i,j,a-1,b-1);
    }
  }
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cout<<mine.at(i).at(j);
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1000000007
using namespace std;
vector<int>w[100009];
int main()
{
    int n,k,num[100009],v[100009];
    long long ans;
    queue<int>q;
    scanf("%d%d",&n,&k);
    ans=k;
    memset(v,0,sizeof(v));
    for(int i=0; i<n-1; i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        w[x].push_back(y);
        w[y].push_back(x);
    }
    q.push(1);
    v[1]=1;
    num[1]=0;
    while(!q.empty())
    {
        int tmp=q.front();
        q.pop();
        int cnt=0;
        for(int i=0; i<w[tmp].size(); i++)
        {
            if(!v[w[tmp][i]])
            {
                v[w[tmp][i]]=1;
                num[w[tmp][i]]=num[tmp]+1;
                if(num[tmp]<2)
                    ans=(ans*(k-num[tmp]-1-cnt))%inf;
                else
                    ans=(ans*(k-2-cnt))%inf;
                q.push(w[tmp][i]);
                cnt++;
            }
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 7288
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	cin >> n;
	int sum;
	map<int, int>mp;
	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			for (int k = 1; k <= 100; k++) {
				sum = i * i + j * j + k * k + i * j + i * k + j * k;
				mp[sum]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << mp[i] << endl;
	}
}


Measured memory_bytes: 5408
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <climits>

using namespace std;

typedef long long ll;

ll a[200005];
ll sum[200005];

int main(){

	int N;
	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
	scanf(" %lld",&a[i]);
	sum[i]=a[i];
	}

	for(i=1;i<N;i++){
	sum[i]+=sum[i-1];
	}

	ll ans=LLONG_MAX;

	for(i=0;i<=N-2;i++){
	ll x=sum[i];
	ll y=sum[N-1]-x;
	ans=min(ans,llabs(x-y));
	}

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

	return 0;
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline
import numpy as np

n, m = map(int, input().split())

T_Height = [int(h) for h in input().split()]

Roads = [0] * n

for i in range(m):
    a, b = map(int, input().split())
    b_h = T_Height[b-1]
    a_h = T_Height[a-1]
    if b_h > Roads[a-1]:
        Roads[a-1] = b_h
    if a_h > Roads[b-1]:
        Roads[b-1] = a_h


i = 0
ans = 0
for e in Roads:
    if T_Height[i] > e:
        ans += 1
    i+=1

print(ans)


Measured memory_bytes: 38664
k,n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
arr = []
(1...n).each do |i|
  arr << a[i] - a[i-1]
end
if a[0] == 0
  arr << k - a[n-1]
else
  arr << k -a[n-1] + a[0]
end
sum = arr.inject(:+) - arr.max
puts sum

Measured memory_bytes: 17028
/***
 ** "Never Forget What you are,the rest of the world will not.Wear it like armour and it can never be used to hurt you"
 **     -- Tyrion Lannister
***/

/**
  *  Author: dhruv_gheewala
  *  Date:   28.03.2020
  *  Time:   17:36:04
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 7
    #define o(str) 42
    #define fundri 108
    #define d(...) 1729
#endif


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

const bool testcases = 0;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(),s.end()
#define test int __T__=1;if(testcases)cin>>__T__;while(__T__--)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define make_unique(vec) sort(all(vec));vec.erase(unique(all(vec)),vec.end())
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

ll seed;auto random_address=[]{char *p=new char;delete p;return (uint64_t)p;};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()*(random_address()|1));
inline int rnd(int l=0,int r=INT_MAX){return uniform_int_distribution<int>(l,r)(rng);}

template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}

template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a)
{in>>a.ff>>a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a)
{for(auto &x : a)in>>x;return in;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}

int main()
{
    std::chrono::time_point<std::chrono::high_resolution_clock> start_time, end_time;
    start_time = std::chrono::high_resolution_clock::now();

    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","w",stderr);
    #endif
    
    fast;
    int x;
    test{

    cin>>x;
    ll ans=0;
    ans += floor(x/500)*1000;
    x%=500;

    ans += floor(x/5)*5;
    cout<<ans<<endl;

    fundri;
    }

    end_time = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
    o("\n\n======\n");
    if(elapsed_time<10000)
        o("Elapsed Time: "<<elapsed_time<<" ms\n");
    else
        o("Elapsed Time: "<<elapsed_time/1000<<" s\n");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#if 0
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif

int main(){
	int n;
	string s;
	cin >> n >> s;
	for(int i=0; i<s.size(); ++i){
		cout << (char)((s[i] - 'A' + n) % 26 + 'A');
	}

	return 0;
}


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

using namespace std;

struct skrr {
  int a, b, i;
  bool operator < (const skrr &x) const {
    if (a == x.a)
      return b < x.b;
    return a < x.a;
  }
} p[200002];
int n, k, l, nr, viz[200002], ans[200002];
vector<int>G[200002];
vector<int>G1[200002];

void dfs (int x, int val) {
  p[x].a = val;
  viz[x] = 1;
  for (auto it : G[x])
    if (!viz[it])
      dfs(it, val);
}

void dfs1 (int x, int val) {
  p[x].b = val;
  viz[x] = 1;
  for (auto it : G1[x])
    if (!viz[it])
      dfs1(it, val);
}

int main()
{
  cin >> n >> k >> l;
  for (int i = 1; i <= k; i++) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= l; i++) {
    int x, y;
    cin >> x >> y;
    G1[x].push_back(y);
    G1[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    p[i].i = i;
  for (int i = 1; i <= n; i++) {
    if (!viz[i])
      dfs(i, ++nr);
  }
  memset(viz, 0, sizeof(viz));
  nr = 0;
   for (int i = 1; i <= n; i++) {
    if (!viz[i])
      dfs1(i, ++nr);
  }
  sort(p + 1, p + n + 1);
  int l = 1;
  for (int i = 1; i <= n; i++) {
    if (p[i].a == p[i + 1].a && p[i].b == p[i + 1].b)
      l++;
    else {
      for (int j = i; j >= i - l + 1; j--)
        ans[p[j].i] += l - 1;
      l = 1;
    }
  }
  for (int i = 1; i <= n; i++)
    cout << ans[i] + 1<< " ";
  return 0;
}


Measured memory_bytes: 20480
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 998244353
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll a,b;cin>>a>>b;
    if(a<=0&&b>=0){
        cout<<"Zero"<<endl;
        return 0;
    }
    ll cnt=0;
    if(b>0&&a>0){
        cout<<"Positive"<<endl;
        return 0;
    }
    b*=-1;a*=-1;
    cnt=b-a+1;
    if(cnt%2==0){
        cout<<"Positive"<<Endl;
    }
    else cout<<"Negative"<<Endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

bool solve(vector<int> a,int l,int r,int p,int ls,int yuki,int teki){
  //cout<<l<<" "<<r<<" "<<p<<endl;
  if(yuki==6) return true;
  if(teki==6) return false;
  if(p==0){
    if(ls==0){
      if(a[l]==0) return solve(a,l-1,r,1,ls,yuki+1,teki);
      else if(a[r]==0) return solve(a,l,r+1,1,ls,yuki+1,teki);
      else return solve(a,l,r,1,ls,yuki,teki);
    }else{
      if(a[r]==0) return solve(a,l,r+1,1,ls,yuki+1,teki);
      else if(a[l]==0) return solve(a,l-1,r,1,ls,yuki+1,teki);
      else return solve(a,l,r,1,ls,yuki,teki);
    }
  }else{
     if(ls!=0){
      if(a[l]==1) return solve(a,l-1,r,0,ls,yuki,teki+1);
      else if(a[r]==1) return solve(a,l,r+1,0,ls,yuki,teki+1);
      else return solve(a,l,r,0,ls,yuki,teki);
    }else{
      if(a[r]==1) return solve(a,l,r+1,0,ls,yuki,teki+1);
      else if(a[l]==1) return solve(a,l-1,r,0,ls,yuki,teki+1);
      else return solve(a,l,r,0,ls,yuki,teki);
    }
  }
}
    

signed main(){
  cin.tie(0);	
  // ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a;
  rep(i,n){
    vector<int> vv={-1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1};
    rep(j,6){
      cin>>a;
      vv[a]=0;
    }
    if(vv[1]==vv[13]){
      if(vv[1]==0) cout<<"no"<<endl;
      else cout<<"yes"<<endl;
    }else{
      // cout<<"?"<<endl;
      if(vv[1]==0){
	if(solve(vv,6,8,0,0,0,0)) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
      }else{
	if(solve(vv,6,8,0,1,0,0)) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
      }
    }
  }
  
    

  return 0;
}



Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		double n = sc.nextDouble();
		double x = sc.nextDouble();
		int t = sc.nextInt();

		System.out.println((int)Math.ceil(n / x) * t);

	}


}

Measured memory_bytes: 37432
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;
const int INF = numeric_limits<int>::max() / 2;

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

    int w,h;
    while(cin>>w>>h,w||h){
        vector< vector<int> > dis(1000,vector<int>(1000,0));
        for(int i=0;i<1000;i++){
            dis[i][i]=0;
        }
        for(int i=0;i<2*h-1;i++){
            if(i%2==0){// ?¨??£?
                for(int j=0;j<w-1;j++){
                    int k;cin>>k;
                    int y=j,x=i/2;
                    if(k) continue;
                    dis[x*w+y][x*w+y+1]=dis[x*w+y+1][x*w+y]=1;
                }
            }
            else{
                for(int j=0;j<w;j++){
                    int k;cin>>k;
                    int y=j,x=i/2;
                    if(k) continue;
                    dis[x*w+y][x*w+y+w]=dis[x*w+y+w][x*w+y]=1;
                }
            }
        }
        int pt=w*h;
        /* TLE?§£
        for(int k=0;k<p;k++){
            for(int i=0;i<p;i++){
                for(int j=0;j<p;j++){
                    dis[i][j]=min(dis[i][k]+dis[k][j],dis[i][j]);
                }
            }
        }*/
        vector<int> res(1000,INF);
        res[0]=1;
        queue<int> q;
        q.push(0);
        while(!q.empty()){
            int p =q.front();q.pop();
            if(p+1<pt && (p+1)%w!=0 && res[p+1]==INF && dis[p][p+1]){
                q.push(p+1);res[p+1]=res[p]+1;
            } 
            if(p-1>=0 && p%w!=0 && res[p-1]==INF && dis[p][p-1]){
                q.push(p-1);res[p-1]=res[p]+1;
            }
            if(p+w<pt && res[p+w]==INF && dis[p][p+w]){
                q.push(p+w);res[p+w]=res[p]+1;
            }
            if(p-w>=0 && res[p-w]==INF && dis[p][p-w]){
                q.push(p-w);res[p-w]=res[p]+1;
            }
        }
        if(res[pt-1]==INF) cout<<0<<endl;
        else cout<<res[pt-1]<<endl;
    }
}

Measured memory_bytes: 6752
#include<stdio.h>

int abc[2][3];

void scan() {
	for (int i = 0; i < 2; ++i) {
		for (int i2 = 0; i2 < 3; ++i2) {
			scanf("%d", &abc[i][i2]);
		}
	}
	return;
}

int main() {
	
	for (int i = 0; i < 3; ++i) {
		scan();
		
		int si, so;
		si = abc[0][0] * 60 * 60 + abc[0][1] * 60 + abc[0][2];
		so = abc[1][0] * 60 * 60 + abc[1][1] * 60 + abc[1][2];
		
		int ans = so - si;
		int ansh, ansm, anss;
		ansh = ans / (60 * 60);
		ans = ans % (60 * 60);
		ansm = ans / 60;
		ans = ans % 60;
		anss = ans;

		printf("%d %d %d\n", ansh, ansm, anss);
	}

	return 0;
}

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

using namespace std;

const bool debug = true;
#define dbg(...) if(debug) printf(__VA_ARGS__)
#define print(var) if (debug) cout << #var << " = " << var << endl

namespace {
    /** utility functions for reading a pair or a vector from stdin. */
    template<typename K, typename V> istream& operator>>(istream& is, pair<K, V>& p) { return is >> p.first >> p.second; }
    template<typename T> istream& operator>>(istream& is, vector<T>& xs) { for (auto& x : xs) is >> x; return is; }

    using ll = long long;
    int N, M;
    vector<int> A;
    void input() {
        cin >> N >> M;
        A.resize(N);
        cin >> A;
    }

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

    void solve() {
        vector<int> X;
        auto L = lcm(N, M);
        for (int i = 0; i < L; i += M) {
            X.insert(X.end(), A.begin(), A.end());
        }
        int i = 0;
        int ans = 0;
        while (true) {
            int j = i + M;
            int W = *max_element(X.begin() + i, X.begin() + j);
            int w = *min_element(X.begin() + i, X.begin() + j);
            ans += W - w;
            i = j;
            if (i == L) break;
        }
        cout << ans << endl;
    }
}

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




Measured memory_bytes: 6928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      int[] dp = new int[n+1];
      dp[0] = 0;
      for(int i=1; i<=n; i++) {
        dp[i] = Integer.MAX_VALUE;
        
        for(int pow = 1; pow <= i; pow *= 6) {
          dp[i] = Math.min(dp[i], dp[i-pow]+1);
        }

        for(int pow = 1; pow <= i; pow *= 9) {
          dp[i] = Math.min(dp[i], dp[i-pow]+1);
        }
      }

      System.out.println(dp[n]);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 22996
#include<iostream>
#include<set>

int main(void){
    std::set<int> s;
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++){
	int v;
	std::cin >> v;
	if(s.find(v) != s.end()){
	    std::cout << "NO" << std::endl;
	    return 0;
	}
	s.insert(v);
    }
    std::cout << "YES" << std::endl;
    return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N, K, T, U, V, L; 
	bitset<10005> flag;

	cin >> N >> K >> T >> U >> V >> L;
	for (int i = 0; i < N; i++) {
		int D; cin >> D;
		flag[D] = true;
	}

	int prev = -INF;	
	int cnt = 0;
	bool f = false;
	double times = 0;
	for (int i = 0; i < L; i++) {
		if (flag[i]) cnt++;
		if (cnt > 0 && (i - prev >= V*T || cnt == K+1)) {
			cnt--;
			f = true;
			prev = i;
		}
		if (i - prev >= V*T) f = false;	
		if (f) times += 1.0 / (double)V;
		else times += 1.0 / (double)U;
	}
	cout << times << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}



Measured memory_bytes: 3300
#include <iostream>

int main(){
	int n;
	while(std::cin >> n, n){
		int ice[10] = {0};
		for(int i=n;i;i--){
			int t;
			std::cin >> t;
			ice[t]++;
		}


		for(int i=0;i<10;i++){
			if(ice[i])
				for(int j=ice[i];j;j--)
					std::cout << "*";
			else
				std::cout << "-";
			std::cout << "\n";
		}
	}
}

Measured memory_bytes: 0
import java.util.*;
public class Main
{

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		double a[]=new double[n+1];
		for(int i=1;i<=n;i++)
		{
			a[i]=sc.nextDouble();
		}
		double dp[][]=new double[n+1][n+1];
		dp[0][0]=1;
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<=i;j++)
			{
				if(j==0)
					dp[i][j]= (dp[i-1][j]*(1-a[i]));
				else
				dp[i][j]=(dp[i-1][j-1]*a[i]) + (dp[i-1][j]*(1-a[i]));
			}
		}
		double sum=0;
		for(int i=(n+1)/2;i<=n;i++)
			sum+=dp[n][i];
		System.out.println(sum);
	}
}

Measured memory_bytes: 124688
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,sum=0;
  cin>>n;
  vint b(n+10,0);
  rep(i,n){
    cin>>b[i];
  }
  rep(i,n){
    REP(j,i+1,n){
      sum+=b[i]*b[j];
    }
  }
  cout<<sum<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, h; cin >> n >> h;
  vector<int> p; int best = 0;
  for(int i = 0; i < n; i++){
    int x, y; cin >> x >> y; best = max(best, x);
    p.push_back(y);
  }
  int ans = (h + best - 1) / best;
  sort(p.rbegin(), p.rend());
  for(int i = 0; i < n; i++){
  	h -= p[i]; h = max(h, 0);
    ans = min(ans, i + 1 + (h + best - 1) / best);
  }
  cout << ans << endl;
  return 0;
}
  


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
//#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
//#include <stack>
//#include <limits>
#include <sstream>
//#include <functional>
using namespace std;

#define len(array)  (sizeof (array) / sizeof *(array))
#define rep(i, s, e) for(int i = s;i < e;i++)
#define rrep(i, e, s) for(int i = e;s <= i;i--)
#define vrange(v) v.begin(), v.end()
#define vrrange(v) v.rbegin(), v.rend()
#define vsort(v) sort(vrange(v))
#define vrsort(v) sort(vrrange(v))
#define arange(a) a, a + len(a)
#define asort(a) sort(arange(a))
#define arsort(a, t) sort(arange(a), greater<t>())
#define afill(a, v) fill(arange(a), v)
#define afill2(a, v, t) fill((t *)a, (t *)(a + len(a)), v)
#define fmax(a, b) (a < b? b : a)
#define fmin(a, b) (a > b? b : a)
#define fabs(a) (a < 0? -a : a)
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-10;
//const int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
//const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//const int weight[] = {0,1,10,100,1000,10000,100000,1000000,10000000};
//priority_queue< int, vector<int>, greater<int> > q;

void doIt(){
  int n, m, s, l, p, w, dp[394], ans[394];
  bool bImpossible = false;
  cin >> n;
  afill(dp, -INF);
  rep(i, 0, n){
	cin >> s >> l >> p;
	rep(j, s, l + 1){
	  dp[j] = max(dp[j], p);
	}
  }
  rep(i, 1, 394){
	rep(j, 1, i){
	  if(dp[j] != -INF && dp[i - j] != -INF) dp[i] = max(dp[i], dp[j] + dp[i - j]);
	}
  }
  cin >> m;
  rep(i, 0, m){
	cin >> w;
	if(dp[w] != -INF) ans[i] =  dp[w];
	else ans[i] = -1, bImpossible = true;
  }
  if(bImpossible) cout << -1 << endl;
  else{
	rep(i, 0, m){
	  cout << ans[i] << endl;
	}
  }
}

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

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
int main(){
	nes;
	string s;
	cin>>s;
	int k=0;
	if(s[0]=='R'){
		++k;
		if(s[1]=='R') {
		++k;
		if(s[2]=='R') cout<<++k;
		else cout<<k;
		}
		else cout<<1;
	}
	else{
		if(s[1]=='R'&&s[2]=='R'){
			cout<<2;
		}
		else if(s[1]=='S'&&s[2]=='R') cout<<1;
		else if(s[1]=='R'&&s[2]=='S') cout<<1;
		else{
			cout<<0;
		}
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	
	ll N, H, D;
	cin >> N >> H >> D;

	vector<ll> frac(N + 1);

	frac[0] = 1;
	repn(i, N) frac[i] = frac[i - 1] * i%MOD;

	ll F = 0;
	repn(i, N) F = (F + frac[i]) % MOD;

	vector<ll> dp(H + 1);
	dp[0] = frac[N];

	ll X = frac[N];
	repn(i, H-1) {
		dp[i] = X * F%MOD;

		X += dp[i];
		if (i >= D) { X -= dp[i - D]; }

		X %= MOD;
		if (X < 0) { X += MOD; }
	}

	cout << X;

	system("PAUSE");
}


Measured memory_bytes: 16120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] = tolower(s[k - 1]);
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>

int main(void){

    int r,D,x_2000,i;

    scanf("%d %d %d",&r,&D,&x_2000);

    for(i = 0;i < 10;i++){
        x_2000 = r * x_2000 -D;
        printf("%d\n",x_2000);
    }

    return 0;
}

Measured memory_bytes: 128
n, k = gets.split.map(&:to_i)
means = gets.split.map {|num|
  (1 + num.to_i) / 2.0
}

sums = [0]

0.upto(k - 1) do |i|
  sums[0] += means[i]
end

max = sums[0]

k.upto(n - 1) do |i|
  sums[i - k + 1] = sums[i - k] - means[i - k] + means[i]
  if max < sums[i - k + 1]
    max = sums[i - k + 1]
  end
end

puts max

Measured memory_bytes: 16468
try:
    while True:
        num_list = []
        num_di = {}
        
        #リストに数値を格納して１番大きい数を出力する
        for i in range(0,5):
            line = list(map(int,input().split()))
            num_list.append(sum(line))
            num_di[sum(line)] = 65 + i
        num_list.sort()
        print(chr(num_di[num_list[4]]) + " " + str(num_list[4]))

#EOFErrorを検知する
except EOFError:
    pass


Measured memory_bytes: 5612
# coding: utf-8

l_prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]

from collections import Counter

num_N = int(input())

l_all = []

for num in range(2, num_N + 1):
    for prime in l_prime:
        if prime > num:
            break

        while num % prime == 0:
            l_all.append(prime)
            num /= prime

prime_counter = Counter(l_all)

ans = 1

for count in prime_counter.values():
    ans *= (count + 1)

print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

//10進数を2進数に変換_63個の要素を持つ配列
vector<int> Convert10to2(ll n) {
	vector<int> ans(63);
	rep(i, 63) {
		ans[i] = n % 2;
		n -= n % 2;
		n /= 2;
	}
	return ans;
}
//2進数を10進数に変換_63個の要素を持つ配列
ll Convert2to10(vector<int> a) {
	ll ans=0;
	ll j = 1;
	rep(i, a.size()) {
		ans += a[i] * j;
		if (i != a.size() - 1) {
			j *= 2;
		}
	}
	return ans;
}
//XORを計算
vector<int> CalcXOR2to2(vector<int> a, vector<int> b) {
	rep(i, 63) {
		if (a[i] != b[i]) {
			a[i] = 1;
		}
		else {
			a[i] = 0;
		}
	}
	return a;
}

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

int sum(vector<int> x) {
	int ans = 0;
	rep(i, x.size()) {
		ans += x[i];
	}
	return ans;
}


int main() {
	int n;
	cin >> n;
	double ans=0;

	rep(i, n) {
		double x;
		string s;
		cin >> x >> s;
		if (s == "JPY") {
			ans += x;
		}
		else {
			ans += x * 380000;
		}
	}
	cout << dec << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int l[8];

int min(int a, int b) { return a < b ? a : b; }
int abs(int x) { return x > 0 ? x : -x; }

int main() {
	int n, a, b, c;
	scanf("%d %d %d %d", &n, &a, &b, &c);
	
	for(int i = 0; i < n; i++) scanf("%d", &l[i]);

	int S = 1;
	for(int i = 0; i < n; i++) S *= 4;
	
	int ans = 1000000;
	for(int s = 0; s < S; s++) {
		int la = 0, lb = 0, lc = 0;
		int ca = 0, cb = 0, cc = 0;

		int t = s;
		for(int i = 0; i < n; i++) {
			if(t % 4 == 1) {
				la += l[i];
				ca += 1;
			}
			if(t % 4 == 2) {
				lb += l[i];
				cb += 1;
			}
			if(t % 4 == 3) {
				lc += l[i];
				cc += 1;
			}
			t /= 4;
		}
		if(ca == 0 || cb == 0 || cc == 0) continue;
		ans = min(ans, abs(la - a) + abs(lb - b) + abs(lc - c) + (ca + cb + cc - 3) * 10);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int w, h;
	int sx, sy;
	int gx, gy;
	int[][] a;

	void run(){
		for(;;){
			w=sc.nextInt();
			h=sc.nextInt();
			if((w|h)==0){
				break;
			}
			sx=sc.nextInt()-1;
			sy=sc.nextInt()-1;
			gx=sc.nextInt()-1;
			gy=sc.nextInt()-1;
			int n=sc.nextInt();
			a=new int[h][w];
			for(int k=0; k<n; k++){
				int c=sc.nextInt();
				int d=sc.nextInt();
				int x=sc.nextInt()-1;
				int y=sc.nextInt()-1;
				for(int j=0; j<2; j++){
					for(int i=0; i<4; i++){
						if(d==0){
							a[y+j][x+i]=c;
						}else{
							a[y+i][x+j]=c;
						}
					}
				}
			}
			solve();
		}
	}

	void solve(){
		LinkedList<P> que=new LinkedList<P>();
		boolean[][] visited=new boolean[h][w];

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

		que.offer(new P(sx, sy));
		visited[sy][sx]=true;

		for(; !que.isEmpty();){
			P p=que.poll();
			for(int i=0; i<4; i++){
				P q=new P(p.x+dx[i], p.y+dy[i]);
				if(q.x>=0&&q.x<w&&q.y>=0&&q.y<h&&a[q.y][q.x]==a[sy][sx]
						&&!visited[q.y][q.x]){
					que.offer(q);
					visited[q.y][q.x]=true;
				}
			}
		}
		println(visited[gy][gx]?"OK":"NG");
	}

	class P{
		int x, y;

		P(int x, int y){
			this.x=x;
			this.y=y;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

using namespace std;

int calc(const int rhs, int& lhs)
{
    for(int i = 0; i < 7; ++i)
    {
        if(rhs < lhs)
        {
            return i;
        }
        lhs <<= 1;
    }
    return 7;
}

int main(void)
{
    int A, B, C;
    int K;
    cin >> A >> B >> C;
    cin >> K;

    int magick = calc(A, B);
    magick += calc(B, C);

    cout << ( magick <= K ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e2+5,mo=1e9+7;
LL Power(LL a,int b){
	LL ans=1;
	while(b){
		if(b&1)(ans*=a)%=mo;
		(a*=a)%=mo,b>>=1;
	}
	return ans;
}
int f[N];
int main(){
	int n=3,k;scanf("%d",&k);
	LL ans=0;
	for(int i=k;i;i--){
		f[i]=Power(k/i,n);
		for(int j=i*2;j<=k;j+=i)(f[i]-=f[j])%=mo;
		ans+=1ll*i*f[i]%mo;
	}
	printf("%lld",(ans%mo+mo)%mo);
	return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long int int64;

int main(int argc, char **argv)
{
    int N;
    string S;
    cin >> N >> S;

    int len = S.length();
    for (int i = 0; i < len; ++i) {
        cout << (char)(((int)(S[i] - 'A' + N) % 26) + 'A');
    }
    cout << endl;
    return 0;
}


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

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

long lcm(long a, long b){
  return a * b / gcd(a, b);
}
int main() {
  long a, b;
  cin >> a >> b;
  long ans = lcm(a, b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
int main() {
	int i, j;
	cin>>n;
	for(i=11; n; i+=10) {
		for(j=2; j*j<=i; j++) if(i%j==0) break;
		if(j*j>i) {
			cout<<i<<' ';
			n--;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int p[1050]={};
  int i,j,k;
  for(i=0;i<m;i++){
    cin >> j >> k;
    p[j]=max(p[j],k);
  }
  int inf = 1<<15;
  int dp[1050][1050];
  fill(dp[0],dp[1049],inf);
  dp[0][0]=0;
  i=0;
  for(j=max(i+1,p[i+1]);j<=n+1;j++){
    dp[j][i+1]=min(dp[j][i+1],dp[i][i]+2*(j-i)-1);
  }
  for(i=1;i<=n+1;i++){
    if(i>=p[i])
      dp[i][i]=min(dp[i][i],dp[i-1][i-1]+1);
    
    for(j=p[i];j<=n+1;j++){
      dp[j][i]=min(dp[j][i],dp[j][i-1]+1);
    }
    
    for(j=max(i+1,p[i+1]);j<=n+1;j++){
      dp[j][i+1]=min(dp[j][i+1],dp[i][i]+2*(j-i)-1);
    }
  }

  //cout << dp[1000][2] << endl;

  /*
  for(i=0;i<=10;i++){
    for(j=0;j<=10;j++){
      //cout << dp[j][i] << " ";
      printf("%3d ", dp[j][i]);
    }
    cout << endl;
  }
  */
  /*
  for(i=990;i<=1001;i++){
    for(j=990;j<=1001;j++){
      //cout << dp[j][i] << " ";
      printf("%3d ", dp[j][i]);
    }
    cout << endl;
  }
  */
  
  
  int o=inf;
  o=min(o,dp[n+1][n+1]);
  cout << o << endl;
  return 0;
}

Measured memory_bytes: 5472
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();

        int cnt = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    int total = i * 500 + j * 100 + k * 50;
                    if (total == x)   cnt++;
                }
            }
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  vector<ll> l(n+1);
  l[0] = 2;
  l[1] = 1;
  repI(i, 2, n+1) l[i] = l[i-1] + l[i-2];

  cout << l[n] << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;




int main() {
    int n,k;
    cin >> n >> k;
    string a;
    for(int i = 0;i < n;i++){
        cin >> a;
        for(int j = 0;j < 2;j++){
            cout << a << endl;
        }
    }
    
}



Measured memory_bytes: 256