akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	int n , q; cin >> n >> q ;
	string s ; cin >> s ;
	vi a(n , 0) ;
	for(int i = 1 ; i < n  ;i++){
		a[i] = a[i - 1] ;
		if(s[i] == 'C' && s[i - 1] == 'A') a[i]++ ;
	}
	int l ,r ;
	for(int i = 0 ; i < q ; i++){
		cin >> l >> r ;
		l--;r-- ;
		cout << a[r] - a[l] << endl; 
	}
	return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int marker[26] = {0};
  for(auto x : s){
    marker[x-'a']++;
  }
  for(int i = 0;i<26;i++){
    if(marker[i] % 2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void){
    int N,j,k,l,i,c,d;
    scanf("%d",&N);
    int A[N],B[N],E[N];
    for(i=0;i<=N-1;i++){
        scanf("%d",&A[i]);
      d = A[i];
      E[d-1] = i+1;
    }
    for(l=0;l<=N-1;l++)printf("%d ",E[l]);
    return 0;
}

Measured memory_bytes: 1536
// @problemURL url.com
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nt(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

func ni(s *bufio.Scanner) int {
	return atoi(nt(s))
}

func atoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	var in = bufio.NewReader(os.Stdin)
	s := bufio.NewScanner(in)
	s.Split(bufio.ScanWords)

	// Code
	n := ni(s)
	m := make(map[int]int)
	for i := 0; i < n-1; i++ {
		m[ni(s)]++
	}
	for i := 1; i <= n; i++ {
		fmt.Println(m[i])
	}
}


Measured memory_bytes: 13080
#include <bits/stdc++.h>
#include<math.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>

ll gcd(ll a,ll b){
if(b==0){
    return a;
}
else{
   return gcd(b,a%b);
}
}
 int main()
{
  /*#ifndef ONLINE_JUDGE
  freopen("tin.txt","r",stdin);
  freopen("tout.txt","w",stdout);
  #endif*/

ll a,b;
while(cin>>a>>b){

cout<<gcd(a,b)<<" "<<(a*b)/gcd(a,b)<<endl;


}
}






Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e8;
int find(int x){
	int sum=0;
	while(x){
		sum+=x%10;
		x/=10;
	}
	return sum;
}
int main(){
	int n;
	cin>>n;
	int ans=inf;
	for(int i=1;i<=n;i++){
		int x=i;
		int y = n-x;
		if(x>y)break;
		int sum=find(x);
		sum+=find(y);
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
	int winX, winY;
	int centerX, centerY, radius;
	string result;
	cin >> winX >> winY >> centerX >> centerY >> radius;
	if(centerY - radius >= 0 && centerY + radius <= winY && 
			centerX -radius >= 0 && centerX + radius <= winX) {
		result = "Yes";
	} else {
		result = "No";
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 1192
#include <vector>
#include <bitset>
#include <functional>
#include <stdio.h>
#include <algorithm>
typedef long long ll;
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
 
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define V vector<int>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
 
  int n,k;scanf("%d%d",&n,&k);
  V a(n);REP(i,n)scanf("%d",&(a[i]));
  sort(ALL(a),greater<int>());
  vector<bitset<5001>> table(n);
  REP(i,n)table[i].set(i);
  vector<bitset<5001>> dp(k,~bitset<5001>());
  dp[0] = ~dp[0];
  REP(i,n)
    for(int j=k-1;j>=a[i];j--)
      if(!dp[j-a[i]][5000])
        dp[j] &= (dp[j-a[i]] | table[i]);
  int cou = n;
  REP(i,n)FOR(j,max(0,k-a[i]),k)if(!dp[j][i]){cou--;break;}
  printf("%d",cou);
 
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int a,b,k,x;
    cin>>a>>b>>k;
    int l=0;
    for(int i=min(a,b);1<=i;i--){
        if(a%i==0&&b%i==0)l++;
        if(l==k){
            x=i;
            break;
        }
    }
    cout<<x<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
vector<string> list = { "dreamer", "dream", "erase", "eraser"};
bool dp[111111];

int main() {//入力の文字数までDPを回す、
	string s;
	cin >> s;
	dp[0] = true;//0文字目は当然セーフ
	for (int i = 0; i <= s.size(); i++) {
		for (int j = 0; j < list.size(); j++) {
			int size = list[j].size();
			if (i >= size) {
				dp[i] |= dp[i - size] && s.substr(i - size, size) == list[j];//何かしらあればtrue
			}
		}
	}
	puts(dp[s.size()] ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<vector>
#include<cstdio>

using namespace std;

struct P{int c,r;};
struct State{
  int t;
  int pos, remain;
  bool operator < (const State& st) const {
    return t > st.t;
  }
};

const int MAX = 5005;
const int INF = (1<<25);
int T[MAX][MAX];
vector<int> Edge[MAX];
P price[MAX];
int N,K;

void input(){
  scanf("%d %d",&N,&K);
  for(int i = 0; i < N; i++) scanf("%d %d",&price[i].c, &price[i].r);
  for(int i = 0; i < K; i++){
    int a,b;
    scanf("%d %d",&a, &b);
    a--;b--;
    Edge[a].push_back(b);
    Edge[b].push_back(a);
  }
}

void solve(){
  fill(T[0], T[0]+MAX*MAX, INF);
  
  T[0][0] = 0;
  priority_queue<State> Q;
  Q.push((State){0,0,0});
  while(!Q.empty()){
    const State now = Q.top();
    Q.pop();
    
    if(now.t > T[now.pos][now.remain]) continue;
    
    if(now.remain > 0){
      for(int i = 0; i < (int)Edge[now.pos].size(); i++){
	State nex = now;
	nex.pos = Edge[now.pos][i];
	nex.remain--;
	
	if(T[nex.pos][nex.remain] > nex.t){
	  T[nex.pos][nex.remain] = nex.t;
	  Q.push(nex);
	}
      }
    }
    
    State nex = now;
    nex.t += price[now.pos].c; 
    nex.remain = price[now.pos].r;
    if(T[nex.pos][nex.remain] > nex.t){
      T[nex.pos][nex.remain] = nex.t;
      Q.push(nex);
    }
  }
  
  int ans = INF;
  for(int i = 0; i < MAX; i++) ans = min(ans,T[N-1][i]);
  printf("%d\n",ans);
}

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

Measured memory_bytes: 99552
#include<stdio.h>
int main(void) {
   int n, sum, i, t;
   scanf("%d", &n);
   while ( n ) {
      sum = 0;
      for ( i = 0; i < n / 4; i++ ) {
         scanf("%d", &t);
         sum += t;
      }
      printf("%d\n", sum);
      scanf("%d", &n);
   }
   return 0;
}

Measured memory_bytes: 1736
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };
map<char,int> dmp;

int dp[1010][9200];
int main() {
	dmp['L'] = 0;
	dmp['D'] = 1;
	dmp['R'] = 2;
	dmp['U'] = 3;
	while (1) {
		int init, amax; cin >> init >> amax;
		if (!init)break;
		int R, C; cin >> R >> C;
		vector<string>fi;
		for (int i = 0; i < R; ++i) {
			string st; cin >> st;
			fi.push_back(st);
		}
		int T; cin >> T;
		map<char, int>mp;
		for (int i = 0; i < T; ++i) {
			char c; int a; cin >> c >> a;
			mp[c] = a;
		}
		int S; cin >> S;

		int nx = 0;
		int ny = 0;
		vector<int>damages;
		damages.push_back(0);
		for (int i = 0; i < S; ++i) {
			char c; int a;
			cin >> c >> a;
			int way = dmp[c];
			for (int j = 0; j < a; ++j) {
				nx += dx[way];
				ny += dy[way];
				damages.push_back(mp[fi[ny][nx]]);
			}
		}
		int P; cin >> P;
		vector<int>ps;
		for (int i = 0; i < P; ++i) {
			int a; cin >> a;
			ps.push_back(a);
		}
		sort(ps.begin(), ps.end());
		reverse(ps.begin(), ps.end());
		for (int i = 0; i < 1010; ++i) {
			for (int j = 0; j < 9200; ++j) {
				dp[i][j] = 0;
			}
		}
		dp[0][0] = init;
		for (int i = 0; i < damages.size(); ++i) {
			for (int j = 0; j < 1 << P; ++j) {
				dp[i][j] -= damages[i];
				dp[i][j] = max(0, dp[i][j]);
			}
			for (int j = 0; j < 1 << P; ++j) {
				if (dp[i][j]) {

					bitset<12>bs(j);
					for (int k = 0; k < P; ++k) {
						if (!bs[k]) {
							bs[k] = true;
							dp[i][bs.to_ulong()] = max(dp[i][bs.to_ulong()], min(dp[i][j] + ps[k], amax));
							bs[k] = false;
						}
					}
				}
			}
			for (int j = 0; j < 1 << P; ++j) {
				dp[i + 1][j] = dp[i][j];
			}
		}
		string ok = "NO";
		for (int i = damages.size(); true; ++i) {
			
			for (int j = 0; j < 1 << P; ++j) {
				if (dp[i][j]>0) {
					ok = "YES";
					break;
				}
			}
			break;
		}
		cout << ok << endl;
	}
	return 0;
}

Measured memory_bytes: 39484
import java.io.FileNotFoundException;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		sc.close();

		char[] s = S.toCharArray();

		int[] count = new int[4];

		for(int i=0;i<S.length();i++) {
			for(int j=0;j<S.length();j++) {
				if(s[i]==s[j]) {
					count[i]++;
				}
			}
		}
		boolean result = true;
		for(int i=0;i<S.length();i++) {
			if(count[i]!=2) {
				result=false;
			}
		}
		if(result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
# sys.setrecursionlimit(int(pow(10,6)))
# sys.stdout = open("out.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    sys.stdin = open("input.txt", "r")
except:
    pass


# @lru_cache(None)
n=L()[0]
dp=[0 for i in range(n+1)]
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            val=i*i+j*j+k*k+i*j+i*k+j*k
            if val<=n:
                dp[val]+=1
for i in range(1,n+1):
    print(dp[i])

Measured memory_bytes: 10752
def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    if 0 in A:
        return print(0)
    prod = 1
    for n in A:
        prod *= n
        if prod > 1000000000000000000:
            return print(-1)
    return print(prod)

main()

Measured memory_bytes: 21768
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        BigDecimal a = new BigDecimal(scanner.nextInt());
        BigDecimal b = new BigDecimal(scanner.nextInt());

        List<BigDecimal> resultA = calc8(a);
        List<BigDecimal> resultB = calc10(b);

        for (BigDecimal decimal : resultA) {
            BigDecimal sameValue = resultB.stream()
                    .filter(e -> e.compareTo(decimal) == 0)
                    .findFirst()
                    .orElse(null);
            if (sameValue != null) {
                System.out.println(sameValue.toPlainString());
                return;
            }
        }
        System.out.println(-1);
    }

    static List<BigDecimal> calc8(BigDecimal noTax) {
        int max = 1250; // (int) (100d / 0.08d);
        BigDecimal div = new BigDecimal("0.08");

        List<BigDecimal> list = new ArrayList<>();
        for (int i = 1; i <= max; i++) {
            BigDecimal maybe = new BigDecimal(i);
            BigDecimal maybeNoTax = maybe.multiply(div).setScale(0, RoundingMode.DOWN);

            int result = noTax.compareTo(maybeNoTax);
            if (result < 0) {
                break; // もう見てもしょうがない
            }
            if (result == 0) {
                list.add(maybe);
            }
        }
        return list;
    }

    static List<BigDecimal> calc10(BigDecimal noTax) {
        int max = 1000; // (int) (100d / 0.1d);
        BigDecimal div = new BigDecimal("0.1");

        List<BigDecimal> list = new ArrayList<>();
        for (int i = 1; i <= max; i++) {
            BigDecimal maybe = new BigDecimal(i);
            BigDecimal maybeNoTax = maybe.multiply(div).setScale(0, RoundingMode.DOWN);
            int result = noTax.compareTo(maybeNoTax);
            if (result < 0) {
                break; // もう見てもしょうがない
            }
            if (result == 0) {
                list.add(maybe);
            }
        }
        return list;
    }
}

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

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

bool check(const vvi& g) {
  int n = g.size();
  queue<int> q;
  vi c(n,-1);
  REP(i,n){
    if (c[i] == -1) {
      q.push(i);
      c[i] = 0;
    }
    while (!q.empty()) {
      int p = q.front();
      q.pop();
      REP(i, n) {
        if (g[p][i]) {
          if (c[i] == -1) {
            c[i] = 1 - c[p];
            q.push(i);
          }
        }
      }
    }
  }
  REP(i, n)REP(j, n) {
    if (g[i][j] == 1 && c[i] == c[j])return false;
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vvi v(n, vi(n));
  REP(i, n) {
    string s; cin >> s;
    REP(j, n)v[i][j] = s[j] - '0';
  }
  if (!check(v)) {
    cout << -1 << endl;
    return 0;
  }
  vvi d = v;
  REP(i, n)REP(j, n)if (i != j && v[i][j] == 0)d[i][j] = INF;
  REP(k, n)REP(i, n)REP(j, n)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int ans = 0;
  vi used(n, 0);
  REP(i, n) {
    if (used[i])continue;
    vi c;
    queue<int> q;
    q.push(i);
    used[i] = 1;
    c.push_back(i);
    while (!q.empty()) {
      int p = q.front(); q.pop();
      REP(i, n) {
        if (v[p][i] && !used[i]) {
          c.push_back(i);
          used[i] = 1;
          q.push(i);
        }
      }
    }
    int tmp = 0;
    REP(i, c.size())REP(j, c.size()) {
      chmax(tmp, d[c[i]][c[j]]);
    }
    ans += tmp + 1;

  }
  cout << ans << endl;
}


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

const int N = 2e5 + 5;

int n, m;
vector<int > Adj[N];

bitset<N> used;
int d[N];


int main()
{
    scanf("%d %d", &n, &m);

    for(int i = 0; i < m; i++)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        Adj[u].push_back(v);
        Adj[v].push_back(u);
    }

    vector<int> vec;

    bool ok1 = false, ok2 = false;
    for(int i = 0; i < Adj[1].size(); i++)
    {
        int v = Adj[1][i];
        vec.push_back(v);
        if(v == n) ok1 = true;
    }

    for(auto s: vec)
    {
        for(int z: Adj[s])
        {
            if(z == n) ok2 = true;
        }
    }


    if(ok2) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
}


Measured memory_bytes: 12784
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
for af in a[1:]:
    a[0] ^= af
print('Yes' if a[0] == 0 else 'No')


Measured memory_bytes: 12468
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define inf 1e18
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main(){
	int n, m;
	cin >> n >> m;
	vector<ll> p(m), y(m);
	vector<vector<ll>> py(n);
	rep(i, m) {
		cin >> p[i] >> y[i];
		p[i]--;
		py[p[i]].push_back(y[i]);
	}
	rep(i, n) {
		sort(py[i].begin(),py[i].end());
	}
	rep(i, m) {
		string ans = "";
		int id = lower_bound(py[p[i]].begin(), py[p[i]].end(), y[i])-py[p[i]].begin() + 1;
		p[i]++;
		rep(j,5 - (int)log10(p[i])) {
			ans += '0';
		}
		ans += to_string(p[i]);
		rep(j,5 - (int)log10(id)) {
			ans += '0';
		}
		ans += to_string(id);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 8576
fun main(args: Array<String>) {
    val s = readLine()!!
    if (s.contains("A") && s.contains("B")) {
        println("Yes")
    } else {
        println("No")
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<int>> matrix;
typedef vector<vector<long long>> llmatrix;

template <typename T>
istream &operator>>(istream &is, vector<T> &arr);
template <typename T>
ostream &operator<<(ostream &os, vector<T> &arr);
template <typename T>
T max(vector<T> a);
template <typename T>
T min(vector<T> a);

int main()
{
    int X;
    cin >> X;
    int ans = 0;
    ans += 1000 * floor(X / 500);
    X -= floor(X / 500) * 500;
    ans += 5 * (int)(X / 5);
    cout << ans << endl;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &arr)
{
    typename vector<T>::iterator a;
    for (a = arr.begin(); a != arr.end(); a++)
    {
        is >> *a;
    }
    return is;
}

template <typename T>
ostream &operator<<(ostream &os, vector<T> &arr)
{
    typename vector<T>::iterator a;
    for (a = arr.begin(); a != arr.end(); a++)
    {
        os << *a << " ";
    }
    os << endl;
    return os;
}

template <typename T> //assume the vector is not null/non empty
T max(vector<T> a)
{
    typename vector<T>::iterator p;
    T mx = *a.begin();
    for (p = a.begin(); p < a.end(); p++)
    {
        mx = max(mx, *p);
    }
    return mx;
}

template <typename T> //assume the vector is not null/non empty
T min(vector<T> a)
{
    typename vector<T>::iterator p;
    T mn = *a.begin();
    for (p = next(p, 1); p < a.end(); p++)
    {
        mn = min(mn, *p);
    }
    return mn;
}


Measured memory_bytes: 256
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int a[2050];
signed main(void)
{
	int x;
	cin>>x;
	for(int i=-1000;i<=1000;++i)
		a[i+1000]=i*i*i*i*i;
	for(int i=-1000;i<=1000;++i)
		for(int j=-1000;j<=1000;++j)
			if(a[i+1000]-a[j+1000]==x)
			{
				printf("%lld %lld\n",i,j);
				return 0;
			}
	return 0;
}




Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

int main(){
    ll n;
    cin>>n;
    ll quo = log(25*(n+1))/log(26);
    // cout<<quo<<" ";
    vector<char> v(quo);
    ll i;
    for(i=quo-1;i>=0;i--)
    {
        n--;
        v[i] = (char)('a'+n%26);
        // cout<<(char)('a'+n%26);
        n/=26;
    }
    // cout<<v.size()<<" ";
    for(i=0;i<v.size();i++)
        cout<<v[i];

}

Measured memory_bytes: 3792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  double d, ans;

  scanf("%lf",&d);

  ans = d * sqrt(2);
  
  for(int i=1;i<=10;i++){
    if(i <= d && d <= sqrt(i*i + 1)){
      ans = max(ans, (double)(i + 1));
    }
  }
  
  printf("%.10lf\n",ans);
  
  return 0;
}



Measured memory_bytes: 3232
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
const int N=100005;
typedef long long ll;
const ll INF=1e18;
using namespace std;
int x,y,z,n;
ll sau[N],sag[N],scu,ans=-INF;
struct node{
    int a,b,c;
}a[N];
bool cmp(node p,node q){
    return p.a-p.b<q.a-q.b;
}
priority_queue<int,vector<int>,greater<int> > Au,Ag;
int main()
{
	scanf("%d%d%d",&x,&y,&z);
	n=x+y+z;
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i].a,&a[i].b,&a[i].c);
		a[i].a-=a[i].c,a[i].b-=a[i].c;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=n;i;i--)
	{
		sau[i]=sau[i+1]+a[i].a;
		Au.push(a[i].a);
		if(Au.size()>x){
            sau[i]-=Au.top();
            Au.pop();
        }
	}
	for(int i=1;i<=n;i++){
		sag[i]=sag[i-1]+a[i].b;
		Ag.push(a[i].b);
		if(Ag.size()>y){
            sag[i]-=Ag.top();
            Ag.pop();
        }
	}
	for(int i=1;i<=n;i++)
        scu+=a[i].c;
	for(int i=y;i<=n-x;i++)
        ans=max(ans,sau[i+1]+sag[i]);
	printf("%lld\n",ans+scu);
}


Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<vector>
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
 int n,cnt=0,small;
 cin>>n;
 vector<int>v(n);
 for(int i=0;i<n;i++)
  {
   cin>>v[i];
   if(i==0)
     small=v[0];
   
   if(v[i]<=small)
  {
   small=v[i];
    cnt++; 
   }
    }
    cout<<cnt<<endl;
    return 0;   
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

  int m, d;
  cin >> m >> d;
  int res = 0;
  for(int i = 1; i <= m; i++){
    for(int j = 10; j <= d; j++){
      int x = j;
      int a = x % 10;
      x /= 10;
      int b = x % 10;
      if(a >= 2 && b >= 2 && a * b == i) res++;
    }
  }
  cout << res;
}

Measured memory_bytes: 256
def chess(h,w):
    o = ""
    for i in range(h):
        for j in range(w):
            if (i+j)%2: o+="."
            else: o+="#"
        o+="\n"
    print o
 
while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    chess(h,w)

Measured memory_bytes: 6444
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;

int main(){
    char a[10], b[5];
    int c;

    scanf("%s %s", a, b);
    strcat(a, b);
    c = atoi(a);
    //printf("%d\n", c);

    int flag = 0;
    for(int i = 0; i * i <= c; ++i){
        //printf("%d\n", i * i);
        if((i * i) == c){
            flag = 1;
        }
    }

    if(flag == 1) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 1624
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define     pii             pair<ll,ll>
const double eps = 1e-8;


int main()
{

//     ios::sync_with_stdio(0);
//	cin.tie(0);

  ll flag=1;
  string s,s1;
  cin>>s>>s1;

  for(ll i=0;i<zz(s)&&i<zz(s1);i++)
  {
      if(s[i]!=s1[i]) flag=0;
  }

  if(flag) cout<<"Yes"<<nn;
  else cout<<"No"<<nn;





}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n,m;
    cin >> n >> m;
    if(n <= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
input_list = input().split(' ')
a = int(input_list[0])
b = int(input_list[1])
c = int(input_list[2])
count = 0

if a>=1 and b>=1 and c>=1 and 10000>=a and 10000>=b and 10000>=c:
    for i in range(a, b+1):
        if c % i == 0:
            count += 1

print(count)


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

int main(){
  int h,w;
  cin>>h>>w;
  int a[h][w];
  int ctr[h][w];
  int sharp=0;
  memset(ctr,-1,sizeof(ctr));
  for(int i=0;i<h;++i){
    string s;
    cin>>s;
    for(int j=0;j<w;++j){
      if(s[j]=='#'){
        a[i][j]=0;
        sharp++;
      }
      else a[i][j]=1;
    }
  }
  queue<pair<int,int>> Q;
  Q.push(make_pair(0,0));
  ctr[0][0]=0;
  while(Q.size()>0){
    int y=Q.front().first;
    int x=Q.front().second;
    if(y+1>=0&&y+1<h&&a[y+1][x]&&ctr[y+1][x]==-1){
      Q.push(make_pair(y+1,x));
      ctr[y+1][x]=ctr[y][x]+1;
    }
    if(y-1>=0&&y-1<h&&a[y-1][x]&&ctr[y-1][x]==-1){
      Q.push(make_pair(y-1,x));
      ctr[y-1][x]=ctr[y][x]+1;
    }
    if(x+1>=0&&x+1<w&&a[y][x+1]&&ctr[y][x+1]==-1){
      Q.push(make_pair(y,x+1));
      ctr[y][x+1]=ctr[y][x]+1;
    }
    if(x-1>=0&&x-1<w&&a[y][x-1]&&ctr[y][x-1]==-1){
      Q.push(make_pair(y,x-1));
      ctr[y][x-1]=ctr[y][x]+1;
    }
    Q.pop();
  }
  if(ctr[h-1][w-1]==-1)cout<<-1<<endl;
  else cout<<h*w-sharp-ctr[h-1][w-1]-1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <string>
#include <string.h>
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  int count = 0;
  scanf("%d", &n);

  char name_1[1000];
  scanf("%s", name_1);


  char tmp[4] = "ABC";
  char tmp_aa[4];

  for (int i = 0; i < n - 2; i++) {
    tmp_aa[0] = name_1[i];
    tmp_aa[1] = name_1[i+1];
    tmp_aa[2] = name_1[i+2];
    if (strcmp(tmp_aa, tmp) == 0)
      count++;
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

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

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

    cin>>x>>y;
    while(1){
        x*=2;
        if(x>y)break;
        ans++;
    }
    Cout(ans+1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  constexpr int inf = 1 << 30;
  vector<pair<int, int>> ret;
  auto sub = [&] (int i, int j) {
    assert(a[i] != inf && a[j] != inf);
    ret.emplace_back(a[i], a[j]);
    a[i] -= a[j];
  };
  int sum = [&]{
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += abs(a[i]);
    }
    return sum;
  }();
  int m = -1;
  int head = a.front();
  int tail = a.back();
  if (head == 0 && tail == 0) {
    m = 0;
    ret.assign(n - 1, {0, 0});
  } else if (head <= 0) {
    m = sum + 2 * head;
    for (int i = 1; i < n; i++) {
      sub(0, i);
    }
  } else if (tail >= 0) {
    m = sum - 2 * tail;
    for (int i = 1; i < n - 1; i++) {
      sub(n - 1, i);
    }
    sub(0, n - 1);
  } else {
    m = sum;
    int k = [&]{
      for (int i = 1; i < n; i++) {
        if (a[i] <= 0) return i;
      }
      assert(false);
      return -1;
    }();
    for (int i = 1; i < k; i++) {
      sub(k, i);
    }
    for (int i = k; i < n; i++) {
      sub(0, i);
    }
  }
  assert(m == a[0]);
  assert((int)ret.size() == n - 1);
  cout << m << endl;
  for (auto e : ret) {
    cout << e.first << " " << e.second << endl;
  }
  return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int X, Y, Z;
    while(cin >> X >> Y >> Z, X||Y||Z){
        int roulette[5], map[70][2];
        double dp[70][5005] = {1.0};
        rep(i,55) map[i][0] = 0;
        rep(i,X){
            cin >> roulette[i];
        }
        rep(i,Z){
            int N;
            cin >> N;
            cin >> map[N][0] >> map[N][1];
        }
        rep(i,Y){
            rep(j,5005){
                if(dp[i][j] == 0) continue;
                rep(k,X){
                    int loc = i + roulette[k];
                    if(loc >= Y && i < Y) loc = Y;
                    else if(i >= Y) break;
                    if(map[loc][0] == 1){
                        dp[ min(loc + map[loc][1],Y) ][j]+= (dp[i][j] * 1.0 / X);
                    }else if(map[loc][0] == 2){
                        dp[loc][j + map[loc][1]]+= (dp[i][j] * 1.0 / X);
                    }else if(map[loc][0] == 3){
                        if(j - map[loc][1] < 0)
                            dp[loc][0]+= (dp[i][j] * 1.0 / X);
                        else
                            dp[loc][j - map[loc][1]]+= (dp[i][j] * 1.0 / X);
                    }else if(map[loc][0] == 0){
                        dp[loc][j] += (dp[i][j] * 1.0 / X);
                    }
                }
            }
        }
        double ans = 0;
        rep(i,5001){
            if(dp[Y][i] != 0){
                ans+= dp[Y][i] * i;
            }
        }
        cout << static_cast<int>(ans) << endl;
    }
}

Measured memory_bytes: 3904
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	h.push_back(inf);
	int ans = 0;
	int temp = 0;
	rep(i, n)
	{
		if (h[i] >= h[i + 1])
		{
			temp++;
		}
		else
		{
			ans = max(temp, ans);
			temp = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
<?php
//??????????????\???
$up=1;
$south=2;
$east=3;
$west=4;
$north=5;
$down=6;
$ans=1;
$tmp;
$count=0;
//?????§??§5???????????????????????????????????????
while($count<5){
    //??????????????°??????????????????
    $stdin=trim(fgets(STDIN));
    //??????????????°???0??????break
    if($stdin==0){
        break;
    }
    if($stdin<=10000){
        //??????????????°???????????????
        for($i=0;$i<$stdin;$i++){
            $diceRoll=trim(fgets(STDIN));
            //??????????????§??????????????????
            switch($diceRoll){
                case"North":
                    $tmp=$up;
                    $up=$south;
                    $south=$down;
                    $down=$north;
                    $north=$tmp;
                    break;
                case"South":
                    $tmp=$up;
                    $up=$north;
                    $north=$down;
                    $down=$south;
                    $south=$tmp;
                    break;
                case"West":
                    $tmp=$up;
                    $up=$east;
                    $east=$down;
                    $down=$west;
                    $west=$tmp;
                    break;
                case"East":
                    $tmp=$up;
                    $up=$west;
                    $west=$down;
                    $down=$east;
                    $east=$tmp;
                    break;
                case"Right":
                    $tmp=$south;
                    $south=$east;
                    $east=$north;
                    $north=$west;
                    $west=$tmp;
                    break;
                case"Left":
                    $tmp=$south;
                    $south=$west;
                    $west=$north;
                    $north=$east;
                    $east=$tmp;
                    break;
                default:
            }
            //??????????????°????????????
            $ans+=$up;
        }
        //????????????
        echo $ans."\n";
        //?????????
        $up=1;
        $south=2;
        $east=3;
        $west=4;
        $north=5;
        $down=6;
        $ans=1;
        //????????????????????°????????????
        $count++;
    }
}

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

const int MOD=1000000007;

int main(){
	int n;cin>>n;
	ll A=0,B=0;
	rep(i,n){
		ll a;scanf("%lld",&a);
		(A+=a)%=MOD;
		(B+=a*a)%=MOD;
	}
	ll t=(MOD+1)/2;
	cout<<(A*A%MOD+MOD-B)%MOD*t%MOD<<endl;
}

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

int ada[105];
string s;

int main(){
	cin >> s;
	int cnt = 0;
	for(int i=0;i<s.size();i++){
		ada[s[i]-'a']^=1;
		if(ada[s[i]-'a'] == 1) cnt++;
		else cnt--;
	}
	if(cnt > 0) cout << "No\n";
	else cout << "Yes\n";
	return 0;
}

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

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

int main() 
{
  int n;
  cin >> n;
  int x[n],y[n];
  int i;
  for(i = 0; i < n;++i){
    cin >> x[i];
  }
  for(i = 0; i < n;++i){
    cin >> y[i];
  }
  double c[n];
  for(i = 0; i < n;++i){
    c[i] = x[i] - y[i];
    if(c[i] < 0){
      c[i] = -c[i];
    }
  }
  double ans1 = 0;
  for(i = 0;i < n;++i){
    ans1 += c[i];
  }
  double ans2 = 0;
  for(i = 0;i < n;++i){
    ans2 += c[i]*c[i];
  }
  ans2 = sqrt(ans2);
  double ans3 = 0;
  for(i = 0;i < n;++i){
    ans3 += c[i]*c[i]*c[i];
  }
  ans3 = pow(ans3,1.0/3.0);
  double ansi = c[0];
  for(i = 1;i < n;++i){
    if(ansi < c[i]){
      ansi = c[i];
    }
  }
  printf("%lf\n",ans1);
  printf("%lf\n",ans2);
  printf("%lf\n",ans3);
  printf("%lf\n",ansi);
}


Measured memory_bytes: 3340
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[4];
int main()
{
    int i,j,k;
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    k=a[2]-a[1]+a[1]-a[0];
    printf("%d\n",k);
    return 0;
}

Measured memory_bytes: 128
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;cin>>n;vector<int> v(n);
    rep(i,0,n)v[i]=i+1;
    do{
        rep(i,0,v.size()){
            if(i)cout<<" ";
            cout<<v[i];
        }
        cout<<endl;
    }while(next_permutation(all(v)));
}



/*
5
105 24 C 1500000000000 white
100 23 C 1500000000000 blue
105 23 A 1480000000000 pink
110 25 B 1500000000000 black
110 20 A 1300000000000 gree
*/



Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>

using namespace std;

int n, m;
int cnt;
int a[100005];

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++)
    {
        int t1, t2;
        scanf("%d%d", &t1, &t2);
        a[t1]++;
        a[t2 + 1]--;
    }
    for(int i = 1; i <= n; i++)
    {
        a[i] += a[i - 1];
        if(a[i] == m) cnt++;
    }
    printf("%d", cnt);
    return 0;
}


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

const llong MOD = 1e9+7;
const llong inf = 1<<30;



int main() {
    int N; cin >> N;
    int res = 0;
    for (int i = 1; i <= N; i++) {
        string temp = to_string(i);
        int digit = temp.size();
        if (digit%2) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
k,n = map(int, input().split())
lst = list(map(int, input().split()))

maxDis = (k-lst[-1]) + lst[0]
for i in range(n-1):
  if lst[i+1] - lst[i] > maxDis:
    maxDis = lst[i+1] - lst[i]
print(k-maxDis)

Measured memory_bytes: 25840
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000000000000
#define mod 1000000007
#define endl '\n'
#define omarshagar                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;
vector<int>graph[100001];
set<pair<int,int>>black;
vector<pair<int,int>>vec;
bool vis[100001];
ll dfs(int s,bool vis[])
{
    ll tmp=0;
    if(vis[s])return 0;
    vis[s]=1;

    for(auto g:graph[s])
    {
        if(black.find({min(g,s),max(g,s)})==black.end())
        {
            tmp+=dfs(g,vis);
        }
    }

    return tmp+1;
}
pair<int,int>disj[100001];
int findpar(int x)
{
    if(disj[x].first==x)return x;
    return findpar(disj[x].first);
}
void Union(int a,int b)
{
    disj[max(b,a)].second+=disj[min(a,b)].second;
    disj[min(a,b)].first=max(a,b);
}
int main() {
    omarshagar
    for(int i=0;i<100001;i++)
    {
        disj[i].first=i;
        disj[i].second=1;
    }
    vector<pair<int,int>>edges;
    int n,m;
    cin>>n>>m;
    int a,b;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        a--;b--;
        edges.push_back({min(a,b),max(b,a)});
    }
    vector<ll>res;
    for(int i=edges.size()-1;i>=0;i--)
    {
         a=edges[i].first;
         b=edges[i].second;
         int bb=findpar(b);
         int aa=findpar(a);
         //cout<<aa<<" "<<bb<<endl;
         if(aa!=bb)
         {
             res.push_back(disj[aa].second*disj[bb].second);
             Union(aa,bb);
         }

         else res.push_back(0);
      //  cout<<" "<<disj[aa].second<<" "<<disj[bb].second<<endl;

    }
    ll sum=0;
    for(int i=res.size()-1;i>=0;i--)
    {
        sum+=res[i];
        cout<<sum<<endl;
    }
    return 0;
}
/*
 1
 4
1000
0010
0100
0001


 */

Measured memory_bytes: 6132
#include<iostream>

using namespace std;

int N;
int A[210];

int main() {
    cin >> N;

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

    int res = 0;

    bool exist_odd = false;


    while (true) {
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) {
                exist_odd = true;
                break;
            }
                
        }

        if (exist_odd)
            break;

        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=3005;
#define M 998244353
#define double long double
#define BINF 10000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 5000004
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);

    int n;
    cin >> n;
    double x = (double)n / 3.0;
    double ans = 1;
    for(int i = 0; i < 3; i++)
        ans *= x;
    cout << fixed << setprecision(8) << ans << endl;
    
    

return 0;  
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int color[8][3],i,j,k,rgb[3],min,c,d,r,g,b;
	color[0][0]=0; color[0][1]=0; color[0][2]=0;
	color[1][0]=0; color[1][1]=0; color[1][2]=255;
	color[2][0]=0; color[2][1]=255; color[2][2]=0;
	color[3][0]=0; color[3][1]=255; color[3][2]=255;
	color[4][0]=255; color[4][1]=0; color[4][2]=0;
	color[5][0]=255; color[5][1]=0; color[5][2]=255;
	color[6][0]=255; color[6][1]=255; color[6][2]=0;
	color[7][0]=255; color[7][1]=255; color[7][2]=255;
	char a[]="0123456789abcdef",s[8];
	while(1){
		for(i=0;i<3;i++)rgb[i]=0;
		cin>>s;
		if(s[0]=='0') break;
		i=0;
		for(j=1;j<6;j+=2){
			for(k=0;k<16;k++){
				if(s[j]==a[k]){
					rgb[i]=rgb[i]+k*16;
					break;
				}
			}
			for(k=0;k<17;k++){
				if(s[j+1]==a[k]){
					rgb[i]=rgb[i]+k;
					break;
				}
			}
			i++;
		}
		min=1000000;
		for(i=0;i<8;i++){
			r=color[i][0]-rgb[0];
			g=color[i][1]-rgb[1];
			b=color[i][2]-rgb[2];
			d=r*r+g*g+b*b;
			if(min>d){
				min=d;
				c=i;
			}
		}
		if(c==0) cout<<"black"<<endl;
		if(c==1) cout<<"blue"<<endl;
		if(c==2) cout<<"lime"<<endl;
		if(c==3) cout<<"aqua"<<endl;
		if(c==4) cout<<"red"<<endl;
		if(c==5) cout<<"fuchsia"<<endl;
		if(c==6) cout<<"yellow"<<endl;
		if(c==7) cout<<"white"<<endl;
//		printf("%d %d %d\n",rgb[0],rgb[1],rgb[2]);
	}
	return 0;
}

Measured memory_bytes: 3024