akhauriyash/Code-Regression huggingface dataset:
N = int(input())


def f(x):
    ret = 0
    while x:
        x, r = divmod(x, 10)
        ret += r
    return ret


ret = 10 ** 9
for a in range(1, N):
    b = N - a
    ret = min(ret, f(a) + f(b))
print(ret)


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

int main()
{
	string O, E;

	cin >> O >> E;

	int oi = 0;
	int ei = 0;
	for( int i; i < O.size() + E.size(); i++ ) {
		if( i % 2 == 0 ) {
			cout << O[oi];
			oi++;
		}
		else {
			cout << E[ei];
			ei++;
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

dic = defaultdict(int)

for st in s:
    dic[st] = dic[st]+1
for st in t:
    dic[st] = dic[st]-1

print(max(0,max(dic.values())))

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int minD = 100;
  for(int i = 0; i < N; ++i){
    cin >> a[i];
    int tmp = a[i];
    int d = 0;
    while(tmp%2 == 0){
      tmp /= 2;
      d++;
    }
    minD = min(minD, d);
  }
  cout << minD << endl;
  

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    static Node nil = new Node(-1, null, null, null);
    static Node root = nil;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String order = sc.next();
            if (order.startsWith("i")) {
                    insert(new Node(sc.nextInt(), nil, nil, nil));
                    
            } else if (order.startsWith("p")){
                printInorder(root);
                System.out.println();
                printPreorder(root);
                System.out.println();
                
            } else {
                System.out.println(hasNodeWithKey(sc.nextInt()) ? "yes" : "no");
            }
        }
    }
    
    static boolean hasNodeWithKey(int key) {
        Node nd = root;
        while (!nd.equals(nil) && nd.val != key) {
                nd = (nd.val > key) ? nd.left : nd.right;
        }
        return !nd.equals(nil);
    }
    
    static void insert(Node z) {
        if (root.equals(nil)) {
            root = z;
            return;
        }
        
        Node p = root; // zの親
        while (true) {
            if (p.val > z.val) {
                if (p.left.equals(nil)) {
                    p.left = z;
                    break;
                } else {
                    p = p.left;
                }
            } else {
                if (p.right.equals(nil)) {
                    p.right = z;
                    break;
                } else {
                    p = p.right;
                }
            }
        }
    }
    
    // 螺旋本の擬似コードから
//    static void insertOtehon(Node nd, Node z) {
//        Node y = nil; // parent of x
//        Node x = nd;
//        while (!x.equals(nil)) {
//            y = x; // 親を設定
//            if (z.val < x.val) {
//                x = x.left;
//            } else {
//                x = x.right;
//            }
//        }
//        z.parent = y;
//        
//        //  Tが空の場合
//        if (y.equals(nil))
//            root = z;
//        else if (z.val < y.val)
//            y.left = z;
//        else {
//            y.right = z;
//        }
//    }
    
    static void printInorder(Node arg) {
        Node nd = arg;
        if(!nd.equals(nil)) {
            printInorder(nd.left);
            System.out.print(" " + nd.val);
            printInorder(nd.right);
        }
    }
    
    static void printPreorder(Node arg) {
        Node nd = arg;
        if(!nd.equals(nil)) {
            System.out.print(" " + nd.val);
            printPreorder(nd.left);
            printPreorder(nd.right);
        }
    }
    
    static class Node {
        int val;
        Node parent;
        Node left;
        Node right;
        
        Node (int val, Node parent, Node left, Node right) {
            this.val = val;
            this.parent = parent;
            this.left = left;
            this.right = right;
        }
        Node (int val) {
            this.val = val;
            this.parent = nil;
            this.left = nil;
            this.right = nil;
        }
    }
}



Measured memory_bytes: 208092
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	sum := 0
	for i := 1; i <= n; i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		}
		sum += i
	}
	fmt.Println(sum)
}

Measured memory_bytes: 1756
X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=1)
B = sorted(list(map(int,input().split())),reverse=1)
C = sorted(list(map(int,input().split())),reverse=1)
num= []
for xi in range(1,X+1):
    for yi in range(1,Y+1):
        for zi in range(1,K//(xi*yi)+1):
            if xi*yi*zi <= K and zi < Z+1:
                num.append((xi-1,yi-1,zi-1))

ans = []
for a,b,c in num:
    ans.append(A[a]+B[b]+C[c])
ans.sort(reverse=1)
for i in range(K):
    print(ans[i])

Measured memory_bytes: 17952
# D - String Formation
from collections import deque


def main():
    S = input().rstrip()
    Q = int(input())
    queue = deque(S)
    to_beginning, to_end = queue.appendleft, queue.append
    is_reversed = False
    for _ in range(Q):
        query = input().split()
        if query[0] == "1":
            to_beginning, to_end = to_end, to_beginning
            is_reversed = not is_reversed
            continue
        com, c = query[1], query[2]
        if com == "1":
            to_beginning(c)
        else:
            to_end(c)
    ans = "".join(queue) if not is_reversed else "".join(reversed(queue))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8564
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int p;
   int sum = 0;
   int max = 0;
   for(int i=0; i<N; ++i){
      std::cin >> p;
      if(max<p) max = p;
      sum += p;
   }
   std::cout << sum - max/2 << std::endl;

   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
ll H, W, N;
vector<string>S;
vector<vll> d;
vll dx{1, 0, -1, 0}, dy{0, 1, 0, -1};

ll xyToIdx(ll x, ll y){
    return (x*W + y);
}

void idxToxy(ll idx, ll &x, ll &y){
    x = idx / W;
    y = idx % W;
    return;
}

int main(){
    cin >>H>>W; N = H*W; //* nr of nodes
    REP(_, H){
        string tmp; cin>>tmp;
        S.push_back(tmp);
    }
    d.resize(N);
    REP(i, N){
        d[i].resize(N);
        fill(ALL(d[i]), INF);
    }
    REP(x, H){
        REP(y, W){
            if(S[x][y] =='#')
                continue;
            d[xyToIdx(x, y)][xyToIdx(x, y)] = 0;
            ll xto, yto;
            REP(k, 4){
                xto = x + dx[k], yto = y + dy[k];
                if( 0<= xto && xto < H && 0 <= yto && yto < W){
                    if(S[xto][yto] =='.'){
                        d[xyToIdx(x, y)][xyToIdx(xto, yto)] = 1;
                        d[xyToIdx(xto, yto)][xyToIdx(x, y)] = 1;
                    }
                }
            }
        }
    }

    rep(k, N){
        rep(i, N){
            rep(j, N){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    ll ans = 0;
    rep(i, N){
        rep(j, N){
            ll xi, yi, xj, yj;
            idxToxy(i, xi, yi);
            idxToxy(j, xj, yj);
            if(S[xi][yi] == '.' && S[xj][yj]=='.' && d[i][j]<INF){
                ans = max(ans, d[i][j]);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        // cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    REP(i, n) {
        REPF(j, i+1, n) {
            int diff = abs(a[i] - a[j]);
            if (diff % (n-1) == 0) {
                cout << a[i] << " " << a[j] << endl;
                return 0;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	unsigned int a[3];
	cin >> a[0] >> a[1] >> a[2];

	sort(a, a+3);

	cout << a[0] << " " << a[1] << " " << a[2] << endl;

	return 0;
}



Measured memory_bytes: 3088
#include<cmath>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cstring>
#include<utility>
#include<iostream>
#include<algorithm>
using namespace std;
using i64=long long;
int read(){int x=0,c=getchar(),f=1;while(isspace(c))c=getchar();if(c=='-')f=-1,c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return f*x;}
int main()
{
    int x;
    cin>>x;
    x%=10;
    if(x==3) return puts("bon"),0;
    else if(x==0||x==1||x==6||x==8) return puts("pon"),0;
    else return puts("hon"),0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int x;
int main(){
    cin>>x;
    int price[6]={100,101,102,103,104,105};
    dp[0]++;
for(int i=0;i<x;i++){
    for(int j=0;j<6;j++){
        if(dp[i]&&(i+price[j])<=100000)
        dp[i+price[j]]++;
        }
    }
if(dp[x])
    cout<<1<<endl;
else
{
    cout<<0<<endl;
}
    return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 300010

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



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 2000000
#define INFTY 30

int h, a[MAX+1];

void maxHeapify(int);
int extract(void);
void increaseKey(int, int);
void insert(int);

int main(){
  int k;
  char c[7];

  while(1){
    scanf("%s", c);
    if(strcmp(c, "end") == 0) break;
    if(strcmp(c, "insert") == 0){
      scanf("%d", &k);
      insert(k);
    }
    else printf("%d\n", extract());
  }
  return 0;
}

void maxHeapify(int i){
  int l, r, largest, b;

  l = 2 * i;
  r = 2 * i + 1;
  if(l <= h && a[l] > a[i]){
    largest = l;
  }
  else largest = i;
  if(r <= h && a[r] > a[largest]){
    largest = r;
  }
  if(largest != i){
    b = a[i];
    a[i] = a[largest];
    a[largest] = b;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;

  if(h < 1) return -INFTY;
  maxv = a[1];
  a[1] = a[h--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int b;

  if(key < a[i]) return;
  a[i] = key;
  while(i > 1 && a[i/2] < a[i]){
    b = a[i];
    a[i] = a[i/2];
    a[i/2] = b;
    i = i / 2;
  }
}

void insert(int key){
  h++;
  a[h] = -INFTY;
  increaseKey(h, key);
}

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

int main() {
  // ここにプログラムを追記
  string mass;
  cin >> mass;
  int cnt=0;
  for(int i=0; i < mass.size(); i++){
    if(mass[i] == '1') cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    int n;
    while(cin >>n && n){
        int A = 0, B = 0;
        rep(i, n){
            int a, b; cin >>a >>b;
            if(a > b) A += a + b;
            else if(a < b) B += a + b;
            else{
                A += a;
                B += b;
            }
        }
        cout <<A <<" " <<B <<endl;
    }
    return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int t;
	// cin>>t;
	t = 1;
	while(t--){
		int n,k;
		cin>>n>>k;
		int arr[n];
		int dp[n];
		for(int i=0;i<n;i++){
			cin>>arr[i];
			dp[i] = INT_MAX;
		}
		dp[0]=0;
		for(int i=1;i<n;i++){
			for(int j=i-k; j<i;j++){
				if(j>=0){
					dp[i] = min(dp[i],dp[j] + abs(arr[i] - arr[j]));
				}
			}
		}
		cout<<dp[n-1]<<'\n';
	}
}

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

int main() {
  int a;
  cin >> a;
  int num;
  num = a%1000/100;
  if( a%100/10 == num && (a/1000 == num || a%10 == num))
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
bool has3(int x){
  while(x){
    if(x%10 == 3)return true;
    x /= 10;
  }
  return false;
}

void call(int n){
  for(int x = 1; x <= n; x++){
    if ( x % 3 == 0 || has3(x)){
      cout << " " << x;
    }
  }
  cout << endl;
}

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

  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main(void){
     
    //変数：三角形の２辺 「 a, b 」とその間の角「 C 」と置く
    double a, b, C;
    
    //入力：三角形の２辺 「 a, b 」とその間の角「 C 」を入力
    cin >> a >>  b >> C;
    
    //変数：三角形の面積 「 S 」、周の長さ 「 L 」, a を底辺としたときの高さ 「 h 」と置く
    double S, L, h;
    
    //計算：三角形の面積 「 S 」は三角関数より S = a * b * sin(ラジアン);
    S = a * b * sin(M_PI * C / 180) / 2;
    //計算：周の長さ 「 L 」は余弦定理で「 c = sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(ラジアン)) 」の長さを求めて周の長さを求める
    L = a + b + sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(M_PI * C / 180));
    //計算：a を底辺としたときの高さ 「 h 」は「 S = h * a / 2」から求める
    h = S / a * 2;
    
    printf("%.8f\n", S);
    printf("%.8f\n", L);
    printf("%.8f\n", h);
    
}


Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
	vec1.size();
	str1.length();
	vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 1e9+7;
ll expo_mod(ll x, ll y, ll p) 
{ 
	ll res = 1;
	x = x % p; 
	if (x == 0) 
		return 0; 
	while (y > 0) 
	{
		if (y%2==1) 
			res = (res*x) % p; 
		y = y>>1; // y = y/2 
		x = (x*x) % p; 
	} 
	return res; 
} 
ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe\n";
	else
		cout<<"safe\n";
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> G[100010];
vector<int> d(100010, INT_MAX);
queue<int> que;
vector<int> o(100010, -1);
int main() {
    cin >> N >> M;
    for (int i = 1; i <= M; i++) {
        int A, B;
        cin >> A >> B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    d[1] = 0;
    que.push(1);
    int c = 0;
    while (que.size()) {
        int a = que.front();
        que.pop();
        for (auto x: G[a]) {
            if (d[x] > d[a]+1)  {
                d[x] = d[a]+1;
                que.push(x);
                if (o[x] == -1) {
                    c++;
                    o[x] = a;
                }
            }
        }
    }
    if (c == N-1) {
        puts("Yes");
        for (int i = 2; i <= N; i++) {
            cout << o[i] << endl;
        }
    }
    else {
        puts("No");
    }
}

Measured memory_bytes: 10720
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int r,g,b;

int main()
{
    cin>>r>>g>>b;
    int tmp=r*100+g*10+b;
    if(tmp%4==0)printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
C=[list(map(int,input().split())) for i in range(M)]
for i in range(N):
    z=10**10
    ans=0
    for t in range(M):
        if (abs(A[i][0]-C[t][0])+abs(A[i][1]-C[t][1]))<z:
            z=(abs(A[i][0]-C[t][0])+abs(A[i][1]-C[t][1]))
            ans=t+1
        else:
            continue
    print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	int l=-1,r=-1;
  	string s;
  	cin >> s;
  	int n = (int)s.size();
  	for (int i = 0; i < n; ++i)
  	{
  		if(i+1 < n)
  		{
  			if (s[i] == s[i+1])
  			{
  				l = i;
  				r = i+1;
  				break;
  			}
  		}
  		if (i+2 < n)
  		{
  			if (s[i] == s[i+2])
  			{
  				l = i;
  				r = i+2;
  				break;
  			}
  		}
  	}
  	if (l == -1 && r == -1)
  	{
  		cout << -1 << " " << -1;
  	}
  	else
  	{
  		cout << l+1 << " " << r+1;
  	}
   	return 0;
}	

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 200050
#define mod 998244353
int n, ans, f[maxn][3][3][2], sum;
char a[maxn];

int read()
{
    int x = 0, k = 1;
    char c; c = getchar();
    while(c < '0' || c > '9') { if(c == '-') k = -1; }
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * k;
}

bool Check()
{
    for(int i = 2; i <= n; i ++) 
        if(a[i] != a[i - 1]) return 0;
    return 1;
}

bool Check2()
{
    for(int i = 2; i <= n; i ++) 
        if(a[i] == a[i - 1]) return 0;
    return 1;
}

void Up(int &x, int y) { x = (x + y) % mod; }
void DP(int i, int j, int k, int p)
{
    for(int q = 0; q <= 2; q ++)
        Up(f[i + 1][q][(q + k) % 3][p | (j == q)], f[i][j][k][p]);
}

signed main()
{
    scanf("%s", a + 1); n = strlen(a + 1);
    if(Check()) { puts("1"); return 0; }
    if(n <= 3)
    {
        if(n == 2) puts("2");
        else 
        {
            if(a[1] != a[2] && a[1] != a[3] && a[2] != a[3]) puts("3");
            else if(a[1] == a[3]) puts("7");
            else puts("6");
        }
        return 0;
    }
    for(int i = 1; i <= n; i ++) sum = (sum + a[i] - 'a') % 3;
    for(int i = 0; i <= 2; i ++) f[1][i][i][0] = 1;
    for(int i = 1; i <= n - 1; i ++)
        for(int j = 0; j <= 2; j ++)
            for(int k = 0; k <= 2; k ++)
                for(int p = 0; p <= 1; p ++)
                    DP(i, j, k, p);
    for(int i = 0; i <= 2; i ++) Up(ans, f[n][i][sum][1]);
    Up(ans, Check2());
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
  int n,x,sum=0,count=0;
  cin >> n >> x;
  vector<int> vec(n);
  
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
    count++;
  }
  
  sort(vec.begin(), vec.end());
  
  while(1){
    if(vec.at(0) <= x-sum){
      count++;
      sum += vec.at(0);
    }else{
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main() {
  int a,b,c,d;
  int r,kouyaku;
  scanf("%d%d",&a,&b);
 
  if(a<=b) {d=a; a=b; b=d;}
  if(a<1 || 1000000000<b ) exit(0);
  
  if(a==b) kouyaku =a;

  while(1) {
    r=a%b;
    if(r==0) break;
    kouyaku=r;
    a=b;
    b=r;
  }
  printf("%d\n",kouyaku);
  return 0;
}



 



Measured memory_bytes: 2084
#include <stdio.h>

int main(void) {
	int i;
	int weight;
	_Bool flag;
	while (scanf("%d", &weight) != EOF) {
		flag = 0;
		for(i = 1; i <= 512; i *= 2)
			if( (weight & i) == i) {
				if( flag)
					printf(" ");
				printf("%d", i);
				flag = 1;
			}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll n, ans=0;
    cin >> n;
    for(ll p=1; p*(p+2)<=n; p++){
        if(n%p==0){
            ans+=n/p-1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int i,j,n,m,a,b,ans;
	int f[505][505],c[505],d[505];
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		scanf("%d",&m);ans=0;
		memset(f,0,sizeof(f));
		memset(c,0,sizeof(c));
		memset(d,0,sizeof(d));
		for(i=0;i<m;i++){
			scanf("%d%d",&a,&b);
			f[a][c[a]]=b;
			f[b][c[b]]=a;
			c[a]++;c[b]++;
		}
		/*for(i=1;i<=n;i++){
			printf("%d:",i);
			for(j=0;j<c[i];j++)printf("%d ",f[i][j]);
			printf("\n");
		}*/
		for(i=0;i<c[1];i++){
			if(f[1][i]!=1 && d[f[1][i]]==0)
				d[f[1][i]]=1,ans++;
			for(j=0;j<c[f[1][i]];j++){
				if(f[f[1][i]][j]!=1 && d[f[f[1][i]][j]]==0){
					d[f[f[1][i]][j]]=1;
					ans++;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
import math
import heapq
import sys
from collections import Counter
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

#N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#s = [input() for i in range(3)]

x=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

if x[0]+x[1]+x[2]>=22:
    print('bust')
else:
    print('win')

Measured memory_bytes: 5252
/*
  ___    ___             ___    __                   _     _   _
 |   \  /   |           |   \  |  |                 | |   (_) | |
 |    \/    |  _ __     |    \ |  |   __ _   _____  | |_   _  | | __
 |  |\  /|  | | '__|    |  |\ \|  |  / _' | |  ___) | __| | | | |/ /
 |  | \/ |  | | |    _  |  | \    | | (_| | |___  | | \_  | | |   /
 |__|    |__| |_|   (_) |__|  \___|  \__,_| (_____|  \__| |_| |_|\_\

 */

 #include<bits/stdc++.h>
 using namespace std;
 #define ll long long
 #define M 1000000007

 int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,n,i,j;
    string s;
    cin>>t>>s;
    if(t<3200)
        cout<<"red\n";
    else
        cout<<s<<endl;
 }



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

int main(){
  int n;
  cin >> n;
  vector <int> a;
  int tmp;
  for(int i = 0;i < n; i++){
    cin >> tmp;
    a.push_back(tmp);
  }
  std::sort(a.begin(), a.end());
  
  float ans;
  ans = a[0];
    
  for (int i = 1;i < n; i++){
    ans = (ans + a[i])/2;
  }
  
  cout << ans;
  
}


Measured memory_bytes: 256
n, m = map(int, input().split())
x = [list(map(int, input().split())) + [i] for i in range(m)]
x.sort()
tmp = 0
k = 0
z = [None for _ in range(m)]
for i in range(m):
    if tmp == x[i][0]:
        k += 1
    else:
        k = 1
        tmp = x[i][0]
    z[x[i][2]] = '{0:06d}{1:06d}'.format(x[i][0], k)
for i in range(m):
    print(z[i])

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

# define fori(i,n)          for(int i=0;i<n;i++)
# define forl(i,n)          for (ll i=0;i<n;i++)
# define pb                 push_back
# define mp                 make_pair
# define X                  first
# define Y                  second
# define all(v)             v.begin(),v.end()
# define in_ar_int(arr,n)   int arr[n]; fori(i,n) cin >> arr[i];
# define in_ar_ll(arr,n)    ll arr[n]; fori(i,n) cin >> arr[i];
# define endl               "\n"
# define R0                 return 0
# define mod                1000000007
# define pi                 3.1415926536


typedef long long ll;
typedef string str;

 
ll power (ll a, ll b){
    ll ans=1;
    while(b){
		if (b & 1) ans*=a;
		a*=a;
		b/=2;
    }
    return ans;
}

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

long long nCr(int n,int r){
    if(n==r) return 1;
    else if (r==0) return 1;
    else return nCr(n-1,r-1)+nCr(n-1,r);
}

int sdigit(int x){
    int ans=0;
    while(x){
		ans+=x%10;
		x/=10;
    }
    return ans;
}

int bs(int a[],int b,int l,int r){
    int mid=l + (r-l)/2;
    if(l>r) return -1;
    if(a[mid]==b||l==r)	return mid;
    if(a[mid]>b)	return bs(a,b,l,mid-1);
    else return bs(a,b,mid+1,r);
}

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


void solve(){
	int n; cin >> n;
	in_ar_int (a,n);
	int dp[n+1];
	dp[n]=0;
	dp[n-1]=abs(a[n-2]-a[n-1]);
	for (int i=2;i<n;i++){
		dp[n-i]=min(dp[n-i+1]+abs(a[n-i]-a[n-i-1]),dp[n-i+2]+abs(a[n-i-1]-a[n-i+1]));
	}
	cout << dp[1];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int chill=1;
    // cin >> chill;
    while(chill--){
	solve();
    }
} 



Measured memory_bytes: 1024
#include<iostream>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(1) {
        C -= B;
        if(C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;


double EPS=0.000000001;
vector<double> p(10),h(10);
double d,n,b;


bool check(double v,int k){
    for (int i = 0; i < n; i++) {
        double x=p[i]-floor(p[i]/(d/k))*(d/k);
        double y=2*k*v*v*x/d*(1-k*x/d);
        if(y<EPS) return false;
        if(y<=h[i]) return false;
    }
    return true;
}

int main(){
    cin >> d >> n >> b;
    for (int i = 0; i < n; i++) {
        cin >> p[i] >> h[i];
    }
    double ans=1e9;
    for (int k = 1; k <= b+1; k++) {
        double l=0.0,r=1e9;
        while(abs(r-l)>EPS){
            double m=(l+r)/2;
            if(check(m,k)) r=m;
            else l=m;
        }
        double v=sqrt(d/(2*k));
        if(r>v) ans=min(ans,sqrt((d/(2*k*r)+r)*(d/(2*k*r)+r)-d/k));
        else ans=min(ans,v*sqrt(2));
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}



Measured memory_bytes: 3292
from sys import stdin
import fractions
A,B = [int(x) for x in stdin.readline().rstrip().split()]
GCD = fractions.gcd(A,B)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
ans = len(set(prime_factorize(GCD)))
print(ans+1)

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

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

    long long n;
    cin >> n;
    long long a, b;
    cin >> a >> b;
    n %= 12;
    for (int i = 1; i <= n; i++) {
        if (i % 2) {
            a = a - b;
        } else {
            b = a + b;
        }
    }
    cout << a << " " << b << endl;
}


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

const int MAX_N = 10010;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> Array;
typedef vector<Array> Graph;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int H, W;
    cin >> H >> W;
    ll res1, res2, res3, res4;
    if(H%3==0){
        res1 = 0;
    }else{
        res1 = W;
    }

    if(W%3==0){
        res2 = 0;
    }else{
        res2 = H;
    }

    ll a = H*(W/3);
    ll b = (H/2)*(W-W/3);
    ll c = (H-H/2)*(W-W/3);
    ll ma = max(max(a, b), c);
    ll mi = min(min(a, b), c);
    res3 = ma-mi;

    a = H*(W/3+1);
    b = (H/2)*(W-W/3-1);
    c = (H-H/2)*(W-W/3-1);
    ma = max(max(a, b), c);
    mi = min(min(a, b), c);
    res3 = min(res3, ma-mi);
    swap(H,W);

    a = H*(W/3);
    b = (H/2)*(W-W/3);
    c = (H-H/2)*(W-W/3);
    ma = max(max(a, b), c);
    mi = min(min(a, b), c);
    res4 = ma-mi;

    a = H*(W/3+1);
    b = (H/2)*(W-W/3-1);
    c = (H-H/2)*(W-W/3-1);
    ma = max(max(a, b), c);
    mi = min(min(a, b), c);
    res4 = min(res4, ma-mi);

    res1 = min(res1, res2);
    res1 = min(res1, res3);
    res1 = min(res1, res4);
    cout << res1 << endl;
    return 0;
}

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

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

const int maxn = 401;
int n;
ll arr[maxn];
ll psum[maxn];
ll dp[maxn][maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(dp, 0x3f, sizeof dp);

    cin >> n;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
      sum += arr[i];
      psum[i] = sum;
    }

    for (int i = 0; i < n; ++i) {
      dp[i][i] = 0;
    }
    for (int len = 2; len <= n; ++len) {
      for (int left = 0; left <= n - len; ++left) {
        int right = left + len - 1;
        for (int mid = left; mid < right; ++mid) {
          ll cost = psum[right] - (left > 0 ? psum[left - 1] : 0);
          dp[left][right] = min(dp[left][right],
              dp[left][mid] + dp[mid+1][right] + cost);
        }
      }
    }
    cout << dp[0][n - 1] << endl;
    
    return 0;
}


Measured memory_bytes: 1536
def main():
    n, c, k = map(int, input().split())
    t = [int(input()) for i in range(n)]
    t.sort()

    ans = 0
    tt = t[0]
    cc = 1
    for i in range(1, n):
        if tt + k < t[i] or c == cc:
            tt = t[i]
            ans += 1
            cc=0

        cc += 1

    print(ans+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 50264
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int x,y;
char c;
int vote[1010][2010]={};
int sum[1010][2010]={};
int main(){ _;
  int n,k;cin>>n>>k;
  int k2=k*2;
  REP(i,n){
    cin>>x>>y>>c;
    if(c=='W')y+=k;
    x%=k2;
    if(x>=k){
      x-=k;
      y+=k;
    }
    y%=k2;
    vote[x][y]++;
  }
  sum[0][0]=vote[0][0];
  for(x=1;x<k;x++)
    sum[x][0]=sum[x-1][0]+vote[x][0];
  for(y=1;y<k2;y++)
    sum[0][y]=sum[0][y-1]+vote[0][y];
  for(y=1;y<k2;y++)
    for(x=1;x<k;x++)
      sum[x][y]=sum[x-1][y]+sum[x][y-1]-sum[x-1][y-1]+vote[x][y];

  int result=sum[k-1][k-1];
  // REP(i,k2){
  //   REP(j,k){
  //     cout<<sum[j][i];
  //   }
  //   cout<<endl;
  // }
  for(y=0;y<k;y++){
    result=max(result,sum[k-1][y+k]-sum[k-1][y]);
  }
  for(x=0;x<k;x++){
    int a=sum[x][k2-1]+sum[k-1][k-1]-sum[x][k-1]*2;
    result=max(result,a);
    result=max(result,n-a);
  }
  for(y=0;y<k;y++){
    for(x=0;x<k;x++){
      int a=sum[x][k2-1]+sum[k-1][y+k]-sum[x][y+k]*2-sum[k-1][y]+sum[x][y]*2;
      result=max(result,a);
      result=max(result,n-a);
    }
  }

  cout<<result<<endl;
}


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

int main(void) {
  int64_t N, M;
  cin >> N >> M;

  int64_t Ans = 0;
  // cornar : 4times skip
  if (N == 1 && M == 1) {
    Ans = 1;
  } else if (N == 1) { // 3times
    Ans += (M - 2);
  } else if (M == 1) { // 3times
    Ans += (N - 2);
  } else {
    Ans += (N - 2) * (M - 2);
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

bool check(string s){
	int n = sz(s);
	bool c=	1;
	FOR(i, 0, n){
		c&=(s[i]==s[n-i-1]);
	}
	return c;
}
void solve(){
	double n;
	cin>>n;
	cout<<fixed<<setprecision(12)<<(n/3)*(n/3)*(n/3)<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

class UnionFind{
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;

    //作る時はParentの値を全て-1にする
    //こうするとずべてバラバラになる
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているのか調べる
    int root(int A){
      if(Parent[A]<0) return A;
      return Parent[A] = root(Parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
      return -Parent[root(A)];//親を取ってきたい
    }

    //AとBをくっつける
    bool connect(int A,int B){
      //AとBを直すつつなぐのではなく、root(A)にroot(B)をくっつける)
      A = root(A);
      B = root(B);
      if(A==B){
        //すでにくっついているからくっつけない
        return false;
      }
      //大きい方(A)に小さい方(B)をくっつけたい
      //大小が逆だったらひっくり返しちゃう
      if(size(A)<size(B)) swap(A,B);

      //Aのサイズを更新する
      Parent[A] += Parent[B];
      //Bの親をAに変更する
      Parent[B] = A;

      return true;
    }
  };


int main(){
  ll N , Q; cin >> N >> Q;
  UnionFind Uni(N);
  rep(i,Q){
    ll a, b, c; cin >> a >> b >> c;
    if(a == 0){
      Uni.connect(b,c);
    }
    else{
      if(Uni.root(b) == Uni.root(c)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }


}



Measured memory_bytes: 3144
#include<stdio.h>
int main()
{
    char c[3][4];
    int i, j;
    for (i = 0; i < 2; i++)
        scanf("%s", c[i]);
    if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0])
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

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

int main() {
  int M, D; cin >> M >> D;
  int ans = 0;
  for (int m = 1; m <= M; m++) {
    for (int d = 1; d <= D; d++) {
      int d1 = d % 10;
      int d2 = d / 10;
      if (d1 >= 2 && d2 >= 2 && d1 * d2 == m) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 _____      _ _              ______     
/  ___|    (_|_)             |  _  \    
\ `--. _ __ _ _  __ _ _ __   | | | |___ 
 `--. \ '__| | |/ _` | '_ \  | | | / _ \
/\__/ / |  | | | (_| | | | | | |/ /  __/
\____/|_|  |_| |\__,_|_| |_| |___/ \___|
            _/ |                         
           |__/                          
All Required Header Files ********/
#include <bits/stdc++.h>  
using 		namespace 		std;
using 		lli= 			long long  int;
using 		ulli= 			unsigned long long int;
using 		ld= 			long double;
int main() {
	
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	
//	cout<<fixed;
//	cout<<scientific;
	cout<<fixed<<setprecision(12);

	ld n;
	cin>>n;
	n=n/3;
	cout<<n*n*n;

	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author i.mekni
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Scanner read = new Scanner(System.in);

        PrintWriter write = new PrintWriter(System.out);

        int x = read.nextInt();
        write.println((x/500)*1000+((x%500)/5)*5);
        write.close();
    }

}

Measured memory_bytes: 23124
//#include <GOD>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define si size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define E end()
#define B begin()
#define pi pair<int, int>
#define en cout << endl
#define cn const
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

cn int maxn = 1e5 + 10;
ll h[maxn];
ll dp[maxn];

int main(){
	fast_io;
	int n;
	cin >> n;
	for(int i = 0; i < n; i ++)
		cin >> h[i];
		
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i ++){
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	
	cout << dp[n - 1];
	
	return 0;
}



Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        List<Grid> gridList = new ArrayList<>();

        int n = in.nextInt();
        for(int i = 0; i < n; i++) {
            gridList.add(new Grid(Color.RED, in.nextInt(), in.nextInt()));
        }
        for(int i = 0; i < n; i++) {
            gridList.add(new Grid(Color.BLUE, in.nextInt(), in.nextInt()));
        }

        gridList.sort(Comparator.comparing(Grid::getX).thenComparing(Grid::getColor));
        List<Grid> list = new ArrayList<>();
        int ans = 0;
        for (Grid grid : gridList) {
            if(grid.color == Color.RED) {
                list.add(grid);
            } else {
                Optional<Grid> maxGrid = list.stream()
                        .filter(g -> g.getY() < grid.getY())
                        .max(Comparator.comparing(Grid::getY));
                if(maxGrid.isPresent()) {
                    ans++;
                    list.remove(maxGrid.get());
                }
            }
        }
        System.out.println(ans);
    }
}

class Grid {

    Color color;
    int x;
    int y;

    public Grid(Color color, int x, int y) {
        this.color = color;
        this.x = x;
        this.y = y;
    }
    public Color getColor() { return this.color; }
    public int getX() { return this.x; }
    public int getY() { return this.y; }

    public String toString(){
        return String.format(color + " \t" + x + ", " + y);
    }
}

enum Color {
    BLUE,
    RED
}

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

int main() {
  long long int a,b,n, x_max, v_max; cin >> a >> b >> n;

  if( n/b < 1 ) { x_max = n; }
  else{ x_max = ( (n/b+1) - 1 ) * b + (b-1); }
  v_max = (a*x_max/b) - a*(x_max/b);
  cout << v_max << endl;

  return 0;
}

Measured memory_bytes: 3600
package main

import (
    "fmt"
    "os"
    "bufio"
    )
    
var r = bufio.NewReader(os.Stdin)

func main(){
   var a,b,c int 
   fmt.Fscan(r, &a)
   fmt.Fscan(r, &b)
   fmt.Fscan(r, &c)

   if a < b  && b < c {
       fmt.Println("Yes")
   }else{
       fmt.Println("No")
   }
}


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

int main() {
  vector<vector<ll>> a(3,vector<ll>(3));
  for(ll i=0;i<3;i++) {
    for(ll j=0;j<3;j++) {
      cin >> a[i][j];
    }
  }
  ll n;
  cin >> n;
  set<ll> b;
  for(ll i=0;i<n;i++) {
    ll temp;
    cin >> temp;
    b.insert(temp);
  }
  bool flag=false;
  for(ll i=0;i<3;i++) {
    if(b.count(a[i][0])&&b.count(a[i][1])&&b.count(a[i][2])) {
      flag=true;
    }
  }
  for(ll i=0;i<3;i++) {
    if(b.count(a[0][i])&&b.count(a[1][i])&&b.count(a[2][i])) {
      flag=true;
    }
  }
  if(b.count(a[0][0])&&b.count(a[1][1])&&b.count(a[2][2])) {
    flag=true;
  }
  if(b.count(a[0][2])&&b.count(a[1][1])&&b.count(a[2][0])) {
    flag=true;
  }
  if(flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint h, w;
llint l[200005], r[200005];
set<P> S;
multiset<llint> T;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w;
	for(int i = 1; i <= h; i++) cin >> l[i] >> r[i];
	
	for(int i = 1; i <= w; i++){
		S.insert(P(i, i));
		T.insert(0);
	}
	
	for(int i = 1; i <= h; i++){
		auto p = S.lower_bound(P(l[i], -inf));
		
		llint mx = 0;
		for(auto it = p; it != S.end();){
			if(it->first > r[i]) break;
			mx = max(mx, it->second);
			auto tmp = it;
			T.erase(T.lower_bound(it->first-it->second));
			it++;
			S.erase(tmp);
		}
		if(mx > 0){
			if(r[i]+1 <= w){
				S.insert(P(r[i]+1, mx));
				T.insert(r[i]+1-mx);
			}
		}
		if(T.size() == 0) cout << -1 << "\n";
		else cout << *T.begin() + i << "\n";
	}
	flush(cout);
	
	return 0;
}

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

int a, b;
string ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    cin >> a >> b;
}

void solve(){
    if(a < b)
        for(int i = 0; i < b; i++)
            ans += a + '0';
    else
        for(int i = 0; i < a; i++)
            ans += b + '0';
}

void out(){
    cout << ans;
}


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

int main() {
  std::string s;
  std::cin >> s;

  int count = 0;
  int cur = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
      cur++;
      if (i + 1 == s.size()) {
        count = std::max(count, cur);
      }
    } else {
      count = std::max(count, cur);
      cur = 0;
    }
  }
  std::cout << count << std::endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

string s[11];
ll m[11][1001];
ll g[11]; // 行ごとのグループ番号
ll now[11]; // 行の区切りごとの1列分のホワイトチョコレート数
ll sum[11]; // 行の区切りごとのグループごとのホワイトチョコレート数

void solve_abc() {
	ll h, w, k;
	ll ans = INF;

	cin >> h >> w >> k;

	ll size = 0;
	rep(i, h) {
		cin >> s[i];
		rep(j, w) {
			m[i][j] = s[i][j] - '0';
		}
	}

	ll line = INF;
	ll gno = 0;
	bool over = false;
	rep(i, 1 << (h - 1)) {
		// 初期化
		line = 0;
		gno = 0;
		rep(j, h) {
			g[j] = 0;
			sum[j] = 0;
		}

		// 行のグルーピングと分割線カウント
		rep(j, h) {
			g[j] = gno;
			if ((i >> j) & 1) {
				gno++;
				line++;
			}
		}

		rep(p, w) {
			// 初期化
			over = false;
			rep(j, h) {
				now[j] = 0;
			}

			// 各グループの列pのホワイトチョコレート数をカウント
			rep(j, h) {
				now[g[j]] += m[j][p];
				if (now[g[j]] > k) {
					line = INF;
					break;
				}
			}

			// 各グループの列pを足すことでホワイトチョコレート数がkを超えるか確認
			rep(j, h) {
				if (now[g[j]] + sum[g[j]] > k) {
					over = true;
					break;
				}
			}

			// kを超えていれば、列に分割線を入れて、sumを更新
			if (over) {
				rep(q, h) {
					sum[q] = now[q];
				}
				line++;
			}
			else {
				rep(q, h) {
					sum[q] += now[q];
				}
			}
		}
		if (ans > line) {
			ans = line;
		}
	}

	cout << ans << "\n";
}

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

	solve_abc();

	return 0;
}

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

int main() {
  int64_t A, B, K;
  cin >> A >> B >> K;
  if (A>=K) A -= K;
  else if (A+B>=K) {
    B -= K-A;
    A = 0;
  }
  else {
    A = 0;
    B = 0;
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256