akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include<string.h>

int main(void)
{
    int kane = 100000;
    int kane2;
    int hi = 0;
    int i = 0;
    scanf("%d",&hi);
    
    while(hi > i){
        kane *= 1.05;
        if(kane % 1000 != 0){
            kane += 1000 - (kane % 1000);
        }
        
        i++;
    }
    
    printf("%d\n",kane);
    
	return 0;
}


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

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    string S;
    cin >> S;

    int len = S.size();
    
    int min = 999;
    for (int i = 0; i < len-2; i++) {
        int num = stoi(S.substr(i, 3));
        int dist = abs(753-num);
        if(dist < min) {
            min = dist;
        }
    }
    cout << min << endl;
}


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

int main() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  
  cout << double(W) * double(H) / 2;
  cout << ' ';
  
  if ((W%2==0 && x==W/2) && (H%2==0 && y==H/2)) {
 // if (x+x==W && y+y==H) {
    cout << 1;
  } else {
    cout << 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626

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

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    double ab = 2 * PI * n;
    cout << setprecision(20) << ab << endl;

    return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

struct edge{
  ll to, cost, time;
};

ll n, m, s;
vector<ll> C(51), D(51);
vector<vector<edge>> G(50);
vector<vector<ll>> d(50, vector<ll>(2600, inf));


void dijkstra(ll start, ll silver) {
	priority_queue<PiP, vector<PiP>, greater<PiP>>que;
	d[start][silver] = 0;
	que.push({0, {start, silver}});
	while (!que.empty()) {
		PiP p = que.top(); que.pop();
		ll v = p.second.first, cnt = p.second.second;
		if (d[v][cnt] < p.first)continue;
        if(cnt + C[v] <= 2501){
            if(chmin(d[v][cnt+C[v]], d[v][cnt] + D[v])){
                que.push({d[v][cnt+C[v]], {v, cnt+C[v]}});
            }
        }
      	rep(i, G[v].size()) {
			edge e = G[v][i];
        	if(cnt < e.cost)continue;
			if (chmin(d[e.to][cnt-e.cost], d[v][cnt] + e.time)) {
			    que.push({d[e.to][cnt-e.cost], {e.to, cnt-e.cost}});
			}
    	}
	}
}

int main(){
    cin >> n >> m >> s;
    rep(i, m){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        G[u-1].push_back({v-1, a, b});
        G[v-1].push_back({u-1, a, b});
    }
    rep(i, n)cin >> C[i] >> D[i];
    dijkstra(0, min(s, 2501LL));
    REP(i, n-1){
        ll ans = inf;
        rep(j, 2550)chmin(ans, d[i][j]);
        cout << ans << endl;
    }
}


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

int main(void)
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = h[0];
    rep(i,n-1) ans += max(0, h[i+1]-h[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
from collections import deque

n, x, y = [int(x) for x in input().split()]
x -= 1
y -= 1
BIG = 65521
ans = [0] * n


def bfs(start_v):
    """ある始点からほかの全点に行くまでの最短距離を求める。"""
    qu = deque()
    qu_append = qu.append
    qu_popleft = qu.popleft
    qu_append(start_v)
    # 始点からvに移動するまでの最短距離: dist[v]
    dist = [BIG] * n

    def push(v, d):
        """始点からvまでの最短距離が算出されていないときに，その距離を保存し，
        キューに頂点vを追加する。"""
        if dist[v] != BIG:
            # 既に訪問済みで距離が求められている。
            return
        dist[v] = d
        qu_append(v)

    push(start_v, 0)

    while len(qu):
        v = qu_popleft()
        # 始点からvの次の頂点へ移動する距離。
        d = dist[v] + 1
        if v < n - 1:
            push(v + 1, d)
        if v > 0:
            push(v - 1, d)
        if v == x:
            push(y, d)
        if v == y:
            push(x, d)

    for i in range(n):
        ans[dist[i]] += 1


def main():
    for i in range(n):
        bfs(i)

    for i in range(1, n):
        print(ans[i] // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 52060
import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String word = scan.next();
      	if(word.equals("G")){
        	System.out.println("C");
        } else if(word.equals("C")){
        	System.out.println("G");
        } else if(word.equals("T")){
        	System.out.println("A");
        } else {
        	System.out.println("T");
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    cout << (x-a)%b;
    
    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,t[ohara];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      rep(i,n)cin>>t[i];
      cin>>m;
      rep(i,m){
        cin>>a>>b;
        rep(j,n){
          if(j==a-1)ans+=b;
          else ans+=t[j];
        }
        Cout(ans);
        ans=0;
      }
     

       
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define FIR first
#define SEC second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll DP[10001];




int main() {
  IN(ll,H);
  IN(ll,N);
  A2IN(ll, A, ll, B ,N);
  Fill(DP,INF);
  DP[0] = 0;
  REP(i, N){
    for(ll j = 0; j <= H; j++){
      chmin(DP[j],DP[max(j - A[i],0LL)] + B[i]);
    }
  }
  OUT(DP[H]);
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str=br.readLine();
        Stack<Integer> stack =new Stack<>();
        Stack<int[]> sub_stack=new Stack<>();
        int sum=0;
        int temp_sum=0;
        int d=0;
        for(int i=0;i<str.length();i++){
            if(str.charAt(i)=='\\'){ d--; stack.push(i); }
            if(str.charAt(i)=='/' && !stack.isEmpty()){
                d++;
                int temp=stack.pop();
                sum+=(i-temp);
                temp_sum=(i-temp);
                while(!sub_stack.isEmpty() && sub_stack.peek()[0]>temp){ temp_sum+=(sub_stack.pop()[1]); }
                sub_stack.push(new int[]{temp,temp_sum});
            }
        }
        Stack<Integer> sum_stack=new Stack<>();
        while(!sub_stack.isEmpty()){ sum_stack.push(sub_stack.pop()[1]); }
        System.out.println(sum);
        System.out.print(sum_stack.size());
        while(!sum_stack.isEmpty()){ System.out.print(" "+sum_stack.pop()); }
        System.out.println();
    }
    
}

Measured memory_bytes: 26412
n,m,x,y=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_max=max(a)
b_min=min(b)
for i in range(x+1,y+1):
    if a_max<i and i<=b_min:
        print("No War")
        exit()
print("War")


Measured memory_bytes: 3060
import math

def main():
    N, D = map(int, input().split())
    points = []
    for i in range(N):
        p = [int(c) for c in input().split()]
        points.append(p)

    count = 0
    for i in range(N-1):
        for j in range(i+1, N):
            v = 0
            for k in range(D):
                v += pow(points[i][k]-points[j][k], 2)
            vsqrt = math.sqrt(v)
            if int(vsqrt) == vsqrt:
                count += 1
    return count

if __name__ == '__main__':
    print(main())

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1), B(N);

    for (int i = 0; i < N+1; i++){
        cin >> A[i];
    }

    for (int i = 0; i < N; i++){
        cin >> B[i];
    }

    long long ans = 0;
    long long count = 0;
    long long t = 0;

    for (int i = 0; i < N; i++){
        if (A[i] <= B[i]){
            ans += A[i];
            count = B[i] - A[i];
            if (A[i+1] - count >= 0){
                t = A[i+1] -count;
            } else {
                t = 0;
            }
            ans += A[i+1] - t;
            A[i+1] = t;

        } else {
            ans += B[i];
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	int cnt = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (i & 1)continue;
		if (a & 1)cnt++;
	}
	cout << cnt << endl;
	
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define INF (int)1e9

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int N, W;
long long A[101], B[101];
long long dp[101][100001];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> W;
	for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];
	for(int i = 0; i <= N; i++)
		for(int j = 0; j <= W; j++)
			if(i == 0 || j == 0) dp[i][j] = 0;
			else if(A[i] <= j) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - A[i]] + B[i]);
			else dp[i][j] = dp[i - 1][j];
	cout << dp[N][W] << "\n";
	return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}


int main(){
    long int w,a,b;
    cin >> w >> a >> b;
    if(a > b)
        swap(a,b);
    cout << (a + w < b ? b - a - w : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
//Robs Code
#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define all(x) x.begin(),x.end()
#define ed cout<<"\n";
#define pb push_back
#define pii pair<int,int>
#define _1 first
#define _2 second
#define maxi 100000007
/**********************************************************/
using namespace std;
int i,j,k,n,m,q,t,a,b,cnt,sum,tot;
signed main() 
{
    speed;
    vector<int> v(5);
    fri(0,4) cin>>v[i];
    cin>>a;
    for(i=0;i<4;i++){
        for(j=i+1;j<5;j++){
            if(abs(v[i]-v[j])>a){
                cout<<":(";
                return 0;
            }
        }
    }
    cout<<"Yay!";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

bool isprime(int x) {
    int d = 2;
    while(d * d <= x) {
        if(x % d == 0)
            return 0;

        d ++;
    }

    if(x > 1)
        return 1;
    return 0;
}

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int i;
    cin >> i;
    while(!isprime(i)) {
        i ++;
    }
    cout << i;

    return 0;
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split(' '))
A_list = list(map(int, input().split(' ')))
B_list = list(map(int, input().split(' ')))
C_list = list(map(int, input().split(' ')))

A_list.sort(reverse=True)
B_list.sort(reverse=True)
C_list.sort(reverse=True)

A_list = A_list[:X]
B_list = B_list[:Y]

all_list = []
all_list.extend(A_list)
all_list.extend(B_list)
all_list.extend(C_list)

all_list.sort(reverse=True)

res = 0
for i in range(X+Y):
    res += all_list[i]

print(res)


Measured memory_bytes: 23328
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
using namespace std;

vector<int> x, y;
double d(int i, int j) {
  return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

int main(void) {
  int n;
  cin >> n;
  x.resize(n);
  y.resize(n);
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i];

  double sum = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      sum += d(i, j);
      cnt++;
    }
  }

  cout << fixed;
  cout << setprecision(8) << sum * (n - 1) / cnt << endl;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

int main()
{
	int n;
	scanf("%d", &n);
	VInt len(n);
	int i;
	FOR(i, 0, n) scanf("%d", &len[i]);
	FOR(i, 1, n) if (len[i] <= len[i - 1]) break;
	if(i == n)
	{
		printf("1\n");
		return 0;
	}

	int mn = 1, mx = n;
	while(mx - mn > 1)
	{
		int md = (mx + mn) / 2;
		stack<PII> s;
		FOR(i, 0, n)
			if(i != 0 && len[i] <= len[i - 1])
			{
				int pos = len[i] - 1;
				while (!s.empty() && s.top().first > pos) s.pop();
				if (s.empty() || s.top().first != pos) s.push(PII(pos, 0));
				++s.top().second;
				while(s.top().first > 0 && s.top().second == md)
				{
					s.pop();
					--pos;
					if (s.empty() || s.top().first != pos) s.push(PII(pos, 0));
					++s.top().second;
				}

				if (pos == 0 && s.top().second == md) break;
			}

		if (i == n) mx = md;
		else mn = md;
	}
	printf("%d\n", mx);
	return 0;
};


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

void solve(){	
	
	int n ;
	cin>>n ;

	vector<ll> v(n) ; 
	rep(i,n){
		cin>>v[i] ;
	}	
	
	rep(i,n){
		if(v[i]==0){
			cout<<0 ;
			return ;
		}
	}

	ll prod=1 ;

	rep(i,n){
		if(v[i]<=1000000000000000000/prod){
			prod*=v[i] ;
		}
		else{
			cout<<-1 ;
			return ;
		}
	}

	cout<<prod ;
}


int main(){

	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3972
// JAI SHREE RAM
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	fast

	ll n;cin>>n;
	set<string> s;
	string c;
	FOR(i,n)
	{
		cin>>c;
		s.insert(c);
	}
	

	cout<<s.size();


}


Measured memory_bytes: 19164
S = input()
SA = S.replace('?', 'a')
T = input()

def test(i):
  # i文字目から初めてハマるかどうか確認
  S_sub = S[i:i+len(T)]
  for s,t in zip(S_sub,T):
    if s == '?':
      continue
    if s != t:
      return False
  return True

pw = []
for i in range(len(S)-len(T)+1):
  if test(i):
    x = SA[:i] + T + SA[i+len(T):]
    pw.append(x)

if pw:
  answer = sorted(pw)[0]
else:
  answer = 'UNRESTORABLE'

print(answer)

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

struct Point {
    int x;
    int y;
    int pair = -1;
};

bool red_sort(const Point &a, const Point &b) {
    if (a.y == b.y) {
        return (a.x < b.x);
    }
    
    return (a.y > b.y);
}

bool blue_sort(const Point &a, const Point &b) {
    if (a.x == b.x) {
        return (a.y < b.y);
    }
    
    return (a.x < b.x);
}

int main() {
    int n;
    cin >> n;
    vector<Point> red(n), blue(n);
    rep(i, n) cin >> red[i].x >> red[i].y;
    rep(i, n) cin >> blue[i].x >> blue[i].y;
    int ans = 0;
    
    sort(red.begin(), red.end(), red_sort);
    sort(blue.begin(), blue.end(), blue_sort);
    
    rep(i, n) {
        rep(ii, n) {
            if ((red[i].x < blue[ii].x) && (red[i].y < blue[ii].y) && (blue[ii].pair == -1)) {
                red[i].pair = ii;
                blue[ii].pair = i;
                ans++;
                break;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*In the name of Allah*/
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000111
#define MAX 200111
#define mod 998244353
#define ll long long

multiset<ll> s;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	ll ans = 1,x;
	cin>>n>>x;
	s.insert(inf - x);
	for(int i = 1; i < n; i++){
		cin>>x;
		auto it = s.upper_bound(inf - x);
		if(it != s.end()){
			// cout<<inf - *it<<" ";
			s.erase(it);
			s.insert(inf - x);
		}else{
			s.insert(inf - x);
			ans++;
		}
	}
	cout<<ans;

	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    ll N;
    cin>>N;
    v L(N);
    rep(i,0,N)cin>>L[i];

    sort(all(L));
    ll sum =0;
    rep(i,0,N-1)sum += L[i];
    
    YN(sum > L[N-1]);
    return 0;
}

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

typedef long long ll;

 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if((b*10+c)%4==0){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a)]
c.sort()
DP=[[0 for j in range(b+1)]for i in range(a)]
for i in range(c[0][0],b+1):
  DP[0][i]+=c[0][1]
for i in range(1,a):
  for j in range(b):
    if j<c[i][0]:
      DP[i][j]=DP[i-1][j]
    else:
      DP[i][j]=max(DP[i-1][j-c[i][0]]+c[i][1],DP[i-1][j])
  DP[i][b]=max(DP[i-1][b-1]+c[i][1],DP[i-1][b])
print(max(DP[-1]))
    


Measured memory_bytes: 123736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace attocoda
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b;
            n = int.Parse(Console.ReadLine());
            if (n == 1)
                Console.WriteLine("Hello World");
            else if(n==2)
            {
                a = int.Parse(Console.ReadLine());
                b = int.Parse(Console.ReadLine());
                Console.WriteLine(a + b);
            }
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(N)RV(A,N-1);
  std::vector<i8t> C(N,0);
  F(I,N-1){
    C[A[I]-1]++;
  }
  F(I,N){
    P(C[I]);
  }
  return 0;
}


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

#define int long long

#define rep(i,s,n) for(int i = (s);i<(n);i++)
#define repe(i,s,n) for(int i = (s);i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;

int a,b,c;

signed main(){
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<endl;
        return 0;
    }
    int x=max(a,max(b,c));
    int cnt=a*b*c;
    int ans=min({b*c,c*a,a*b});
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)

l = 0
r = K - 1
ans = Float::INFINITY
while r < N
  dist = X[r] - X[l]
  ans = [ans, X[r].abs + dist,  X[l].abs + dist].min
  l += 1
  r += 1
end

puts ans


Measured memory_bytes: 11012
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
#include <map>
#include <stack>
 
using namespace std;

typedef long long ll;

class UnionFind {
private:
	vector<ll> parents;
	vector<ll> ranks;

public:
	vector<ll> sizes;

	UnionFind(ll s): parents(s), ranks(s), sizes(s, 1) {
		for(ll i = 0; i < s; i++) parents[i] = i;
	}

	int find(ll x) {
		if(parents[x] == x) return x;
		else return parents[x] = find(parents[x]);
	}

	void unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(ranks[x] < ranks[y]) {
			parents[x] = y;
			sizes[y] += sizes[x];
		} else {
			parents[y] = x;
			sizes[x] += sizes[y];
			if(ranks[x] == ranks[y]) ranks[x]++;
		}
	}

	bool same(ll x, ll y) {
		return find(x) == find(y);
	}
};

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

    int N, M, K;

    cin >> N >> M >> K;

    UnionFind uf(N);

    vector<int> C(K), D(K);

    vector<int> J(N);

    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
        J[a]++;
        J[b]++;
    }

    for(int i = 0; i < K; i++) {
        cin >> C[i] >> D[i];
        C[i]--;
        D[i]--;
    }

    vector<int> ans(N);

    for(int i = 0; i < N; i++) {
        ans[i] = uf.sizes[uf.find(i)] - J[i] - 1;
    }

    for(int i = 0; i < K; i++) {
        if(uf.same(C[i], D[i])) {
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }


    for(int i = 0; i < N; i++) {
        cout << ans[i] << " ";
    }

    cout << endl;
}


Measured memory_bytes: 4736
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int[][] students = new int[n][n];
			boolean[][] tallest = new boolean[n][n];
			boolean[][] shortest = new boolean[n][n];
			int[][] x = new int[n][n];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					students[i][j] = sc.nextInt();
				}
			}
			
			for(int i = 0; i < n; i++){
				int columnMax = -1, maxj = -1;
				for(int j = 0; j < n; j++){
					if(columnMax < students[j][i]){
						columnMax = students[j][i];
                        maxj = j;
                    }
				}
/*				if(columnMax == students[maxj][i]){
					tallest[maxj][i] = true;
					x[maxj][i] |= 2;
				}
*/				for(int j = 0; j < n; j++){
					if(columnMax == students[j][i]){
						tallest[j][i] = true;
						x[j][i] |= 2;
					}
				}
			}
			for(int i = 0; i < n; i++){
				int rowMin = Integer.MAX_VALUE, minj = -1;
				for(int j = 0; j < n; j++){
					if(rowMin > students[i][j]){
						rowMin = students[i][j];
                        minj = j;
                    }
				}
/*				if(rowMin == students[i][minj]){
					shortest[i][minj] = true;
					x[i][minj] |= 1;
				}
*/				for(int j = 0; j < n; j++){
					if(rowMin == students[i][minj]){
						shortest[i][minj] = true;
						x[i][minj] |= 1;
					}
				}
			}
			
			Set<Integer> both = new HashSet<Integer>();
            for(int i = 0;i < n;i++){
                for(int j = 0;j < n;j++){
                    if(x[i][j] == 3){
                        both.add(students[i][j]);
                    }
                }
            }
			
            if(both.size() == 1){
            	StringBuilder sb = new StringBuilder();
                for(int v : both){
                    sb.append(v + " ");
                }
                sb.deleteCharAt(sb.length() - 1);
                System.out.println(sb);
            }else{
            	System.out.println(0);
            }
/*			boolean noAns = true;
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(shortest[i][j] && tallest[i][j]){
						sb.append(students[i][j] + " ");
						noAns = false;
					}
				}
			}
			
			if(noAns){
				System.out.println(0);
			}else{
				sb.deleteCharAt(sb.length() - 1);
				System.out.print(sb);
			}
*/		}
		
	}
}

Measured memory_bytes: 19524
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  
  int th = b - a;
  
  int depth = 0;
  rep(i, th-1) {
    depth += i+1;
  }
  fin(depth - a);
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 02.09.2017 15:19:24       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 1234567;

int r[N], t[N], init[N];

int main() {
  int x, n;
  scanf("%d %d", &x, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", r + i);
  }
  int tt;
  scanf("%d", &tt);
  for (int i = 0; i < tt; i++) {
    scanf("%d %d", t + i, init + i);
  }
  int a = 0;
  int val_a = 0;
  int b = x;
  int val_b = x;
  int dir = -1;
  int out = -1;
  int ptr = 0;
  for (int i = 0; i <= n; i++) {
    while (ptr < tt && (i == n || t[ptr] <= r[i])) {
      int now = -1;
      if (init[ptr] <= a) {
        now = val_a;
      } else {
        if (init[ptr] >= b) {
          now = val_b;
        } else {
          now = val_a - out * (init[ptr] - a);
        }
      }
      now += (t[ptr] - (i == 0 ? 0 : r[i - 1])) * dir;
      now = max(now, 0);
      now = min(now, x);
      printf("%d\n", out == -1 ? now : x - now);
      ptr++;
    }
    if (i < n) {
      int pass = r[i] - (i == 0 ? 0 : r[i - 1]);
      val_a += dir * pass;
      val_b += dir * pass;
      if (val_a < 0) {
        a -= val_a;
        val_a = 0;
      }
      if (val_b < 0) {
        b += val_b;
        val_b = 0;
      }
      if (val_a > x) {
        a += (val_a - x);
        val_a = x;
      }
      if (val_b > x) {
        b -= (val_b - x);
        val_b = x;
      }
      if (a > b) {
        a = b = 0;
      }
      val_a = x - val_a;
      val_b = x - val_b;
      out = -out;
    }
//    cerr << "after " << i << ": " << a << " " << val_a << " " << b << " " << val_b << " " << out << endl;
  }
  return 0;
}


Measured memory_bytes: 5760
n,r,c,t,ans=int(input()),{"M":0,"A":0,"R":0,"C":0,"H":0},0,("M","A","R","C","H"),0
for i in range(n):
  s=input()
  if s[0] in r:
    if r[s[0]]==0:c+=1
    r[s[0]]+=1
for i in range(3):
  for j in range(i+1,4):
    for h in range(j+1,5):ans+=r[t[i]]*r[t[j]]*r[t[h]]
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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 main(){
	ll N,P;
	cin >> N >> P;
	ll p = P;
	
	map<ll,ll> prime;
	for(ll i=2; i*i<=P; ++i){
		if(p%i!=0) continue;
		while(p%i==0){
			prime[i] += 1;
			p = p/i;
		}
	}
	if(p!=1){
		prime[p] = 1;
	}
	
	ll ans = 1;
	for(auto x: prime){
		REP(i,x.second/N) ans *= x.first;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
using ld = long double;
using cd = complex<ld>;

ll cnt[70][70];

int main() {
    cout.precision(20); cout << fixed;
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ll a = 0, b = 0;
        int j = 0;
        for (; j < s.size() && s[j] != '.'; j++) {
            a *= 10;
            a += s[j] - '0';
        }
        j++;
        for (int u = 0; u < 9; u++) {
            b *= 10;
            if (j + u < s.size()) {
                b += s[j + u] - '0';
            }
        }
        ll x = a * 1e9 + b;
        int cnt2 = 0, cnt5 = 0;
        while (x % 2 == 0) {
            cnt2++;
            x /= 2;
        }
        while (x % 5 == 0) {
            cnt5++;
            x /= 5;
        }
        cnt[cnt2][cnt5]++;
    }
    ll ans = 0;
    for (int a = 0; a < 70; a++) {
        for (int b = 0; b < 70; b++) {
            for (int c = 0; c < 70; c++) {
                for (int d = 0; d < 70; d++) {
                    if (a + c >= 18 && b + d >= 18) {
                        if (a == c && b == d) {
                            ans += cnt[a][b] * (cnt[a][b] - 1);
                        } else {
                            ans += cnt[a][b] * cnt[c][d];
                        }
                    }
                }
            }
        }
    }
    cout << ans / 2;
}



Measured memory_bytes: 3656
#include <stdio.h>
#define M 10000
#define NIL -1
struct node {
    int parent , left , right;
};
struct node T[M];
int n,D[M],H[M];

void setDepth(int,int);
int setHeight(int);
int setSibling(int);
void print(int );

void setDepth(int u,int d){
    if(u == NIL)return;
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if( T[u].left != NIL){
        h1 = setHeight(T[u].left) + 1;
    }
    if(T[u].right != NIL){
        h2 = setHeight(T[u].right) + 1;
    }
    if(h1< h2){
        H[u] = h2;
        return H[u];
    }
    else {
        H[u] = h1;
        return H[u];
    }
}

int getSibling(int u){
    if( T[u].parent == NIL) return NIL;
    if( T[T[u].parent].left != u && T[T[u].parent].left != NIL){
           return T[T[u].parent].left;
    }
    if( T[T[u].parent].right != u && T[T[u].parent].right != NIL){
        return T[T[u].parent].right;
    }
    return NIL;
}

void print (int u){
    int deg = 0;
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    if(T[u].left != NIL)deg++;
    if( T[u].right != NIL)deg++;
    printf("degree = %d, " ,deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if( T[u].parent == NIL ){
        printf("root\n");
    }
    else if( T[u].left == NIL && T[u].right == NIL){
        printf("leaf\n");
    }
    else {
        printf("internal node\n");
    }
}

int main(void){
    int i, v, left, right, root  = 0;
    scanf("%d",&n);
    for(i=0;i<n;i++)T[i].parent = NIL;
    for(i=0;i<n;i++){
        scanf("%d%d%d",&v,&left,&right);
        T[v].left = left;
        T[v].right = right;
        if(left != NIL)T[left].parent = v;
        if( right != NIL)T[right].parent = v;
    }
    for(i=0;i<n ;i++){
        if(T[i].parent == NIL)root =i;
    }
    setDepth(root,0);
    setHeight(root);
    for(i=0;i<n;i++){
        print(i);
    }
    return 0;
}


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

int main(){
  int N,l,r,k;
  k = 0;
  cin >> N;
  for(int j = 0; j < N ;j++){
    cin >> l >> r;
    k += (r-l+1);
    cout << endl;
  }
  cout << k << endl;
}      
    
    


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    if (n == m) {
      System.out.println("Yes");
    } else if (n > m) { 
      System.out.println("No");
    } 
  }
}

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

int gcd(int p,int q){
    if(p % q == 0)return q;
    return gcd(q, p% q);
}

int main() {
    int K;
    cin >> K;
    ll ans = 0;
    int num = 0;
    for(int i=1;i < K + 1;i++){
        for(int j=1;j < K+1;j++){
            num = gcd(i,j);
            for(int n=1;n < K+1;n++){
                ans += gcd(num,n);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define __int64 long long

int kk,n;
ll x[100],y[100];


int main(){	
	cin>>n>>kk;
	ll ans=7000000000000000000;
	rep(i,n)cin>>x[i]>>y[i];

					int c=0;
	rep(i,n){
		rep(j,n){
		//	if(i==j)continue;
			rep(k,n){
				//if(i==k||j==k)continue;
				rep(l,n){
					//if(i==l||j==l||k==l)continue;
					c=0;
					rep(z,n){
						if(x[i]<=x[z]&&x[z]<=x[j]&&y[k]<=y[z]&&y[z]<=y[l])c++;
					}

					if(c>=kk){
						ans=min(ans,(x[j]-x[i])*(y[l]-y[k]));
						//cout<<x[i]<<" "<<x[j]<<" "<<y[k]<<" "<<y[l]<<" "<<c<<endl;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
//probrem_b.go

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	//"strings"
)

const (
	constMod = int(1e9) + 7
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

// -----------------------------------------

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntSlice(n int) []int {
	ns := []int{}
	for i := 0; i < n; i++ {
		ns = append(ns, getInt())
	}
	return ns
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func getStringSlice(n int) []string {
	ss := []string{}
	for i := 0; i < n; i++ {
		ss = append(ss, getString())
	}
	return ss
}

// -----------------------------------------

// Sort Fanction

func sortIntSlice(ns []int) []int {
	sort.Sort(sort.IntSlice(ns))
	return ns
}

func rsortIntSlice(ns []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(ns)))
	return ns
}

// -----------------------------------------

// Num Fanction

//numModPow(a, n, m) = a^n % m
func numModPow(a int, n int, m int) int {
	result := 1

	for n > 0 {
		if n%2 == 1 {
			result = (result * a) % m
		}

		a = (a * a) % m
		n >>= 1
	}

	return result
}

// numGcd(a, b) = gcd(a, b)
func numGcd(a int, b int) int {
	if b == 0 {
		return a
	}

	return numGcd(b, a%b)
}

// numLcm(a, b) = lcm(a, b)
func numLcm(a int, b int) int {
	return a * b / numGcd(a, b)
}

// numModInv(a, p) = a^(-1) % p
func numModInv(a int, p int) int {
	if a == 1 {
		return 1
	}

	return p - numModInv(p%a, p)*(p/a)%p
}

// numModFrac(n) = n! % constMod
func numModFrac(n int) []int {
	frac := []int{1}

	for i := 1; i <= n; i++ {
		frac = append(frac, i*frac[i-1]%constMod)
	}

	return frac
}

// numModConb(n, r) = nCr % constMod
func numModConb(n int, r int) int {
	frac := numModFrac(n)

	return (frac[n] / ((frac[n-r] * frac[r]) % constMod)) % constMod
}

// -----------------------------------------

func solve() {

	x := getInt()
	h := 0

	fh := x / 500

	h += fh * 1000
	x -= fh * 500

	f := x / 5

	h += f * 5

	fmt.Fprintln(wr, h)

}

// -----------------------------------------

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
using namespace std;
typedef pair <int, int> pii;
int main (void) {
	int n, m; cin >> n >> m;
	vector <pii> students(n);
	vector <pii> checkpoints(m);
	for (int i = 0; i < n; i++) {
		cin >> students[i].first;
		cin >> students[i].second;
	}
	for (int i = 0; i < m; i++) {
		cin >> checkpoints[i].first;
		cin >> checkpoints[i].second;
	}
	for (int i = 0; i < n; i++) {
		long long d = (long long) 1e9;
		int minindex = -1;
		for (int j = 0 ; j < m; j++) {
			long long distance = abs (students[i].first - checkpoints[j].first) + abs (students[i].second - checkpoints[j].second);
			if (distance < d) {
				d = distance;
				minindex = j;
			}
		}
		cout << minindex+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int n;
  cin >> n;
  map<string,int> mp;
  for (int i=0;i<n;++i){
    string s;
    cin >> s;
    mp[s]++;
  }
    cout << "AC x "<< mp["AC"] << endl;
    cout << "WA x "<< mp["WA"] << endl;
    cout << "TLE x "<< mp["TLE"]<<endl;
    cout << "RE x "<< mp["RE"] <<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
P v[4][200001]={};

int main() {
	int n;
	cin>>n;
	int s[100]={};
	int t=0;
	for(int i=0;i<n;++i){
		cin>>s[i];
		t+=s[i];
	}
	sort(s,s+n);
	if(t%10>0){
		cout<<t<<endl;
		return 0;
	}
	int i;
	for(i=0;i<n&&(t-s[i])%10==0;++i);
	if(i==n){
		cout<<"0"<<endl;
		return 0;
	}

	cout<<t-s[i]<<endl;
	return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] w = new int[n];
		w[0] = sc.nextInt();
		for (int i = 1; i < n; i++) {
			w[i] = w[i - 1] + sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			min = Math.min(min, Math.abs(w[i] - (w[n - 1] - w[i])));
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
	int n,m,a[200009],b[200009],c[300000],i;
	scanf("%d%d",&n,&m);
	    for(i=1;i<=m;i++)
	    {
	      scanf("%d%d",&a[i],&b[i]);
	        if(a[i]==1)
			c[b[i]]=1;
	    }	
				    for(i=1;i<=m;i++)
					
	     	         {
				        if(b[i]==n&&c[a[i]]==1)
				          {
						  printf("POSSIBLE\n");
	     	              return 0;
						   }
				     }
				 
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>n>>m;
if(n==m)
{
  cout<<"Yes";
}
else
{
  cout<<"No";
}
}


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

int main(){
	int a,b,c,n,m;
	cin >> n >> m;
	a=n+m;
	b=n-m;
	c=n*m;
	int maxn1=0;
	int maxn2=0;
	maxn1=max(a,b);
	maxn2=max(maxn1,c);
	cout << maxn2;
} 

Measured memory_bytes: 256