akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

const (
	MAX = 1000000000000000000
)
const MaxBuf = 200100

var (
	list []*big.Int = make([]*big.Int, 0)
	bmax            = big.NewInt(MAX)
)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	l := readLine()
	l = readLine()
	l = strings.TrimSpace(l)
	l2 := strings.Split(l, " ")

	for i := 0; i < len(l2); i++ {
		a, _ := strconv.Atoi(l2[i])
		if a == 0 {
			fmt.Println(0)
			return
		}
		list = append(list, big.NewInt(int64(a)))
	}

	now := big.NewInt(1)
	for i := 0; i < len(list); i++ {
		now = now.Mul(now, list[i])
		if now.Cmp(bmax) == 1 {
			fmt.Println("-1")
			return
		}
	}

	fmt.Println(now)
}


Measured memory_bytes: 14920
#include <iostream>

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

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;

  while (1) {
    c -= b;
    if (c <= 0) {
      std::cout << "Yes" << '\n';
      break;
    }

    a -= d;
    if (a <= 0) {
      std::cout << "No" << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

struct edge {
    edge(int src, int dst, long long weight)
        : src(src)
        , dst(dst)
        , weight(weight)
    {}

    int src;
    int dst;
    long long weight;
};

const long long INF = 1LL << 50;

bool bellman_ford(const vector<vector<edge>> &g, int s, vector<long long>& dist)
{
    int N = g.size();
    dist.assign(N, INF + INF);
    dist[s] = 0;
    bool negative_cycle = false;
    for (int k = 0; k < N; ++k) {
        for (const auto& edges : g) {
            for (const auto& e : edges) {
                if (dist[e.dst] > dist[e.src] + e.weight) {
                    dist[e.dst] = dist[e.src] + e.weight;
                    if (k == N - 1) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

vector<bool> get_reachability(const vector<vector<edge>>& g, int s)
{
    vector<bool> visited(g.size(), false);
    queue<int> waiting;
    auto visit = [&](int x) {
        if (visited[x]) {
            return false;
        }
        visited[x] = true;
        waiting.push(x);
        return true;
    };

    visit(s);
    while (!waiting.empty()) {
        int x = waiting.front();
        waiting.pop();
        for (auto& e : g[x]) {
            if (visit(e.dst)) {
                waiting.push(e.dst);
            }
        }
    }
    return visited;
}

long long solve(int N, int M, int P, const vector<int>& A, const vector<int>& B, const vector<int>& C)
{
    vector<vector<edge>> g_org(N), g_rev(N), g(N);
    for (int i = 0; i < M; ++i) {
        g_org[A[i]].emplace_back(A[i], B[i], P - C[i]);
        g_rev[B[i]].emplace_back(B[i], A[i], P - C[i]);
    }
    auto r_org = get_reachability(g_org, 0);
    auto r_rev = get_reachability(g_rev, N - 1);
    for (int i = 0; i < M; ++i) {
        if (r_org[B[i]] && r_rev[B[i]]) {
            g[A[i]].emplace_back(A[i], B[i], P - C[i]);
        }
    }

    vector<long long> dist;
    if (!bellman_ford(g, 0, dist)) {
        return -1;
    }

    return max(0LL, -dist[N - 1]);
}

int main()
{
    int N, M, P;
    cin >> N >> M >> P;
    vector<int> A(M), B(M), C(M);

    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i] >> C[i];
        --A[i];
        --B[i];
    }
    cout << solve(N, M, P, A, B, C) << endl;
}



Measured memory_bytes: 896
#include<cstdio>
#include<iostream>
#include<cmath>
#include<ctype.h>
#include<vector>
#include<cstdlib>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<time.h>

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
const ll INF = -10000000000;
using namespace std;
ll dp[10001][101] = {};
int N, W;
int v[1000], w[1000];

int main()
{
	cin >> N >> W;
	REP(i, N) cin >> v[i] >> w[i];

	for (int i = 0; i <= W; i++) { //??\??????????????§??????
		for (int j = 0; j < N; j++) { //j????????\????????????
			if (i == 0) dp[i][j] = 0;
			else if (i >= w[j]) dp[i][j] = max(dp[i][j-1],dp[i-w[j]][j]+v[j]);
			else dp[i][j] = dp[i][j - 1];
		}
	}
	/*
	REP(i, W+1) {
		REP(j, N) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/
	cout << dp[W][N - 1] << endl;

	return 0;
}

Measured memory_bytes: 9056
import java.io.*;
import java.util.Scanner;
 
public class Main {
    public static double area(double r) {
        return r * r * Math.PI;
    }

    public static double perimeter(double r) {
        return 2 * Math.PI * r;
    }
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        // int b = sc.nextInt();
        System.out.printf("%.10f %.10f\n", area(r), perimeter(r));
    }
}


Measured memory_bytes: 28356
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){

  int N, M;
  cin >> N;
  vector<string> vec1(N);
  for (int i=0; i<N; i++){
    cin >> vec1.at(i);
  }
  cin >> M;
  vector<string> vec2(M);
  for (int i=0; i<M; i++){
    cin >> vec2.at(i);
  }

  int max=0;
  for (int i=0; i<N; i++){
    int sum=0;
    for (int j=0; j<N; j++){
      if (vec1.at(i)==vec1.at(j)){
        sum++;
      }
    }
    for (int k=0; k<M; k++){
      if (vec1.at(i)==vec2.at(k)){
        sum--;
      }
    }
    if (sum>max){
      swap(sum, max);
    }
  }

  cout << max << endl;
}


Measured memory_bytes: 3584
while True:
    Input = input().split()
    a = int(Input[0])
    op = Input[1]
    b = int(Input[2])
    if a >= 0 and b >= 0 and a <= 20000 and b <= 20000:
        if op == "+":
            print(a + b)
        elif op == "-":
            print(a - b)
        elif op == "*":
            print(a * b)
        elif op == "/":
            if b != 0:
                print(int(a / b))
        elif op == "?":
            break

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> d(K);
    vector<vector<int>> A(K, vector<int>(N));
    for (int i = 0; i < K; i++) {
        cin >> d.at(i);
        for (int j = 0; j < d.at(i); j++){
            cin >> A.at(i).at(j);
        }
    }



    vector<int> ans(0);

    for (int i = 0; i < K; i++) {
        for (int j = 0; j < d.at(i); j++){
            ans.push_back(A.at(i).at(j));
        }
    }

    int countA = 0;
    int countB = 0;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < ans.size(); j++){
            if (i == ans.at(j)) {
                countB++;
            }
        }
        if (countB == 0) {
            countA++;
        }
        countB = 0;
    }

    cout << countA << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = static_cast<LL>(1e9+7);
const LL N = 5e5+1;

int main() {
	fastio();

	LL n;
	cin >> n;

	vector<LL> a(n);

	for (auto &e : a) {
		cin >> e;
	}
	sort(a.begin(), a.end(), greater<LL>());
	
	LL cnt = 1, ans = a[0];
	for (int i = 1; i < n && cnt < n-1; ++i) {
		if (cnt < n-2) {
			cnt += 2;
			ans += 2*a[i];
		}
		else {
			cnt++;
			ans += a[i];
		}
	}

	cout << ans << "\n";


}

Measured memory_bytes: 4780
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

typedef int Weight;
struct Edge {
  int cnt;
  int src;
  int dest;
  Weight weight;
  Edge(int cnt, int src, int dest, Weight weight) : cnt(cnt), src(src), dest(dest), weight(weight) {;}
  bool operator<(const Edge &rhs) const {
    return weight > rhs.weight;
  }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int c, n, m, s, d;
bool visit[20][110];

int main() {
  while (scanf("%d %d %d %d %d", &c, &n, &m, &s, &d), c|n|m|s|d) {
    MEMSET(visit, false);
    s--; d--;
    Graph g(n);
    REP(i, m) {
      int f, t, cost;
      scanf("%d %d %d", &f, &t, &cost);
      f--; t--;
      g[f].push_back(Edge(0xdeadbeaf, 0xdeadbeaf, t, cost));
      g[t].push_back(Edge(0xdeadbeaf, 0xdeadbeaf, f, cost));
    }
    priority_queue<Edge> que;
    que.push(Edge(c, 0xdeadbeaf, s, 0));
    while (!que.empty()) {
      Edge e = que.top();
      que.pop();
      if (visit[e.cnt][e.dest]) { continue; }
      visit[e.cnt][e.dest] = true;
      if (e.dest == d) {
        printf("%d\n", e.weight);
        break;
      }
      FORIT(it, g[e.dest]) {
        if (e.cnt != 0) {
          int ncost = e.weight + it->weight / 2;
          que.push(Edge(e.cnt - 1, 0xdeadbeaf, it->dest, ncost));
        }
        int ncost = e.weight + it->weight;
        que.push(Edge(e.cnt, 0xdeadbeaf, it->dest, ncost));
      }
    }
  }
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
# https://atcoder.jp/contests/arc068/tasks/arc068_a

# 最初に5の面を上にして,6,5,6,5と点を稼いでいくのが最適

x = read_a_int()
ans = (x // 11) * 2
nokori = x % 11
if nokori > 0:
    nokori -= 6
    ans += 1
if nokori > 0:
    nokori -= 5
    ans += 1
print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

long long gcd(long long N, long long M){
    if(N==0||M==0){
        return max(1LL,max(N,M));
    }
    while (true){
        if (min(N,M)==0){
            return max(N,M);
        }else if (N>M){
            N%=M;
        }else{
            M%=N;
        }
    }
}

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

    map<pair<ll,ll>,ll> m;
    ll ans=1;
    for(int i=0; i<N; i++){
        ll A, B;
        cin >> A >> B;
        ll g=gcd(abs(A),abs(B));
        A/=g;
        B/=g;
        if(A<0){
            A=-A;
            B=-B;
        }else if(A==0){
            B=abs(B);
        }
        pair<ll,ll> key=make_pair(A,B);
        if(m.count(key)){
            m[key]++;
        }else{
            m[key]=1;
        }
    }

    vector<ll> p2(200001,1);
    for(int i=0; i<200000; i++){
        p2[i+1]=2LL*p2[i];
        p2[i+1]%=MOD;
    }

    for(auto &kv:m){
        pair<ll,ll> key=kv.first;
        ll val=kv.second;
        if(key.first==0 && key.second==0)continue;
        m[key]=0;
        //cout << key.first << ' ' << key.second << endl;
        
        pair<ll,ll> inv_key;
        if(key.second<=0){
            inv_key=make_pair(-key.second,key.first);
        }else{
            inv_key=make_pair(key.second,-key.first);
        }
        ll inv_val=0;   
        if(m.count(inv_key)&&inv_key!=key){
            inv_val=m[inv_key];
            m[inv_key]=0;
        }

        //cout << inv_key.first << ' ' << inv_key.second << ' ' << val << ' ' << inv_val << endl;
        ans*=(p2[val]+p2[inv_val]-1)%MOD;
        ans%=MOD;
    }
    pair<ll,ll> key=make_pair(0,0);
    if(m.count(key)){
        ans+=m[key];
        ans%=MOD;
    }

    cout << (MOD+ans-1)%MOD << '\n';
}

Measured memory_bytes: 17072
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
using namespace std;
typedef long long ll;
ll n;
ll m;
vector<ll> a;
vector<ll> sum;
vector<ll> rle;
vector<ll> v;
bool C(ll x,ll y){
  // cout << y <<":"<<rle[x] << "\n";
  return y<rle[x];
}
ll upper(ll l,ll r,ll y){
  ll lb=l-1,ub=r+1;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(C(mid,y)) ub=mid;
    else lb=mid;
  }
  return ub;
}
bool C2(ll y,ll k){
  ll j=upper(0,m-1,y);
  // cout << y <<":"<<j << "\n";
  return sum[m]-sum[j]-(m-j)*y<=n-y*k;
}

ll lower(ll l,ll r,ll k){
  
  ll lb=l-1,ub=r+1;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(C2(mid,k)) lb=mid;
    else ub=mid;
  }
  return lb;
}

int main()
{
  cin >> n;
  a.resize(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(), a.end());


  ll cnt=1;
  rep(i,n-1){
    if(a[i]==a[i+1]){
      cnt++;
    }
    else{
      rle.push_back(cnt);
      cnt=1;
    }
  }
  rle.push_back(cnt);

  sort(rle.begin(), rle.end());
  
  
  m=rle.size();
  
  
  sum.resize(m+1);
  sum[0]=0;
  rep(i,m){
    sum[i+1] = sum[i]+rle[i];
  }


  rep1(k,n){
    cout << lower(1,n/k,k) << "\n";
  }
  return 0;
}


Measured memory_bytes: 9324
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define INF (1<<29)

int data[100002] , memo[100002];
int n,L;
int recurse(int n){
	if(~memo[n]) return memo[n];
	int ans = 0;
	if(data[n+1] > data[n]) ans = max( ans , recurse(n+1) );
	if(data[n-1] > data[n]) ans = max( ans , recurse(n-1) );
	
	return memo[n] = ans + (L - data[n]);
}
int main(){
	cin >> n >> L;
	for(int i = 1 ; i <= n ; i++) cin >> data[i];
	memset(memo,-1,sizeof(memo));
	
	int ans = 0;
	for(int i = 1 ; i <= n ; i++){
		ans = max<int>( ans , recurse(i) ); 
	}
	cout << ans << endl;
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> grid(h, vector<char>(w));
    vector<bool> ignore_row(h, true);
    vector<bool> ignore_column(w, true);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> grid[i][j];
            if (grid[i][j] == '#')
            {
                ignore_row[i] = false;
                ignore_column[j] = false;
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        if (ignore_row[i]) continue;
        for (int j = 0; j < w; j++)
        {
            if (ignore_column[j]) continue;
            cout << grid[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    int n;
    
    cin >> n;
    char c[n];

    for(int i=0;i<n;i++){
      cin >> c[i];
        if(c[i] == 'Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
       
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n+1];
    int b[] = new int[n+1];
    int c[] = new int[n];
    int answer = 0;
    int before =0;
    for(int i=1;i<=n;i++){
      a[i]=sc.nextInt();
    }
    for(int i=1;i<=n;i++){
      b[i]=sc.nextInt();
    }
    for(int i=1;i<=n-1;i++){
      c[i]=sc.nextInt();
    }
    for(int i=1;i<=n;i++){
      answer = answer + b[a[i]];
      if(before+1==a[i]&&before!=0){
        answer = answer + c[before];
      }
      before = a[i];
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    vs grid(h);
    int cnt = 0;
    rep(i, h) {
        cin >> grid[i];
        rep(j, w) {
            if (grid[i][j] == '#') cnt++;
        }
    }
    if (cnt == h+w-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <chrono>
#include <random>
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define PI 3.14159265358979323846
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a<b)?(b):(a))
#define abs(a) ((a>0)?a:-(a))
#define pii pair<int,int>

const double eps = (double)1e-6;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



map<pii, set<pii> > adj; 

int indeg[1005][1005];
int inp[1005][1005];
vector<pair<int,int> > q;
int ans = 0;

int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n-1; j++) {
            cin >> inp[i][j];
            if (j != 1) {
                int tmpi = i, tmpj = inp[i][j];
                if (tmpi > tmpj) swap(tmpi, tmpj);
                int pretmpi = i, pretmpj = inp[i][j-1];
                if (pretmpi > pretmpj) swap(pretmpi, pretmpj);
                indeg[tmpi][tmpj]++;
                adj[{pretmpi,pretmpj}].insert({tmpi,tmpj});
                // printf("i = %d, j = %d, tmpi = %d, tmpj = %d, pretmpi = %d, pretmpj = %d\n",i,j,tmpi,tmpj,pretmpi,pretmpj);
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (!indeg[i][j] && i < j) {
                q.emplace_back(i,j);
            }
        }
    }

    // cout << "debugging..." << endl;
    // for (auto p : q) {
    //     cout << p.first << " " << p.second << endl;
    // }

    vector<pair<int,int> >tmp;

    while (!q.empty()) {
        tmp.clear();
        while (!q.empty()) {
            auto currp = q[q.size()-1]; q.pop_back();
            int i = currp.first, j = currp.second;
            for (auto nei : adj[{i,j}]) {
                int neii = nei.first, neij = nei.second;
                // if (neii > neij) swap(neii, neij);
                if (--indeg[neii][neij] == 0) tmp.emplace_back(neii,neij);
            }
        }
        ans++;
        q = tmp;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n-1; j++) {
            if (indeg[i][j]) {
                cout << -1 << endl; return 0;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 101760
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long ll;
#define print(x) cout<<(x)<<endl


#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

ll dp[26];


// DONT USE "int", USE "ll" !!!!!!!!!!!!
int main() {
	int a, b, t;
	cin >> a >> b >> t;
	int out = b * (t / a);
	print(out);


	return 0;
}

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

long long gcd(long long a, long long b){
    return b ? gcd(b, a%b) : a; 
}

int main(){
    long long a, b, ans=1, G;
    cin >> a >> b;
    G = gcd(a, b);
    for(long long i=2; i*i<=G; i++){
	if(G%i==0){
	    ans++;
	    while(G%i==0) G/=i; 
	}
    }

    if(G != 1)
	ans++;
    
    cout << ans << endl;
}



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

#define ff first
#define ss second
#define it(a, x) for (auto &a : x)
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vs vector<string>
#define gi greater<int>
#define vc vector<char>
#define vvi vector<vi>
#define vvc vector<vc>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
#define deb(x) cout << #x << "=" << x << endl;
#define in(i, n) for (auto i = 0; i < n; i++)
#define all(x) begin(x), end(x)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());//random shuffler

ll fxp(ll a, ll b) {
    if (b == 0) return 1;
    if (b % 2 == 0) {
        ll c = fxp(a, b / 2);
        return (c * c) % mod;
    }
    return (a * fxp(a, b - 1)) % mod;
}

void c_p_c() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    in(i, n)cin >> a[i];
    vector<ll> pre(n);
    pre[0] = a[0];
    for (int i = 1; i < n; i++) {
        pre[i] = pre[i - 1] + a[i];
    }
    ll sum = pre[n - 1], ans = 0;
    in(i, n) {
        ans += (a[i] % mod) * ((sum - pre[i]) % mod);
        ans %= mod;
    }
    cout << ans;
}

int main(int argc, char const *argv[]) {
    c_p_c();
    solve();
    return 0;
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    ll a, b;
    cin >> a >> b;
    if(a <= 0 and 0 <=  b) {
        cout << "Zero" << endl;
    }
    else if (a < 0 and (min(0ll, b) - a + 1) % 2 == 1) {
        cout << "Negative" << endl;
    }
    else cout << "Positive" << endl;



    return 0;
}


Measured memory_bytes: 256
N = int(input())

a = [int(i) for i in input().split()]

count=0
ans=0

for i in range(N):
    if a[i]<0:
        count+=1
        a[i]=abs(a[i])

if count%2==0:
    ans=sum(a)

else:
    a.sort()
    ans=sum(a)-a[0]*2

print(ans)


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

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

inline void Main() {
  // code
  int n,x;
  list<int> w;
  cin>>n;
  rep(i,n) {
    cin>>x;
    w.push_back(x);
  }

  int a = 0, b = 0;
  a = w.front();w.pop_front();
  b = w.back();w.pop_back();

  while(!w.empty()) {
    if(a < b || (a == b && w.front() < w.back())) {
      a += w.front();
      w.pop_front();
    } else {
      b += w.back();
      w.pop_back();
    }
  }

  cout << abs(a-b) << endl;
}

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


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

int main(int argc, char *argv[]){
    int n;
    cin >> n;
    long long c=0;
    int min=0;
    int a;
    for(int i=0;i<n;i++){
        cin >> a;
        if(min>a) c=c+min-a;
        else min=a;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) std::cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define MOD 1000000007

#define INF 1e12

const int MAX = 510000;

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;
}

// a^n mod m を求める
Int modpow(Int a, Int n, Int m) {
    Int b, t;
    if (n == 0) return 1;
    a %= m;
    b = a * a;
    b %= m;
    t = modpow(b, n / 2, m);
    if (n % 2 != 0) {
        t *= a;
        t %= m;
    }
    return t;
}

int main() {
    COMinit();
    Int n;
    cin >> n;
    if (n < 3) {
        PUTS(0)
        return 0;
    }
    Int ans = 0;
    Int d = 1;
    while (true) {
        Int m = n - 3 * d;
        if (m < 0) break;
        ans += COM(d + m - 1, m);
        ans %= MOD;
        d++;
    }
    PUTS(ans % MOD)
}


Measured memory_bytes: 15588
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
int main() {
    FIO;
    ll N,i,H,s=0,A[100000];
    cin>>H>>N;
    for(i=0;i<N;i++)
        cin>>A[i];
      for(i=0;i<N;i++)
        s+=A[i];
  	if(s>=H)
    cout<<"Yes";
    else
    cout<<"No";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=3005;
ll n;
long double a[N],dp[N][N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=1;i<=n;i++)cin>>a[i];
    dp[0][0]=1;
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=i;j++){
            //heads
            if(j>0)dp[i][j]=dp[i][j]+dp[i-1][j-1]*a[i];
            //tails
            dp[i][j] = dp[i][j] + dp[i-1][j]*(1-a[i]);
        }
    }
    long double ans = 0;
    for(ll i=(n+1)/2;i<=n;i++)ans+=dp[n][i];
    cout<<fixed<<setprecision(18)<<ans;
}

Measured memory_bytes: 139392
#include<stdio.h>
#include<limits.h>
#define VMAX 15
long int dist[VMAX][VMAX], dp[1<<VMAX];
int evnum[VMAX], odd[VMAX];
int cpp(int size);
int main(void)
{
  int i, j, v, e, s, t, d, sum = 0;
  for (i = 0; i < (1 << VMAX); i++) dp[i] =INT_MAX;
  for (i = 0; i < VMAX; i++) {
    for (j = 0; j < VMAX; j++) dist[i][j] = INT_MAX;
  }
  dp[0] = 0;
  scanf("%d%d", &v, &e);
  for (i = 0; i < e; i++) {
    scanf("%d%d%d", &s, &t, &d);
    if (d < dist[s][t]) {
      dist[s][t] = d;
      dist[t][s] = d;
    }
    sum += d;
    evnum[s]++;
    evnum[t]++;
  }
  printf("%d\n", sum + cpp(v));
}
int cpp(int size)
{
  int i, j, k, S, count = 0;
  long long int limit;
  for (i = 0; i < size; i++) {
    if (evnum[i] & 1) odd[count++] = i;
  }
  for (k = 0; k < size; k++) {
    for (i = 0; i < size; i++) {
      for (j = 0; j < size; j++) {
        long int newlen = dist[i][k] + dist[k][j];
        if (newlen < dist[i][j]) dist[i][j] = newlen;
      }
    }
  }
  limit = (1 << count) - 1;
  for (S = 0; S <= limit; S++) {
    for (i = 0; i < count; i++) {
      if (!(S & (1 << i))) {
        for (j = i + 1; j < count; j++) {
          if (!(S & (1 << j))) {
            long int tmp = dp[S] + dist[odd[i]][odd[j]], s = S | (1 << i) | (1 << j);
            if (tmp < dp[s]) dp[s] = tmp;
          }
        }
      }
    }
  }
  return dp[limit];
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct po{
  int num,site;
};

int m,n;
po a[102];
vector <int> rel[101];


void check(int e) {
  for(int i=1;i<=e;i++) {
    
    for(int j=0;j<rel[i].size();j++) {  
      int low = rel[i][j];
      if(a[i].site > a[low].site) {
	int t = a[i].site;
	a[i].site = a[low].site;
	a[low].site = t;
	check(i);
      }
    }
  }
      
}

int main() {

  cin >> n;
  cin >> m;
  for(int i=0;i<101;i++) a[i].num = a[i].site = i;

  for(int i=0;i<m;i++) {
    int x,y;
    cin >> x >> y;
    rel[x].push_back(y);
  }

  int emp;
  for(int i=1;i<=n;i++)
    if(rel[i].size() == 0) 
      emp = i;
      
  for(int i=1;i<=n;i++){
    rel[i].push_back(emp);
    sort(rel[i].begin(),rel[i].end());
  }  
  

  /*for(int i=1;i<=n;i++){
    cout << i <<" > ";
    for(int j=0;j<rel[i].size();j++)
      cout << rel[i][j] <<" ";
    cout << endl;
    } */

  check(n);

  //for(int i=1;i<=n;i++)cout <<"num="<< a[i].num <<" site="<<a[i].site << endl;
    
  
  for(int i=1;i<n;i++)
    for(int j=n;j>i;j--)
      if(a[j].site < a[j-1].site)
	swap(a[j],a[j-1]);
  
  for(int i=1;i<=n;i++) cout << a[i].num << endl;
  
    return 0;
  }

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] c = new int[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) 
				c[i][j] = sc.nextInt();
		}
		boolean ok = true;
		for(int i = 1; i <= 2; i++) {
			if(c[0][i] - c[0][i-1] != c[1][i] - c[1][i-1] || c[0][i] - c[0][i-1] != c[2][i] - c[2][i-1])
				ok = false;
		}
		for(int i = 1; i <= 2; i++) {
			if(c[i][0] - c[i-1][0] != c[i][1] - c[i-1][1] || c[i][0] - c[i-1][0] != c[i][2] - c[i-1][2])
				ok = false;
		}
		System.out.println(ok ? "Yes" : "No");
	}

}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}


int main(){
    int a,b; cin >> a >> b;
    if(a == b){
        cout << a+b << endl;
    }else{
        cout << max(a,b) * 2 - 1 << endl;
    }


}



Measured memory_bytes: 256
n=int(input())
a=[]
d={}
b=0
m=0
for i in range(n):
    s=input()
    try:
        a[d[s]][1]+=1
    except:
        d[s]=b
        a.append([s,1])
        b+=1
    m=max(m,a[d[s]][1])
a.sort()
for i in range(len(a)):
    if a[i][1]==m:
        print(a[i][0])

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

int main() {
	string s,t; cin >> s >> t;
	int n=s.size();
	rep(i,n) {
		if(s==t) {
			cout << "Yes" << endl;
			return 0;
		}
		s=s.back()+s.substr(0,n-1);
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

int x; cin>>x;
  if(x>=30){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}

  
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

		int[] c = new int[n];
		int[] s = new int[n];
		int[] f = new int[n];

		for(int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}

		for(int i = 0; i < n; i++) {
			int t = 0;
			for(int j = i; j < n - 1; j++) {
				if(t < s[j]) {
					t = s[j];
				} else if(t % f[j] == 0) {

				} else {
					t = t + f[j] - t % f[j];
				}
				t += c[j];
			}
			System.out.println(t);
		}
	}
}

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

int dfs(int current_node, vector<vector<int>> & adj,vector<int>&dp){
	if(dp[current_node] != -1) return dp[current_node];
	int temp = 0;
	for(int child : adj[current_node]){
		temp = max(temp, dfs(child, adj,dp) + 1);
	}
	return dp[current_node] = temp;
}

int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int>>adj(n+1);

	for(int i = 0; i < m; ++i){
		int start,end;
		cin>>start>>end;
		adj[start].push_back(end);
	}
	int result = 0;
	vector<int>dp(n+1,-1);
	for(int i = 1; i <= n; ++i){
		result = max(result, dfs(i,adj,dp));
	}	
	cout<<result<<endl;
}



Measured memory_bytes: 11884
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<  #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }


void solve()
{ 
   int n;
   cin>>n;
   int f=0;
   while(n>0)
     {
        if(n%10==7)
            f=1;
        n=n/10;
     }
     if(f)
        cout<<"Yes";
    else
        cout<<"No";

}
signed main()
{fast
    int t;
  t=1;
   //cin>>t;
  while(t--)
     {
      solve();
     }



}
  













Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;



int main(){
	double n, m;
	vector<int> taro;
	vector<int> hanako;
	int tmp;

	while (cin >> n >> m && (n != 0 && m != 0)) {
		bool flag = false;
		int taro_total = 0;
		int hanako_total = 0;
		taro.clear();
		hanako.clear();

		for (int i = 0; i < n; i++) {
			cin >> tmp;
			taro.push_back(tmp);
			taro_total += tmp;
		}
		for (int i = 0; i < m; i++) {
			cin >> tmp;
			hanako.push_back(tmp);
			hanako_total += tmp;
		}
		sort(taro.begin(), taro.end());
		sort(hanako.begin(), hanako.end());

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (taro_total - taro[i] + hanako[j] == hanako_total - hanako[j] + taro[i]) {
					cout << taro[i] << " " << hanako[j] << endl;
					flag = true;
					break;
				}
			}
			if (flag) {
				break;
			}
		}
		if (!flag) {
			cout << "-1" << endl;
		}
  }
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int counter = 0;
  rep(i, N + 1) {
    if (i % 2 == 0) continue;
    int divisor_counter = 0;
    rep(j, i) {
      if (i % (j + 1) == 0) ++divisor_counter;
    }
    if (divisor_counter == 8) ++counter;
  }

  cout << counter << endl;
}

Measured memory_bytes: 256
N = int(input())
H = [int(x) for x in input().split()]

ans = 0
tmp = 0

for i in range(N-1):
    if H[i]>=H[i+1]:
        tmp +=1
        if ans < tmp:
            ans = tmp        
    else :
        tmp = 0
        
print(ans)
        
       

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

int main() {
  int N,c=0;
  cin >> N ;
  vector<int> a(N) ;
  for(int i=0 ; i<N ;i++){
    cin >> a.at(i);
    if((i%2 == 0) && (a.at(i)%2==1)) c++ ;
  }
  cout << c;
}


Measured memory_bytes: 3624
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
res = 0
for i in a:
    res += b[i - 1]
for i, j in zip(a, a[1:]):
    if j == i + 1:
        res += c[i - 1]
print(res)

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

signed _main(){
  /*
  string S; cin >> S;
  if(S[2]==S[3] && S[4]==S[5]) Yes
  else No
  */

  int X;
  cin >> X;
  int ans=0;
  ans+=(X/500)*1000;
  X%=500;
  ans+=(X/5)*5;
  answer
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+3;
vector<int> g[N];
int used[N],cnt;
int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);cout.tie(0);
	set<int> st;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int h;
		cin>>h;
		st.insert(h);	
	}
	if(st.size()==n)cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 9728
n = int(input())
m = n//3
mod = 10**9+7

dp = [[0]*n for _ in range(m)]

for i in range(2, n):
    dp[0][i] = 1

for i in range(1, m):
    for j in range(3, n):
        dp[i][j] = dp[i-1][j-3] + dp[i][j-1]

ans = 0
for i in range(m):
    ans += dp[i][-1]
    ans %= mod
print(ans)


Measured memory_bytes: 89184
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

x = inp()
ans = 0
a = x // 500
b = (x - a * 500) // 5
print(a * 1000 + b * 5)

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

ll gcd(ll a, ll b)
{
    ll tmp = 0;

    a = abs(a);
    b = abs(b);

    while (b != 0) {
        if (b < a) {
            tmp = a;
            a = b;
            b = tmp;
        }
        b = b % a;
    }
    return a;
}

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

    ll ans = 0;
    roop(i, 1, k+1)roop(j, 1, k+1)roop(l, 1, k+1){
        ll tmp = gcd(i, j);
        tmp = gcd(tmp, l);
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define INF 1e9
typedef long long LL;
const LL mod = 1e9+7;

int main() {
  vector<vector<char>> C(3, vector<char>(3));
  rep(i,3) rep(j,3) cin >> C[i][j];
  
  cout << C[0][0] << C[1][1] << C[2][2] << endl;
  
  return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs'

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')
const [n, m, x] = input[0].split(' ').map(x => +x)
const ac = input.slice(1).map(y => y.split(' ').map(x => +x))
const ac_T = ac[0].map((_, i) => ac.map(x => x[i]))
let ans = -1
for (let i = 1; i < 2 ** n; i++) {
  const flag = i.toString(2).padStart(n, '0').split('').map(x => x == true)
  const a = ac_T[0].filter((_, idx) => flag[idx]).reduce((acc, cur) => acc + cur, 0)
  let tmp = true
  for (let j = 0; j < m; j++) {
    const c = ac_T[j+1].filter((_, idx) => flag[idx]).reduce((acc, cur) => acc + cur, 0)
    if (c < x) {
      tmp = false
      break
    }
  } 
  if tmp {
    ans = (ans == -1) ? a : Math.min(ans, a)
  }
}
console.log(ans)

Measured memory_bytes: 35812
s=gets.chomp
d=s.size
f=->x,y{
  p1=x!=y||d==1&&x>s[0].to_i ? 0 : 1
  p2=case d
  when 1
    0
  when 2
    x<s[0].to_i||x==s[0].to_i.to_i&&y<=s[1].to_i ? 1 : 0
  else;
    x<s[0].to_i ?
      (10**(d-1)-1)/9 :
    x>s[0].to_i ?
      (10**(d-2)-1)/9 :
      (10**(d-2)-1)/9 + s[1,d-2].to_i + ( y<=s[d-1].to_i ? 1 : 0 )
  end
  p1+p2
}
puts (1..9).reduce(0){|t,i| t+f[i,i]**2 }+[*1..9].combination(2).reduce(0){|t,(i,j)| t+f[i,j]*f[j,i] }*2

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]

    td = 0

    for i, j in enumerate(b):
        mi = min(a[i], j)
        td += mi + min(j - mi, a[i + 1])
        a[i] -= mi
        a[i + 1] -= min(j - mi, a[i + 1])

    print(td)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 54540
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

const double PI = acos(-1);

int main() {
    int r=read();
    printf("%.5f\n", 2*PI*r);
}

Measured memory_bytes: 3760
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int64_t N;
  cin >> N;
  
  int64_t mx = 0;
  vector<int64_t> nums(N);
  for (int n = 0; n < N; ++n) {
    cin >> nums[n];
    mx = max(mx, nums[n]);
  }
  int64_t half1 = mx / 2;
  int64_t half2 = mx % 2 == 0 ? half1 : half1 + 1;
  
  int64_t diff = mx; int64_t small = 0;
  for (int64_t n : nums) {
    if (n == mx) continue;
    int64_t tmp_diff = min(abs(n - half1), abs(n - half2));
    if (tmp_diff < diff) {
      diff = tmp_diff;
      small = n;
    }
  }
  cout << mx << " " << small << endl;
  
  return 0;
}


Measured memory_bytes: 4036
#include <cstdio>
#include <cstring>

int main(){
    char str[1001];
    
    while(1){
        scanf("%s", str);
        if (str[0] == '0') break;
        int sum = 0;
        for(int i = 0; i < strlen(str); i++){
            sum += (str[i] - '0');
        }
        printf("%d\n", sum);
    }

}



Measured memory_bytes: 2692