akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

const int MAX = 1e7;
ll 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;
    }
}
//二項係数
ll 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;
}

//繰り返し二乗法
ll EX(ll x,ll n){
    if(n == 0)return 1;
    else if(n%2 == 1)return EX(x,n-1)*x%mod;
    else return EX(x*x%mod,n/2)%mod;
};

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    ll ans = 0;
    int n = s.size();
    COMinit();
    for(int i = 0; i <= k; i++){
        ans += (COM(n-1+k-i,n-1)*EX(25,k-i))%mod*EX(26,i)%mod;
        ans %= mod;
    }
    cout << ans%mod << endl;
    return 0;
}

Measured memory_bytes: 238600
import collections
s = input()
alph = "abcdefghijklmnopqrstuvwxyz"
col = dict(collections.Counter(s))

flag = True
for i in range(26):
    if col.get(alph[i], 0) > 1:
        print("no")
        flag = False
        break
if flag:
    print("yes")


Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main(){
    int N;
    int x[100001];
    int cnt = 0;
    cin >> N;
    for(int i = 1; i <= N; i++){    
        cin >> x[i];
    }
    for(int i = 1; i <= N-1; i++){    
        if(x[i] == i){
            cnt++;
            int tmp = x[i];
            x[i] = x[i+1];
            x[i+1] = tmp;
        } 
    }
    if(x[N] == N) cnt++;
    cout << cnt << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>A(N);
  vector<int>B(N);
  vector<int>C(N-1);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N-1; i++) {
    cin >> C.at(i);
  }
  
  int sat = 0;
  for (int i = 0; i < N; i++) {
    sat += B.at(i);
    if (i < N-1){
      if (A.at(i)+1 == A.at(i+1)){
        sat += C.at(A.at(i)-1);
      }
    }
  }
  cout << sat << endl;
}



Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = 0;
		int y = 0;
		int t = 0;
		for(int i = 0; i < n; i++) {
			int targetT = sc.nextInt();
			int targetX = sc.nextInt();
			int targetY = sc.nextInt();
			if((targetT -t) < (Math.abs(targetX -x) + Math.abs(targetY -y))) {
				System.out.println("No");
				return;
			}
			if((targetT -t) == (Math.abs(targetX -x) + Math.abs(targetY -y))) {
				x = targetX;
				y = targetY;
				t = targetT;
				continue;
			}
			if(((targetT -t) - ((Math.abs(targetX -x) + Math.abs(targetY -y)))) % 2 ==0) {
				x = targetX;
				y = targetY;
				t = targetT;
				continue;
			}else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

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

#define MAX_LEN 200000

int main(void){
	int n;
	int a[MAX_LEN], b[MAX_LEN];
	bool pushed[MAX_LEN];
	for(int i=0;i<MAX_LEN;++i) pushed[i] = false;

	cin >> n;
	for(int i=0;i<n;++i) cin >> a[i];
		

	for(int i=0;i<(n+1)/2;++i){
		if(!pushed[n-1 - i*2]){
			b[i] = a[n-1 - i*2];
			pushed[n-1 - i*2]=true;
		}

		if(n-1 -i*2 -1 >= 0 && !pushed[n-1 -i*2 -1]){
			b[n-1 - i] = a[n-1 -i*2 -1];
			pushed[n-1 -i*2 -1]=true;
		}
	}

	for(int i=0;i<n;++i) {
		if(i != 0) cout << ' ';
		cout << b[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>
#include <string.h>
int main(void)
{
  char str[1110];
  int a[1110];
  int n;
  int i;
  int j=0;

  while (1) {
    scanf("%s",str);
    if (str[0]=='0') break;
    n=strlen(str);
    for (i=0; i<n; i++) {
      a[j]+=str[i]-'0';
    }
    j++;
  }

  for(i=0; i<j; i++) {
    printf("%d\n",a[i]);
  }
  return 0;
}

Measured memory_bytes: 540
#include <stdio.h>

int heap[255];

int parent(int i) {
    return i/2;
}

int left(int i) {
    return 2*i;
}

int right(int i) {
    return 2*i+1;
}


int main(void) {
	int i, n, t;
	scanf("%d\n", &n);
	
	for(i=1;i<=n;i++) {
		scanf("%d", &heap[i]);
	}

	for(i=1;i<=n;i++) {
		int r, l;
		printf("node %d: key = %d,",i, heap[i]);
		if(i>1) {
			printf(" parent key = %d,",heap[parent(i)]);
		}
		l = left(i);
		r = right(i);
		if(l <= n) printf(" left key = %d,", heap[l]);
		if(r <= n) printf(" right key = %d,", heap[r]);
		printf(" \n");
	}
	
	return 0;
}



Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	ll ans1=0, ans2=0;

	cin>>n;

	vll a(n), b(n), sum(n+1, 0);

	rep(i, n){
		cin>>a[i];
	}
	b=a;

	repr(i, 1, n+1){
		sum[i]=sum[i-1]+a[i-1];
		ll temp=labs(sum[i])+1;
		if(i%2){
			if(sum[i]>=0){
				a[i-1]-=temp;
				ans1+=temp;
			}
		}else{
			if(sum[i]<=0){
				a[i-1]+=temp;
				ans1+=temp;
			}
		}
		sum[i]=sum[i-1]+a[i-1];
	}
	//rep(i, n) cout<<a[i]<<" ";
	//cout<<endl;

	a=b;
	repr(i, 1, n+1){
		sum[i]=sum[i-1]+a[i-1];
		ll temp=labs(sum[i])+1;
		if(i%2){
			if(sum[i]<=0){
				a[i-1]+=temp;
				ans2+=temp;
			}
		} else{
			if(sum[i]>=0){
				a[i-1]-=temp;
				ans2+=temp;
			}
		}
		sum[i]=sum[i-1]+a[i-1];
	}
	//rep(i, n) cout<<a[i]<<" ";
	//cout<<endl;

	if(ans1<ans2){
		cout<<ans1<<endl;
	}else{
		cout<<ans2<<endl;
	}
	
}

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

using namespace std;

const int N = 1e5 + 5;
long long solve(std::vector<int> v, int b){
	long long ret = 0;
	for(int i = 0; i < v.size(); i++){
		ret += abs(v[i] - b);
	}
	return ret;
}
int main(){
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
// #else
// 	ios_base::sync_with_stdio(0);
// 	cin.tie(0);
// #endif
	int n;
   	cin >> n;
   	std::vector<int> v(n);
   	long long sum = 0;
   	for(int i = 0; i < n; i++){
   		cin >> v[i];
   		v[i] -= (i + 1);
   		sum += v[i];
   	}
   	sort(v.begin(), v.end());
   	sum /= n;
   	long long ans = LLONG_MAX;
   	for(int i = sum - 10; i <= sum + 10; i++)
   		ans = min(ans, solve(v, i));
   	ans = min(ans, solve(v, v[n/2]));
   	ans = min(ans, solve(v, v[(n + 1)/2]));
   	cout << ans << '\n';


	return 0;
}


Measured memory_bytes: 1800
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]

dp = [0] * W
dp[0] = s = 1 << 6400

for a, b in zip(A, B):
    for j, (aa, bb) in enumerate(zip(a, b)):
        d = abs(aa - bb)
        if j > 0:
            dp[j] |= dp[j - 1]
        dp[j] = (dp[j] << d) | (dp[j] >> d)

g = dp[-1]
for i in range(6401):
    if g & (s << i) or g & (s >> i):
        print(i)
        quit()

Measured memory_bytes: 3444
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi T(n);
  Vi X(n);
  Vi Y(n);
  REP(i,n){
    IN3(T[i],X[i],Y[i]);
  }
  int time = 0;
  bool ok = true;
  REP(i,n){
    int difftime = T[i] - time;
    time = T[i];
    int diffdis = abs(X[i] - x) + abs(Y[i] - y);
    x = X[i];
    y = Y[i];
    if(difftime % 2 != diffdis % 2 || difftime < diffdis) {
      ok = false;
      break;
    }
  }
  Yes(ok);
}

Measured memory_bytes: 2560
#include <stdio.h>

int solve(int, int);

int n, A[20];

int main(void)
{
	int i, q, m[200];
	
	scanf("%d",&n);
	for (i=0; i<n; i++) {
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for (i=0; i<q; i++) {
		scanf("%d",&m[i]);
	}
	
	for (i=0; i<q; i++) {
		if( solve(0,m[i]) ) {
			printf("yes\n");
		} else {
			printf("no\n");
		}
	}
	
	return 0;
}

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

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

int main(){
  ll m1,d1,m2,d2;
  cin>>m1>>d1;
  cin>>m2>>d2;
  if(m1!=m2){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  int minN = v[0];
  int ans = n;
  for(int i = 0; i < n; ++i){
    if(minN < v[i])ans--;
    ChangeMin(minN, v[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
'''
Problem Link - https://atcoder.jp/contests/abc176/tasks/abc176_c
'''
from sys import stdin,stdout
from math import *
from collections import *

mod = 1000000007

def gcd(a,b):
	while b:
		a,b = b,a%b
	return a

def lcm(a,b): return (a*b) // gcd(a,b)

def set_bits(X):
	c = 0
	while X:
		X &= (X-1);c += 1
	return c

def compute_MOD(N,M): return (N%M + M) % M

def get_array(): return list(map(int, stdin.readline().split()))
 
def get_ints(): return map(int, stdin.readline().split())

def get_int(): return int(stdin.readline())

def get_input(): return stdin.readline().strip()

def main():
    tc = get_int()
    arr = get_array()
    ans = 0
    Max = arr[0]
    for i in arr[1:]:
    	Max = max(Max,i)
    	ans += Max-i
    stdout.write(str(ans)+'\n')
if __name__ == "__main__":
    main()

Measured memory_bytes: 34292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e8;
int main(){
  int n, m, R;
  cin >> n >> m >> R;
  vector<int> per(R);
  vector<vector<int>> a(n,vector<int>(n,INF));
  rep(i,R) cin >> per[i], per[i]--;
  rep(i,n) a[i][i] = 0;
  rep(i,m) {
    int u, v, c;
    cin >> u >> v >> c;
    u--; v--;
    a[u][v] = c;
    a[v][u] = c;
  }
  rep(k,n) rep(i,n) rep(j,n) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);

  
  int res = INF;
  sort(per.begin(), per.end());
  do {
    int d = 0;
    rep(i,R-1) {
      d += a[per[i]][per[i+1]];
    }
    res = min(res,d);
  } while (next_permutation(per.begin(), per.end()));
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    ll as=0;
    ll tot = 0;
    bool sawb = false;
    for(char c:s) {
        if(c=='A') {
            if(sawb) {
                sawb=false;
                as = 0;
            }
            ++as;
        }
        else if(c=='B') {
            if(sawb) {
                as = 0;
                sawb = false;
            }
            else sawb = true;
        }
        else if(c=='C') {
            if(sawb) {
                tot+=as;
                sawb=false;
            }
            else as = 0;
        }
    }
    cout<<tot<<endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<string> vs;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<pair<string, ll> > vsi;
typedef set<ll> si;
typedef map<ll, ll> mii;
typedef map<string, ll> msi;
typedef tuple<ll, ll, ll> ti;
 
 
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
 
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
 
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __evars_out_var(a);
    cerr << "; ";
    __evars(++it, args...);
}
 
 
#define pb push_back
#define mk make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define mod 1000000007
#define ff first
#define ss second
 
 
//Loops
#define REP(i, b) for(ll i=0; i<(ll)(b); i++)
#define F(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define FD(i, a, b) for(ll i=(ll)(a); i>=(ll)(b); i--)
 
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL);
#define RTIME(start, end) ((double)(end-start)/(double)CLOCKS_PER_SEC)
#define D(a) cout<<a<<endl
#define MAX 1000007
//#define INF 1e18
 
const ll nmax=1000*1007;
    

struct edge
{
    ll a, b, cost;
    edge(ll x, ll y, ll z):a(x), b(y), cost(z) {};
};
 
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);   
 
}
 

int main ()
{
    fastio()
 
    ll n;
    ld ans=0;
    cin>>n;
    vi v(n);
    REP(i, n)
        cin>>v[i];
    REP(i, n)
    {
        ans+=(ld)((ld)1/(ld)v[i]);
    }
    cout<<fixed<<setprecision(10)<<(ld)(1/ans)<<endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();

        int[] cnt = new int[n];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                for (int k = 1; k <= n; k++) {
                    int tmp = calc(i, j, k, n);
                    if (tmp == -1)
                        break;
                    cnt[tmp-1]++;
                }
            }
        }

        PrintWriter pw = new PrintWriter(System.out);
        for (int i : cnt) {
            pw.println(i);
        }

        pw.flush();
    }

    static int calc(int x, int y, int z, int n) {
        int tmp = x*x + y*y + z*z;
        if (tmp > n)
            return -1;
        tmp += x*y + y*z + z*x;
        if (tmp > n)
            return -1;

        return tmp;
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 33812
#include<iostream>
#include<string>

using namespace std;
int main(){

  int N;
  cin >> N;

  float A;
  float sum =0;
  for(int i=0;i<N;i++){
    cin >> A;
    float inv = 1/A;
    sum =sum+inv;

  }

  cout <<  1/sum  << endl;
  return 0;



}

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

int main() {
  int n, x[10], i;
  cin >> n;
  for (i = 1; i <= 9; i++) {
    x[i] = 100 * i + 10 * i + i;
  }
  if (x[n / 100] - n >= 0) {
    cout << x[n / 100] << "\n";
  } else {
    cout << x[n / 100 + 1] << "\n";
  }
  return 0;
}

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

int main(){
    long long n, k;
    cin >> n >> k;
    long long a;
    a = n % k;
    if((k - a) < a){
        a = k - a;
    }
    cout << a << endl;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
       int x,y;   
       while(1){        cin>>x>>y;        
       if(x==0 && y==0)break;       
       if(x<y){            
           cout<<x<<" "<<y<<endl;       
       }       
       else{           
           cout<<y<<" "<<x<<endl;       
           }    
           }       
           return 0;
    
}



Measured memory_bytes: 2988
#include<stdio.h>

int main(void){

  int a,b,plus,cross;
  scanf("%d%d",&a,&b);
  plus = a + b;
  cross = a * b;

  if(plus == 15){
    printf("+\n");
  }
  else if(cross == 15){
    printf("*\n");
  }
  else{
    printf("x\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long A, B, K;
  cin >> A >> B >> K;
  long long X = min(A, K);
  A -= X;
  K -= X;
  B -= min(B, K);
  cout << A << " " << B << '\n';
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>

using namespace std;

string reverse(string s) {
    string converted = "";
    for (int i = 0; i < (int)s.length(); ++i) {
        converted += s[s.length() - i - 1];
    }
    return converted;
}

string decrypt(string cipher) {
    int begin;
    int nest = 0;
    int rot = 0;
    string plain = "";
    for (int i = 0; i < (int)cipher.length(); ++i) {
        if (cipher[i] == '[') {
            if (nest == 0) {
                begin = i;
            }
            ++nest;
        } else if (cipher[i] == ']') {
            --nest;
            if (nest == 0) {
                plain += reverse(decrypt(cipher.substr(begin + 1, i - begin - 1)));
            }
        } else if (nest == 0) {
            switch (cipher[i]) {
                case '+':
                    rot = (rot + 1) % 26;
                    break;
                case '-':
                    rot = (rot + 25) % 26;
                    break;
                case '?':
                    plain += '?';
                    rot = 0;
                    break;
                default:
                    plain += (cipher[i] - 'A' + rot) % 26 + 'A';
                    rot = 0;
            }
        }
    }
    return plain;
}

int main() {
    string cipher, plain;
    while (true) {
        cin >> cipher;
        if (cipher == ".") {
            return 0;
        }
        plain = decrypt(cipher);
        for (int i = 0; i < (int)plain.length(); ++i) {
            if (plain[i] == '?') {
                plain[i] = 'A';
            }
        }
        cout << plain << endl;
    }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back

using namespace std;

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

const int MAXN = 2e5 + 10;

ll n, m;
ll cnt[MAXN];

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

	cin >> n >> m;
	for(int i=1; i<=m; i++){
		int cl, cr;
		cin >> cl >> cr;
		cnt[cl]++;
		cnt[cr+1]--;
	}

	int ans = 0;
	for(int j=1; j<=n; j++){
		cnt[j] += cnt[j-1];
		if(cnt[j] == m) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1152
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n; string s, t;
	cin >> n >> s >> t;
	vector<int> sps = { 0 }, spt = { 0 };
	for (int i = 1; i < n; ++i) {
		if (s[i - 1] != s[i]) {
			sps.push_back(i);
		}
		if (t[i - 1] != t[i]) {
			spt.push_back(i);
		}
	}
	sps.push_back(n);
	spt.push_back(n);
	int parity = (s[0] == t[0] ? 0 : 1);
	int ls = sps.size(), lt = spt.size(), ans = (1 << 30);
	for (int i = -ls + 1; i < lt; ++i) {
		if (abs(i) % 2 != parity) continue;
		int sum = 0;
		for (int j = -lt + 1; j < ls + lt; ++j) {
			int ps = j - i;
			if (ps < 0) ps = 0;
			else if (ps >= ls) ps = n;
			else ps = sps[ps];
			int pt = j;
			if (pt < 0) pt = 0;
			else if (pt >= lt) pt = n;
			else pt = spt[pt];
			sum += abs(ps - pt);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n,m;

bool is_war(const vector<int>&x, const vector<int>&y){
	return *max_element(x.begin(), x.end())>=*min_element(y.begin(),y.end());
}

int main(){
	cin>>n>>m;
	vector<int> x(n+1),y(m+1);
	cin>>x[0]>>y[0];
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	for(int i=1;i<=m;i++){
		cin>>y[i];
	}
	if(is_war(x,y))
		cout<<"War"<<endl;
	else
		cout<<"No War"<<endl;
	return 0;

}

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

int main(){
    ll t=1;
    //cin>>t;
    ll ans=1;
    bool val=false;
    while(t--){
        ll n;
        cin>>n;
        
        for(ll i=0;i<n;i++){
            ll p;
            cin>>p;
            if(p==0) {
                ans=0;
                val=false;
                break;
                
            }
            if(log10(p)+log10(ans)>18.0000){
                ans=1;
                val=true;
            } 
            else ans*=p;
        }
    
    }
    if(ans>=1000000000000000001 || val) cout<<"-1";
    else cout<<ans;
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
static const double pi = 3.141592653589793;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int main(){
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double alpha = (H * 60 + M) / 720 * (pi * 2);
  double beta = M / 60 * (pi * 2);
  double theta = alpha - beta;
  double res = sqrt(A*A + B*B - 2.0*A*B*cos(theta));
  cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 4200
//from PKU1125
#define M 299
double dist[M][M],d;
next[M][M],x[M],y[M];
main(){
	int k,n,i,j;
	for(;scanf("%d",&n),n;){
		/*initialize*/
		for(i=1;i<=n;i++)scanf("%d",&j),scanf("%d%d",x+j,y+j);
		for(i=1;i<=n;i++)for(j=1;j<=n;next[i][j]=j,j++)
			dist[i][j]=(d=hypot(x[i]-x[j],y[i]-y[j]))<50.1?d:M;

		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++){
						if(dist[i][j]>dist[i][k]+dist[k][j])
							dist[i][j]=dist[i][k]+dist[k][j],next[i][j]=next[i][k];
					}
		}

		{/*query*/
			for(scanf("%d",&k);k;k--){
				if(scanf("%d%d",&i,&j),dist[i][j]>=M){puts("NA");continue;}
				for(n=i;n!=j;n=next[n][j])printf("%d ",n);
				printf("%d\n",j);
			}
		}
	}exit(0);
}

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

using namespace std;

#define endl '\n'
#define Opy ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)

typedef long long ll;

int main()
{
    Opy;

/*-------------------------------------------------
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
-------------------------------------------------*/
    char A[150];

    cin>> A;

    for(int i = 0; i < strlen(A); i++)
    {
        cout<< "x";
    }

    cout<< endl;

    return 0;
}



Measured memory_bytes: 3648
n = input()
s = input()

n = int(n)

alp = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", \
       "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

res = ""

for i in range(len(s)):
  res = res + alp[(alp.index(s[i]) + n) % 26]
  
print(res)

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

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			int pass = 0;
			var s = "";
			while((s = Console.ReadLine()) != null)
			{
				var arr = s.ToCharArray();
				for(var i = 0; i < s.Count(); i++)
				{
					if(Char.IsDigit(arr[i]))
					{
						var c = new System.Collections.Generic.List<char>();
						while(i < s.Count() && Char.IsDigit(arr[i]))
						{
							c.Add(arr[i]);
							i++;
						}
						pass += int.Parse(new string(c.ToArray()));
					}
				}
			}
			Console.WriteLine(pass);
		}
	}
}

Measured memory_bytes: 5836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
const ll MAX=200010;
const ll MAX_P=200010;
ll N,M,K;
ll fact[MAX_P];
void make_fact(){
  fact[0]=fact[1]=1;
  for(ll i=2;i<MAX_P;i++){
    fact[i]=(fact[i-1]*i)%MOD;
  }
}
ll Extgcd(ll a,ll b,ll &x,ll &y){
  ll d=a;
  if(b!=0){
    Extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }
  else{
    x=1;y=0;
  }
  return d;
}

ll mod_inv(ll a,ll p){//mod pでのaの逆元を求める
  ll x,y;
  Extgcd(a,p,x,y);
  return (x%p+p)%p;
}
//n!=a*p^e (a,p互いに素,p素数) とした時のeとa mod p を求める
ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  
  ll res=mod_fact(n/p,p,e);
  e+=n/p;

  if(n/p%2!=0) return res*(p-fact[n%p])%p;
  return res*fact[n%p]%p;
}

//nCk mod pを求める
ll mod_comb(ll n,ll k,ll p){
  if(n<0||k<0||n-k<0) return 0;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inv(a2*a3%p,p)%p;
}
void solve(){
  make_fact();
  ll res=0;
  //全組み合わせの2点のマンハッタン距離の総和
  /*  rep1(i,N){
    ll X=((N+1-i)*(N-i)/2%MOD+i*(i-1)/2%MOD)*(M*M%MOD)%MOD;
    res=(res+X)%MOD;
  }
  rep1(i,M){
    ll Y=((M+1-i)*(M-i)/2%MOD+i*(i-1)/2%MOD)*(N*N%MOD)%MOD;
    res=(res+Y)%MOD;
  }
  res/=2;*/
  ll m=M*M%MOD,n=N*N%MOD;
  rep(i,N){
    ll X=((((N-i)*m)%MOD)*i)%MOD;
    res=(res+X)%MOD;
  }
  rep(i,M){
    ll Y=((((M-i)*n)%MOD)*i)%MOD;
    res=(res+Y)%MOD;
  }
  
  if(K!=2){
    ll com=mod_comb(N*M-2,K-2,MOD);
    res=(res*com)%MOD;
  }
  prin(res);
  
}
int main(){
  cin>>N>>M>>K;
  solve();
  return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define all(m) m.begin(), m.end()
#define uid uniform_int_distribution
#define init(m, x) memset(m, x, sizeof(m));
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    str x, y; cin>>x>>y;
    int a = x.size(), b = y.size();
    ll o = 1000203;
    for(int q=0; q+b<=a; q++){
        int tyt = 0;
        for(int i=0; i<b; i++){
            tyt += x[q+i]!=y[i];
        }
        o = min(o, (ll)tyt);
    }
    cout<<o;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

ll mod=1000000007;

int main(){
    ll N = ii();
    ll M = ii();
    ll K = ii();
    vector<ll> A;
    vector<ll> B;
    ll t=0;
    A.push_back(0);
    REP(i,0,N){ t+=ii(); A.push_back(t); }

    t=0;
    REP(i,0,M){ t+=ii(); B.push_back(t); }

    ll ret = 0;
    REP(i,0,N+1){
        if(A[i]>K){
            continue;
        }
        ll rt = K-A[i];
        auto it = std::upper_bound(B.begin(), B.end(), rt);
        if (it != B.end()) {
            auto b = std::distance(B.begin(), it);
            ret=max((ll)b+i, ret);
        }else{
            ret=max(ret,(ll)B.size()+i);
        }
    }
    oie(ret);
    return 0;
}

Measured memory_bytes: 7940
from functools import reduce
from itertools import combinations
from math import gcd


def func(A):
    is_A = [0] * (10**6+1)
    for a in A:
        is_A[a] += 1
    if any(x > 1 for x in is_A[2:]):
        return False
    if sum(is_A[i] for i in range(2, 10**6+1, 2)) > 1:
        return False
    for i in range(3, 10**6+1, 2):
        if sum(is_A[j] for j in range(i, 10**6+1, i)) > 1:
            return False
    return True


def solve():
    N = int(input())
    A = list(map(int, input().split()))
    if func(A):
        # if not all(gcd(i, j)==1 for i, j in combinations(A, 2)):
        #     raise NameError
        print('pairwise coprime')
    elif reduce(gcd, A) == 1:
        print('setwise coprime')
    else:
        print('not coprime')
    

if __name__ == '__main__':
    solve()

Measured memory_bytes: 199040
# coding: utf-8

s = input()
t = input()
size = len(s)

s_list = [0] * size
t_list = [0] * size

for i in range(size):
  s_list[i] = s.index(s[i])
  t_list[i] = t.index(t[i])

if s_list == t_list:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 44912
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define fio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

map<int,int> m;
vi v;

int main() {	
	int k,n;
	fio;
	cin >> n >> k;
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		++m[a];
	}
	int d = 0;
	int ans = 0;
	for(auto p : m) {
		v.pb(p.se);
	}
	sort(v.rbegin(),v.rend());
	for(int i = k; i < v.size(); ++i)
		ans += v[i];
	cout << ans << "\n";
}

Measured memory_bytes: 10744
#include <bits/stdc++.h>
#define REPi(n) for(int i=0;i<n;i++)
#define REPj(n) for(int j=0;j<n;j++)

using namespace std;

int main(){
    long n,a,b,ans;
    cin >> n >> a >> b;
    long temp=n%(a+b);
    ans=a*(n/(a+b));
    if(temp>=a){
        temp=a;
    }
    ans+=temp;


    
    cout << ans << endl;
    return 0;
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    int s = a + b + c;
    cout << min({s-a,s-b,s-c}) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define asort(x) sort((x).begin(), (x).end())
#define rsort(x) sort((x).rbegin(), (x).rend())
using namespace std;
ll knap(ll wt[], ll val[], ll w, ll n)
{
    ll dp[n+1][w+1];
   for(int i=0;i<=n;i++)
   for(int j=0;j<=w;j++)
   {
       if(i==0 || j==0)
       dp[i][j]=0;
   }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j>=wt[i-1])
            dp[i][j] = max(val[i-1] + dp[i-1][j-wt[i-1]], dp[i-1][j]);
            else
            {
                dp[i][j] = dp[i-1][j];
            }
            
        }
    }
    return dp[n][w];
}
int main()
{
    ll n,w;
    cin>>n>>w;
    ll wt[n],val[n];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    ll ans=knap(wt,val,w,n);
    cout<<ans<<"\n";

}

Measured memory_bytes: 82328
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

auto input(size_t n) {
    return InputType2(n);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    size_t x = input();
    size_t c = 0;
    auto a = x / 500;
    c += 1000 * a;
    x -= a * 500;
    auto b = x / 5;
    c += 5 * b;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author gtpan77
 */

#include <bits/stdc++.h>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
const int N = (int)1e5+77;
const ll inf = (ll) 1e18+7;
const ll mod = (ll) 1e9+7;

class CManyFormulas {
    public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin>>s;
        int n = sz(s);
        ll ans = 0, cur;
        forn(i,1<<(n-1)) {
            cur = (s[0] - '0');
            forn(j,n-1) {
                if(i&(1<<j)) {
                    ans += cur;
                    cur = 0;
                }
                cur = cur*10 + (s[j+1] - '0');
            }
            ans += cur;
        }
        cout<<ans<<endl;
    }
};


int main() {
    fast;
    CManyFormulas solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
<?php
    $inArray = [];
    while (!feof(STDIN) ) {
        $inArray[] = trim(fgets(STDIN));
    }
    
    $baseStr = $inArray[0].$inArray[0];
    if(strpos($baseStr, $inArray[1]) === FALSE){
        echo "No\n";
    } else {
        echo "Yes\n";
    }
?>


Measured memory_bytes: 9240
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

double f(double sx, double sy, double sz, double gx, double gy, double gz){
    return sqrt((sx-gx)*(sx-gx)+(sy-gy)*(sy-gy)+(sz-gz)*(sz-gz));
}

double g(double p, double q, double m, double n){
    return (n*p+m*q)/(m+n);
}


int main(void) {
    int i,j;
    int n,q;
    cin >> n >> q;
    vector<double> x(n),y(n),z(n);
    vector<ll> r(n),l(n);
    rep(i,n) cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
    rep(k,q){
        ll ans = 0;
        double sx,sy,sz,gx,gy,gz;
        cin >> sx >> sy >> sz >> gx >> gy >> gz;
        double dis = f(sx,sy,sz,gx,gy,gz);
        rep(i,n){
            double lb = 0, ub = dis;
            rep(j,100){
                double m1 = (lb+lb+ub)/3.0;
                double m2 = (lb+ub+ub)/3.0;
                double px1 = g(sx,gx,m1,dis-m1);
                double py1 = g(sy,gy,m1,dis-m1);
                double pz1 = g(sz,gz,m1,dis-m1);
                double len1 = f(px1,py1,pz1,x[i],y[i],z[i]);
                double px2 = g(sx,gx,m2,dis-m2);
                double py2 = g(sy,gy,m2,dis-m2);
                double pz2 = g(sz,gz,m2,dis-m2);
                double len2 = f(px2,py2,pz2,x[i],y[i],z[i]);
                if(len1 < len2)ub = m2;
                else lb = m1;
            }
            double px = g(sx,gx,lb,dis-ub);
            double py = g(sy,gy,lb,dis-ub);
            double pz = g(sz,gz,lb,dis-ub);
            double len = f(px,py,pz,x[i],y[i],z[i]);
            //cout << shosu(10) << dis << " " << lb << " " << len << endl;
            if(len <= r[i] + EPS) ans += l[i];
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i].st
#define mod 1000000007
#define inf 1000000009
#define N 52
using namespace std;

typedef long long ll;
typedef pair < ll , ll > ii;

ll n, m, a[N], u[N], x[N], y[N];
ll ans;
vector < ii > g[N];
ll yol[N][N];

bool dfs(ll node, ll bas, ll son){
	if(u[node])
		return 0;
	u[node] = 1;
	if(node == son)
		return true;
	bool don = false;
	for(ll i = 0; i < g[node].size(); i++){
		if(dfs(coc, bas, son)){
			don = true;
			yol[bas][son] |= (1ll<<g[node][i].nd);
		}
	}
	return don;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	for(ll i = 1; i < n; i++){
		ll u, v;
		scanf("%lld %lld",&u ,&v);
		g[u].pb(mp(v, i));
		g[v].pb(mp(u, i));
	}
	for(ll i = 1; i <= n; i++)
		for(ll j = i + 1; j <= n; j++){
			memset(u, 0, sizeof u);
			dfs(i, i, j);
			// cout << yol[i][j] << endl;
			// for(ll k = 0; k < yol[i][j].size(); k++)
			// 	cout << yol[i][j][k] << " ";
			// cout << endl;
		}
	scanf("%lld",&m);
	for(ll i = 0; i < m; i++)
		scanf("%lld %lld",x + i, y + i);
	for(ll i = 0; i < (1ll<<m); i++){
		ll cur = 0;
		for(ll j = 0; j < m; j++){
			if( !((1ll<<j) & i) )
				continue;
			cur |= yol[x[j]][y[j]];
		}
		ll kac = __builtin_popcountll(cur);
		// cout << i << " " << n - 1 - kac << endl;
		if(__builtin_popcountll(i)%2)
			ans += (1ll<<(n - kac - 1));
		else
			ans -= (1ll<<(n - kac - 1));
		// cout << kac << endl;
	}
	cout << abs(ans) << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

int a, b, c, d, e, f;

int main() {
    cin >> a >> b >> c >> d >> e >> f;

    int water = 0, sugar = 0;
    double conc = 0.0;
    for (int i = 0; i < 30; i++) {
        for (int j = 0; j <= 30; j++) {
            for (int k = 0; k < 100; k++) {
                for (int l = 0; l <= 100; l++) {
                    int x = a * i + b * j;
                    int tw = 100 * x;
                    int ts = c * k + d * l;

                    if (ts > e * x) continue;
                    if (tw + ts > f) continue;
                    if (tw + ts == 0) continue;

                    double tc = (double)100*ts/(tw+ts);
                    if (chmax(conc, tc)) water = tw, sugar = ts;
                }
            }
        }
    }

    if (conc == 0) water = 100*a;
    cout << water+sugar << ' ' << sugar << endl;
}


Measured memory_bytes: 256
main :: IO()
main = do
  s <- getLine
  if validate s then
    putStrLn . show . nextDay . read $ s
  else
    error "error"

validate :: String -> Bool
validate "Sunny" = True
validate "Cloudy" = True
validate "Rainy" = True
validate _ = False

---------------------------------------------
data Weather = Sunny | Cloudy | Rainy
  deriving (Read, Show)



data Today = Today {
  weth :: Weather,
  temp :: Float,
  humidity :: Float
}

nextDay :: Weather -> Weather
nextDay Sunny = Cloudy
nextDay Cloudy = Rainy
nextDay Rainy = Sunny


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

int main(){
    int N, M, T; cin >> N >> M >> T;
    vector<int> a(N);
    for(int i=0; i<N; ++i) cin >> a[i];

    int res = a[0] - M;
    for(int i=0; i+1<N; ++i) res += max(a[i + 1] - a[i] - 2 * M, 0);
    res += max(T - a[N - 1] - M, 0);

    cout << res << endl;
}


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

int main()
{
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)
			break;
		
		for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					cout << '#';
			}
				cout << '\n';
		}
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3052