akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

//	modNの計算をするクラス
template <int mod> struct mint {
    int data;
    mint( void ) :data(0) {}
    mint( int n ) :data( n>=0 ? n%mod : (mod - (-n)%mod) %mod ) {}
    operator int() { return data; }
    friend istream &operator>>(istream&is,mint&m){int n; is>>n; m=n; return is;}
    friend ostream &operator<<(ostream&os,mint&m){os<<(int)m; return os;}
    mint operator+ ( int n ) { return (data + n) % mod; }
    mint operator+ (mint m ) { return *this + (int)m; }
    void operator+=( int n ) { data = *this +      n; }
    void operator+=(mint m ) { data = *this + (int)m; }
    mint operator* ( int n ) { return (lint)data * n % mod; }
    mint operator* (mint m ) { return *this * (int)m; }
    void operator*=( int n ) { data = *this *      n; }
    void operator*=(mint m ) { data = *this * (int)m; }
    mint operator/ ( int n ) { return *this * mint(n).inv(); }
    mint operator/ (mint m ) { return *this * m.inv(); }
    void operator/=( int n ) { data = data * mint(n).inv(); }
    void operator/=(mint m ) { data = data * m.inv(); }
    bool operator==( int n ) { return data == n; }
    bool operator==(mint m ) { return data == m.data; }
    bool operator!=( int n ) { return data != n; }
    bool operator!=(mint m ) { return data != m.data; }
    mint pow(int n){mint a=1,b=data;while(n>0){if(n&1)a*=b;b*=b;n>>=1;}return a;}
    mint pow(mint m){ return (*this).pow((int)m); }
    mint inv(){int a=data,b=mod,c=1,d=0,e;while(b){e=a/b;swap(a-=e*b,b);swap(c-=e*d,d);}return c;}
};
using mint_7 = mint<1000000007>;

int main() {
    const int MAX = 1000;
    int H = in, W = in;
    vector<string> A(H);
    rep( i, H ) cin >> A[i];

    mint_7 dp[MAX][MAX];
    dp[0][0] = 1;
    for( int i=1; i<H; i++ ) dp[i][0] = dp[i-1][0] * (A[i][0] == '.');
    for( int i=1; i<W; i++ ) dp[0][i] = dp[0][i-1] * (A[0][i] == '.');

    for( int y=1; y<H; y++ ) for( int x=1; x<W; x++ ) {
        dp[y][x] = (dp[y-1][x] + dp[y][x-1]) * (A[y][x] == '.');
    }

    cout << dp[H-1][W-1] << "\n";
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  for(;;){
    int N,M;
    cin >> N >> M;
    if(N == 0 || M == 0) break;
    vector<pair<int,int> > v(M,make_pair<int,int>(0,0));
    vector<vector<pair<int,int> > > w(M);
    int r;
    cin >> r;
    for(int i=0; i<r; i++){
      int t,n,m,s;
      cin >> t >> n >> m >> s;
      if(s == 1){
        if(v[m-1].first++ == 0) v[m-1].second = t;
      }else if(s == 0){
        if(--v[m-1].first == 0)
          w[m-1].push_back(make_pair<int,int>(v[m-1].second,t));
      }
    }
    int q;
    cin >> q;
    for(int i=0; i<q; i++){
      int ts,te,m;
      cin >> ts >> te >> m;
      vector<pair<int,int> > x = w[m-1];
      int ret=0;
      for(vector<pair<int,int> >::iterator p = x.begin(); p != x.end(); p++){
        int start = ts < (*p).first ? (*p).first : ts;
        int end = (*p).second < te ? (*p).second : te;
        if(end - start > 0) ret += end - start;
      }
      cout << ret << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1504
#include <bits/stdc++.h>
using namespace std;
#define N 1010
#define ll long long

int n,cnt;
int mark[N*10];
ll pri[N],a[N][N];

void getpri() {
	for (int i=2;i<=10000;i++) {
		if (!mark[i]) pri[++cnt]=i;
		if (cnt==1000) break;
		for (int j=1;j<=cnt && i*pri[j]<=10000;j++) {
			mark[i*pri[j]]=1;
			if (i%pri[j]==0) break;
		}
	}
}

ll lcm(ll x,ll y) {
	if (!x || !y) return x+y;
	return x/__gcd(x,y)*y;
}

int main()
{
	getpri();
	scanf("%d",&n);
	if (n==2) {
		puts("4 7");
		puts("23 10");
		return 0;
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if ((i+j)%2==0)
				a[i][j]=pri[(i+j)/2]*pri[n+(i-j)/2+(n+1)/2];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (!a[i][j])
				a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=n;j++)
			printf("%lld ",a[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 7296
// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#define _USE_MATH_DEFINES

#include "stdio.h"
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <unordered_set>
#include <functional>
#include <array>

using namespace std;

bool canGenerateNum(const vector<int>& vec, const int number)
{
	function<bool(const vector<int>& v, const int index, const int num)> canGenerateNumImpl = [&](const vector<int>& v, const int index, const int num) {
		if (num == 0)return true;
		if (num < 0 || index == v.size())return false;
		return canGenerateNumImpl(v, index + 1, num) || canGenerateNumImpl(v, index + 1, num - v.at(index));
	};
	return canGenerateNumImpl(vec, 0, number);
}

struct Point{
	Point(const double x = 0.0, const double y = 0.0) :x(x), y(y) {}
	Point operator+(const Point& rhs)const {
		return Point(x + rhs.x, y + rhs.y);
	}
	Point operator-(const Point& rhs)const {
		return Point(x - rhs.x, y - rhs.y);
	}
	Point operator*(const double num) const {
		return Point(x*num, y*num);
	}
	Point operator/(const double num) const {
		return Point(x/num, y/num);
	}
	double x, y;
};

ostream& operator<<(ostream& os, const Point& p){
	os << p.x << " " << p.y;
	return os;
}


//2次元で点を左回りに回転する
Point rotatePoint(const Point& rotationCenter, const Point& rotationTarget){
	static const double sixtyDegreeInRadian = M_PI / 3.0;
	static const double  cosine60 = cos(sixtyDegreeInRadian);
	static const double  sine60 = sin(sixtyDegreeInRadian);
	const Point v(rotationTarget - rotationCenter);
	const Point rotatedV(v.x*cosine60 - v.y*sine60, v.x*sine60 + v.y*cosine60);
	return rotationCenter + rotatedV;
}

void printKoch(const Point& p1, const Point& p2, const int n) {
	const function<void(const Point& p1, const Point& p2, const int depth)> printKochImpl
		= [&](const Point& p1_, const Point& p2_, const int depth_) {
		if (depth_ >= n) return;
		const Point& vec = (p2_ - p1_)/3.0;
		const Point p1_1 = p1_ + vec;
		const Point p1_3 = p1_ + vec * 2.0;
		const Point p1_2 = rotatePoint(p1_1, p1_3);

		
		printKochImpl(p1_, p1_1, depth_ + 1);
		cout << fixed << setprecision(5) << p1_1 << endl;
		printKochImpl(p1_1, p1_2, depth_ + 1);
		cout << fixed << setprecision(5) << p1_2 << endl;
		printKochImpl(p1_2, p1_3, depth_ + 1);
		cout << fixed << setprecision(5) << p1_3 << endl;
		printKochImpl(p1_3, p2_, depth_ + 1);
		
	};
	if (n < 0)return;
	cout << fixed << setprecision(5) << p1 << endl;
	printKochImpl(p1, p2, 0);
	cout << fixed << setprecision(5) << p2 << endl;
}

int main()
{
	int n;
	cin >> n;
	const Point p1(0.0 ,0.0);
	const Point p2(100.0, 0.0);
	printKoch(p1, p2, n);

	
	return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define nl cout<<"\n"
#define dbg(x) cout<<x<<" ";
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define UM unordered_map<int,int>
#define ULL unordered_map<ll,int>
void fun(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[2]*10+a[1]+a[0];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  fun();
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = [[0]*w for _ in range(h)]

def dfs(x, y):
    cnt = 0
    for i in range(x - 1, x + 2):
        for j in range(y - 1, y + 2):
            if i == x and j == y:
                continue
            if 0 <= i < h and 0 <= j < w:
                if s[i][j] == "#":
                    cnt += 1
    return cnt

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            s[i][j] = str(dfs(i, j))
for i in s:
    print("".join(i))
            

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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vint vector<int>

int main() {
    string s;cin>>s;
    string t = "CODEFESTIVAL2016";
    int ans=0;
    rep(i,16) {
        if(s[i] != t[i]) ans++;
    }
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n = 0;
	int m = 0;
	int results = 0;
	scanf("%d%d", &n, &m);//_sの削除
	results += (n * (n - 1)) / 2;
	results += (m * (m - 1)) / 2;
	printf("%d", results);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int m, h;
  while(1) {
    cin >> s;
    if (s == "-") break;
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> h;
      s = s.substr(h) + s.substr(0, h);
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	sll s;
	ll a;
	rep(i,0,2,1)
	{
		cin>>a;
		s.insert(a);
	}
	if(s.size()==2)
	{
		cout<<"Yes";
	}
	else
	
	{
		cout<<"No";
	}
	return 0;
}




Measured memory_bytes: 256
n, m, r = gets.strip.split.map(&:to_i)
r = gets.strip.split.map(&:to_i)

roads = Array.new(n+1) { [10**8]*(n+1) }

readlines.each do |line|
  a, b, c = line.strip.split.map(&:to_i)
  roads[b][a] = roads[a][b] = c
end


(n+1).times do |via|
  (n+1).times do |s|
    s_via = roads[s][via]
    (n+1).times do |g|
      via_center = s_via + roads[via][g]
#      roads[g][s] = roads[s][g] = [roads[s][g], via_center].min
      roads[g][s] = roads[s][g] = via_center if roads[s][g] > via_center
    end
  end
end

result = 10**9
r.permutation.each do |arr| 
  tmp = 0
  arr.each_cons(2) do |from, to|
    tmp += roads[from][to]
  end
  result = tmp if result > tmp
end

 p result

Measured memory_bytes: 4476
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)
	if a%k == 0 {
		fmt.Println("OK")
		return
	}
	rem := (a/k)*k + k
	if a <= rem && rem <= b {
		fmt.Println("OK")
		return
	}
	fmt.Println("NG")
}


Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e6 + 10, oo = 1e9 + 10;
ll h[N];
struct Line{
    ll k = 0, b = 0;
    ll f(ll x) {
        return k * x + b;
    }
};
struct node{
    Line L;
    node *l, *r; 
    node() {
        l = r = NULL;
    }
} *root;
void add_line(int l, int r, Line x, node *&t) {
    if(!t) {
        t = new node();
        t->L = x;
        return;
    }
    int m = l + r >> 1;
    bool lef = x.f(l) < t->L.f(l);
    bool mid = x.f(m) < t->L.f(m);
    if(mid) {
        swap(t->L, x);
    }
    if(l == r) {
        return;
    } else if(lef != mid) {
        add_line(l, m, x, t->l);
    } else {
        add_line(m + 1, r, x, t->r);
    }
}
ll get(int l, int r, int x, node *&t) {
    if(!t) return oo;
    if(l == r) return t->L.f(x);
    int m = l + r >> 1;
    return min(t->L.f(x), x <= m ? get(l, m, x, t->l) : get(m + 1, r, x, t->r));
}
int main() {
    ll n, c, best;
    Line cur;
    cin >> n >> c;
    for(int i = 1; i <= n; ++i) cin >> h[i];
    cur = {-2 * h[1], h[1] * h[1]};
    add_line(1, N, cur, root);
    for(int i = 2; i <= n; ++i) {
        ll sq = h[i] * h[i];
        best = get(1, N, h[i], root) + sq + c;
        cur = {-2 * h[i], best + sq};
        add_line(1, N, cur, root);
    }
    cout << best << endl;
}

Measured memory_bytes: 14528
using System;
using System.Collections.Generic;
using System.Linq;

public class PrintAChessboard
{
    //??????H cm ?????? W cm ????????§?????????????????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        int i;
        int k;
        int l;
        string[] strRectangleData;
        List<string> strRectangleList = new List<string>();
        /*---??£?¨???¨---*/

        /*??\???(H W)?????????{H W ????????????0?????´?????????}*/
        for(i = 0;;i++) {
            strRectangleList.Add(Console.ReadLine());
            strRectangleData = strRectangleList[i].Split(' ');
            if (strRectangleData[0] == "0" && strRectangleData[1] == "0"){
                break;
            }
        }

        /*????????????int?????§??´???*/
        int[,] intRectangleData = new int[strRectangleList.Count, 2];

        for (i = 0; i < strRectangleList.Count - 1; i++) {
            strRectangleData = strRectangleList[i].Split(' ');
            intRectangleData[i,0] = int.Parse(strRectangleData[0]);
            intRectangleData[i,1] = int.Parse(strRectangleData[1]);
            }

        /*????????¢????????????[#]??§??¨???????????????[.]??§??¨???*/
        for (i = 0; i < strRectangleList.Count - 1; i++) {
            for (k = 0; k < intRectangleData[i, 0]; k++) {
                //??¶??°?????????[.]??????????¢????????????????
                if (k % 2 == 1){
                    Console.Write(".");
                }
                for (l = 0; l < ((k % 2 == 0) ? intRectangleData[i, 1] : intRectangleData[i, 1] - 1); l++) {
                    //[#]??¨[.]??????????????¨?????????
                    if (l % 2 == 0)
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.Write("\n");
            }
            Console.Write("\n");
        }
    }
}

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

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ld = long double;

constexpr int nax = 200 * 1000 + 105;
constexpr int infty = 1000 * 1000 * 1000 + 5;
constexpr int mod = 1000 * 1000 * 1000 + 7;

int n;
int tab[nax];

map<int, int> dp;

int Get(int x) {
  auto it = dp.find(x);
  if (it == dp.end()) return n + 100;
  return it->second;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  n = s.size();
  for (int i = 1; i <= n; i++) {
    tab[i] = (1 << (int) (s[i - 1] - 'a'));
    tab[i] ^= tab[i - 1];
  }
  dp[0] = 0;
  int last = 0;
  for (int i = 1; i <= n; i++) {
    int wynik = Get(tab[i]);
    debug() << imie(i) imie(tab[i]);
    debug() << "poc" imie(i) imie(wynik);
    for (int j = 0; j < 'z' - 'a' + 1; j++) {
      const int mabyc = tab[i] ^ (1 << j);
      wynik = min(wynik, Get(mabyc));
    }
    wynik++;
    debug() << imie(i) imie(wynik);
    last = wynik;
    wynik = min(Get(tab[i]), wynik);
    dp[tab[i]] = wynik;
    debug() << imie(dp);
  }
  cout << last << endl;
  return 0;
}


Measured memory_bytes: 10644
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,x,t = list(map(int, input().split()))
ans = t * (n//x + int(n%x!=0))
print(ans)

Measured memory_bytes: 61732
t = []
for i in range(5):
    t.append(int(input()))

s = []
for i in range(5):
    s.append(t[i] % 10)

o = 5
p = 10
for i in range(5):
    if s[i] > 0:
        if p > s[i]:
            o = i
            p = s[i]

m = 0
for i in range(5):
    if i != o:
        if s[i] == 0:
            m += t[i]
        else:
            m += t[i] - t[i] % 10 + 10

if o != 5:
    m += t[o]
print(m)

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_H = (int)(3e2 + 5);
const int MAX_W = (int)(3e2 + 5);

int h, w, k;
char s[MAX_H][MAX_W];

int cnt[MAX_H];
int ans[MAX_H][MAX_W];

int main(void) {
  // Here your code !
  scanf("%d %d %d", &h, &w, &k);

  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      cin >> s[i][j];
      if (s[i][j] == '#') cnt[i] += 1;
    }
  }

  int start;

  for (int i = 1; i <= h; ++i) {
    if (cnt[i] > 0) {
      start = i;
      break;
    }
  }

  int p = 0;

  for (int i = start; i <= h; ++i) {
    if (cnt[i] == 0) {
      for (int j = 1; j <= w; ++j) {
        ans[i][j] = ans[i - 1][j];
      }
      continue;
    }

    p += 1;

    for (int j = 1; j <= w; ++j) {
      ans[i][j] = p;
      if (s[i][j] == '#') {
        cnt[i] -= 1;
        if (cnt[i] > 0) p += 1;
      }
    }
  }

  for (int i = start - 1; i >= 1; --i) {
    for (int j = 1; j <= w; ++j) {
      ans[i][j] = ans[i + 1][j];
    }
  }

  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      printf("%d ", ans[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double PI = acos(-1.0);
const int N = 100000;

int main()
{
    for(;;){
        int p, q, r;
        cin >> p >> q >> r;
        if(p == 0)
            return 0;

        if(r == 0){
            double ret = (p - q) * 2.0 * PI;
            printf("%.10f\n", ret);
            continue;
        }

        double theta = 2.0 * PI * q / p;
        double ret = 0.0;
        double x1 = p - q + r;
        double y1 = 0.0;
        for(int i=1; i<=N; ++i){
            double x2 = (p - q) * cos(theta/N*i) + r * cos((p - q) * theta/N*i / q);
            double y2 = (p - q) * sin(theta/N*i) - r * sin((p - q) * theta/N*i / q);
            ret += sqrt(pow(x1 - x2, 2.0) + pow(y1 - y2, 2.0));
            x1 = x2;
            y1 = y2;
        }

        int i = 1;
        while((q * i) % p != 0)
            ++ i;
        ret *= i;

        printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	int h, m, h2, m2, k;
	cin >> h >> m >> h2 >> m2 >> k;

	int sum = (h2 * 60 + m2) - (h * 60 + m);

	cout << sum - k;

	return 0;
}

Measured memory_bytes: 3636
program main
  implicit none
  integer i,n_R,n_L,ans,N
  character(10**5) S
  integer,allocatable :: A(:)
  !read(*, *) (L(i), i = 1,N)
  read(*, *) S
  N = len(trim(S))
  allocate(A(N))
  A = 0
  n_R = 1
  n_L = 0
  ans = 1
  do i = 2,N
    if (S(i-1:i) == 'LR') then
      A(ans-1) = (n_R/2) + mod(n_R,2)
      A(ans-1) = A(ans-1) + n_L/2
      A(ans) = n_R/2
      A(ans) = A(ans) + n_L/2 + mod(n_L,2)
      n_R = 1
      n_L = 0
    elseif (S(i-1:i) == 'RL') then
      n_L = 1
      ans = i
    elseif (S(i-1:i) == 'LL') then
      n_L = n_L + 1
    elseif (S(i-1:i) == 'RR') then
      n_R = n_R + 1
    end if
  end do
  A(ans-1) = (n_R/2) + mod(n_R,2)
    A(ans-1) = A(ans-1) + n_L/2
    A(ans) = n_R/2
    A(ans) = A(ans) + n_L/2 + mod(n_L,2)
  write(*, *) A
end program main


Measured memory_bytes: 2596
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let R = scan.word::<f64>();

    println!("{}", 2.0 * std::f64::consts::PI * R);
}


Measured memory_bytes: 2160
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include<list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
using namespace std;
int a[10003];
int main(){
  int n,ans=0;
  cin>>n;
  for (int i=0;i<n;i++){
    cin>>a[i];
    while (a[i]%2==0){
      a[i]/=2;
      ans++;
	}
  }
  cout<<ans;
  return 0;
}

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

int main() {
    vector<string> s(3);
    rep(i, 3) cin >> s.at(i);
    vector<int> cards(3);
    int turn = 0;
    while (true) {
        if (cards.at(turn) == s.at(turn).size()) {
            char ans = 'A' + turn;
            cout << ans << endl;
            break;
        }
        int next = s.at(turn).at(cards.at(turn)) - 'a';
        cards.at(turn)++;
        turn = next;
    }
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	int n;
	cin >> n;
	int ans=0, amin=inf;
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		if(a <= amin) ans++;
		amin = min(amin, a);
	}
	cout << ans << endl;
    return 0;
}


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

namespace My
{
class Solver
{
  public:
	Solver() {}
	void Solve(istream &cin, ostream &cout)
	{
		string S;
		cin >> S;

		int scnt = 0;
		int ans = 0;
		REP (i, S.length()) {
			auto c = S[i];
			if (c == 'S') {
				++scnt;
			} else {
				if (0 == scnt) {
					// Tが残る
					++ans;
				} else {
					// STを消す
					--scnt;
				}
			}
		}
		ans += scnt;

		cout << ans << endl;
	}

	template <typename ArrayT>
	static void DumpArray(const ArrayT &arr)
	{
	#if defined(HOME)
		for (auto it = std::begin(arr); it != std::end(arr); ++it) {
			cerr << *it << " ";
		}
		cerr << endl;
	#endif
	};
	template <typename T>
	static bool ChMin(T &target, T value)
	{
		if (value < target) {
			target = value;
			return true;
		} else {
			return false;
		}
	}
	template <typename T>
	static bool ChMax(T &target, T value)
	{
		if (target < value) {
			target = value;
			return true;
		} else {
			return false;
		}
	}
};
} // namespace MySpace

#if !defined(BOOST_TEST_MODULE)
#if !defined(GTEST_INCLUDE_GTEST_GTEST_H_)
int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	My::Solver solver;
	solver.Solve(std::cin, std::cout);

	return 0;
}
#endif
#endif


Measured memory_bytes: 720
var  i,j,k,l:longint;
     s:ansistring;
     c:boolean;
begin
  c:=false;
  readln(s);
  for  i:=1  to  length(s)  do
    begin
      if  s[i]='C'  then  c:=true;
      if  (s[i]='F')and( c )then
        begin
          writeln('Yes');
          exit;
        end;
    end;
  writeln('No');
end.


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <limits>

// -------------8<------- start of library -------8<------------------------
template<class T>
struct Graph {
    const int n, s;
    const T INF;
    bool is_neg_cycle;
    std::vector<std::vector<std::pair<int, T>>> adj;
    std::vector<T> d;

    Graph(int _n, int _s)
        : n(_n), s(_s), INF(std::numeric_limits<T>::max()),
          is_neg_cycle(false), adj(n), d(n, INF) { }

    void add_edge(int u, int v, T w) { adj[u].emplace_back(std::make_pair(v, w)); }
    T ShortestDistance(const int t) const { return d[t]; }
    bool IsNegativeCycleFromS() const { return is_neg_cycle; }

    bool CheckNegativeCycle() {
        std::fill(d.begin(), d.end(), 0);
        BellmanFord();
        return is_neg_cycle;
    }

    void BellmanFord() {
        d[s] = 0;
        for (int i = 0; ; ++i) {
            bool update = false;
            for (int v = 0; v < n; ++v)
                for (const auto &e : adj[v])
                    if (d[v] < INF && d[v] + e.second < d[e.first]) {
                        d[e.first] = d[v] + e.second;
                        update = true;
                    }
            if (!update) break;
            if (i == n - 1) { is_neg_cycle = true; break; }
        }
    }
};
// -------------8<------- end of library ---------8-------------------------

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

    // AOJ GPL_1_B: Shortest Path - Single Shortest Path (Negative Edges)
    int n, m, r, s, t, d;
    std::cin >> n >> m >> r;

    Graph<int> g(n, r);
    for (int i = 0; i < m; ++i) {
        std::cin >> s >> t >> d;
        g.add_edge(s, t, d);
    }

    g.BellmanFord();
    if (g.IsNegativeCycleFromS())
        std::cout << "NEGATIVE CYCLE\n";
    else {
        for (int v = 0; v < n; ++v) {
            int dist = g.ShortestDistance(v);
            if (dist == g.INF) std::cout << "INF\n";
            else std::cout << dist << '\n';
        }
    }

    return 0;
}



Measured memory_bytes: 3228
import heapq,sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S]=0;H=[(0,S)]
 while H:
  c,u=heapq.heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heapq.heappush(H,(t,v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:print(g(n,E,*p))
  else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


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

const int NMAX = 1e5 + 5;
long long freq[NMAX], x, sum, y, t, n;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x;
        freq[x]++;
        sum += x;
    }
    cin >> t;
    while(t--) {
        cin >> x >> y;
        sum = sum - freq[x] * x + freq[x] * y;
        freq[y] += freq[x];
        freq[x] = 0;
        cout << sum << '\n';
    }
    return 0;
}


Measured memory_bytes: 4404
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c,d,p,alla,allb,ans;
    cin>>a>>b>>c>>d>>p;
    alla=a*p;
    if(p>c)allb=b+(p-c)*d;
    else allb=b;
    ans=min(alla,allb);
    cout<<ans<<endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N, K, h[100010], dp[100010], MIN;
    scanf("%lld %lld", &N, &K);
    rep(i, 0, N) scanf("%lld", h+i);
    dp[0] = 0;
    rep(i, 1, N){
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        rep(j, 2, K+1){
            if(i-j<0) break;
            dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
        }
    }
    printf("%lld\n", dp[N-1]);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


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

int main() {

  char s1,s2,s3;
  cin>>s1>>s2>>s3;
  int c;
  c=0;
  if (s1=='1'){
    c=c+1;
  }
  if (s2=='1'){
    c=c+1;
  }
  if(s3=='1'){
    c=c+1;
  }
  cout<<c<<endl;
}

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

int main()
{
  int n, m;
  while (cin >> n >> m) {
    if ((n|m) == 0)
      break;

    vector<int> v(n);
    for (int i = 0; i < n; ++i)
      cin >> v[i];
    while (v.size() % m != 0)
      v.push_back(0);
    sort(v.begin(), v.end(), greater<int>());

    int ans = 0;
    for (unsigned int i = 0; i < v.size(); i += m) {
      for (int j = 0; j < m-1; ++j)
	ans += v[i+j];
    }

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
//const int MOD=1e9+7;
 
const int MOD=998244353;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    if(!(n%3)){
        vector<string> ans(n,string(n,'.'));
        
        for(int i=0; i<n; i+=3){
            ans[i][i]='a';
            ans[i][i+1]='a';
            ans[i+1][i+2]='a';
            ans[i+2][i+2]='a';
        }
        for(auto s:ans){
            cout<<s<<'\n';
        }
        return 0;
    }
    if(!(n%4)){
        vector<string> vs={"aacd","bbcd","cdaa","cdbb"};
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j+=4){
                cout<<vs[i%4];
            }
            cout<<'\n';
        }
        return 0;
    }
    if(!(n%5)){
        vector<string> vs={"xyycc","xaa.w","i..aw","i..au","ssttu"};
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j+=5){
                cout<<vs[i%5];
            }
            cout<<'\n';
        }
        return 0;
    }
    int a=-1,b=-1;
    
    for(int i=0; i<1000 && a==-1; i++){
        for(int j=0; j<1000; j++){
            if(5*i+4*j==n){
                a=i;
                b=j;
                break;
            }
        }
    }
    
    if(a!=-1){
        //cout<<a<<' ';
        vector<string> vs4={"aacd","bbcd","cdaa","cdbb"};
        vector<string> vs5={"xyycc","xaa.w","i..aw","i..au","ssttu"};
        vector<string> ans(n,string(n,'.'));
        int pos=0;
        
        while(pos<b*4){
            for(int i=0; i<4; i++){
                for(int j=0; j<4; j++){
                    ans[pos+i][pos+j]=vs4[i%4][j];
                }
            }
            pos+=4;
        }
        while(pos<b*4+a*5){
            for(int i=0; i<5; i++){
                for(int j=0; j<5; j++){
                    ans[pos+i][pos+j]=vs5[i%5][j];
                }
            }
            pos+=5;
        }
        
        
        for(auto s:ans){
            cout<<s<<'\n';
        }
        return 0;
        
    }
    for(int i=0; i<1000 && a==-1; i++){
        for(int j=0; j<1000; j++){
            if(7*i+4*j==n){
                a=i;
                b=j;
                break;
            }
        }
    }
    
    if(a!=-1){
        //cout<<a<<' ';
        vector<string> vs7={"abb...x","a.c...x","ddc...y","...abby","...a.cz","...ddcz","xxyyzz."};
        vector<string> vs4={"aacd","bbcd","cdaa","cdbb"};
        vector<string> ans(n,string(n,'.'));
        int pos=0;
        
        while(pos<b*4){
            for(int i=0; i<4; i++){
                for(int j=0; j<4; j++){
                    ans[pos+i][pos+j]=vs4[i%4][j];
                }
            }
            pos+=4;
        }
        while(pos<b*4+a*7){
            for(int i=0; i<7; i++){
                for(int j=0; j<7; j++){
                    ans[pos+i][pos+j]=vs7[i%7][j];
                }
            }
            pos+=7;
        }
        
        
        for(auto s:ans){
            cout<<s<<'\n';
        }
        return 0;
        
    }
    
    
    
    cout<<-1;
    
    
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 110;
int n, k;
int plan[MAX_N];
int memo[4][4][MAX_N];
int dfs(int a, int b, int depth)
{
    if(memo[a][b][depth]) return memo[a][b][depth];
    if(depth > n) return 1;
    int res = 0;
    if(plan[depth])
    {
        if(not(a == b && b == plan[depth])) res += dfs(b, plan[depth], depth + 1);
    }
    else
    {
        for(int c = 1; c <= 3; c++)
        {
            if(a == b && b == c) continue;
            res += dfs(b, c, depth + 1);
        }
    }
    return memo[a][b][depth] = res % 10000;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    memset(memo, 0, sizeof(memo));
    for(int i = 0; i < k; i++)
    {
        int a, b; cin >> a >> b;
        plan[a] = b;
    }
    cout << dfs(0, 0, 1) % 10000 << endl;
    return 0;
}




Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
int a[1007];
int main() {
	int n,k;
	cin>>n>>k;
	int m=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<k;i++){
		m+=a[i];
	}
	cout<<m;
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
signed main()
{
	cin>>a>>b>>c>>d;
	if(c/b+(c%b!=0)<=a/d+(a%d!=0))
	puts("Yes");
	else
	puts("No");
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <ctime>
#include <numeric>
#include <cstdlib>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
string S[11234];

int ans = 0;
int ctrB = 0;
int ctrA = 0;
bool STR = false;
bool END = false;
int ctr = 0;


int main(){
	
	cin>>N;
	REP( i, N ) cin>>S[i];
	
	REP( i, N ){
		REP( j, S[i].size()-1 ){
			if( S[i][j] == 'A' && S[i][j+1] == 'B' ) ans++;
		}
	}
	
	REP( i, N ){
		if( S[i][0] == 'B'){
			ctrB++;
			if( S[i][S[i].size()-1] != 'A' ) END = true;
		}
	}
	REP( i, N ){
		if( S[i][S[i].size()-1] == 'A' ){
			ctrA++;
			if( S[i][0] != 'B' ) STR = true;
		}
	}
	
	REP( i, N ){
		if( S[i][S[i].size()-1] != 'A' && S[i][0] != 'B' ) ctr++;
	}
	
	
	
	if( !STR && ctr < 2 ){
		ctrB--;
		ctr--;
		STR = true;
	}
	if( !END && ctr == 0 ) ctrA--;
	
	if( !END && !STR ) ctrA--;
	
	/*
	if( STR ) puts("STR");
	if( END ) puts("END");
	cout<<ans<<endl;
	cout<<ctrA<<" "<<ctrB<<" "<<ctr<<endl;
	//*/
	
	ans += max( 0, min( ctrB, ctrA ) );
	cout<<ans<<endl;
	
	return 0;
	
}

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

int main() {
	int w, h, x, y, r,up,right,down,left;
	cin >> w >> h >> x >> y >> r;

	left = x - r;
	right = x + r;
	up = y + r;
	down = y - r;

	if (left < 0) {
		cout << "No" << endl;
	}
	else if(right > w) {
		cout << "No" << endl;
	}
	else if (up > h) {
		cout << "No" << endl;
	}
	else if (down < 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int n,A,B,C;
vector<int> l(8);
int dfs(int depth,int a,int b,int c){
    if(depth == n){
        if(min(a,min(b,c))>0){
            return abs(a-A) + abs(b-B) + abs(c-C) - 30;
        }else{
            return 1e9;
        }
    }
    int ret0 = dfs(depth+1,a,b,c);
    int ret1 = dfs(depth+1,a+l[depth],b,c) + 10;
    int ret2 = dfs(depth+1,a,b+l[depth],c) + 10;
    int ret3 = dfs(depth+1,a,b,c+l[depth]) + 10;
    return min(ret0,min(ret1,min(ret2,ret3)));
}
int main(){
    cin >> n >> A >> B >> C;
    rep(i,n) cin >> l[i];
    cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //input
    ll n;
    cin >> n;
    vector<ll>a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    reverse(b.begin(),b.end());
    vector<ll>same,dif;
    ll h;
    rep(i,n){
        if(a[i]==b[i])h=a[i];
    }
    rep(i,n){
        if(a[i]==b[i])same.push_back(i);
        if(a[i]!=h&&b[i]!=h) dif.push_back(i);
    }
    if(same.size()>dif.size()){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    rep(i,same.size()){
        swap(b[same[i]],b[dif[i]]);
    }
    rep(i,n-1){
        cout << b[i] << ' ';
    }
    cout << b[n-1] << endl;
    return 0;
}


Measured memory_bytes: 9492
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int cnt =0;
        
        cnt += (x/500)*1000;
        x = x-(x/500)*500;

        cnt+= (x/5)*5;
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21204
# ABC090 B - Palindromic Numbers
a,b = map(int,input().split())

ans = 0
for i in range(a,b+1):
    s = ''
    s = str(i)
    if s[0:1]==s[4:5] and s[1:2]==s[3:4]:
        ans += 1
print(ans)

Measured memory_bytes: 3060
// #define _GLIBCXX_DEBUG // for STL debug (optional)

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
void dump_func() { cerr << endl; }
template <class Head, class... Tail>
void dump_func(Head &&h, Tail &&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
#define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
typedef long long ll;

int main()
{
	string s;
	cin >> s;
	if (s[s.size() - 1] == 's')
	{
		cout << s << "es" << endl;
	}
	else
	{
		cout << s << "s" << endl;
	}
}


Measured memory_bytes: 3624
package main

import (
	"fmt"
)

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

	var ans, prob float64
	ans = 0

	for i := 1; i <= n; i++ {
		prob = 1.0 / float64(n)
		now := i
		for now < k {
			now *= 2
			prob /= 2
		}
		ans += prob
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<string>

using namespace std;

int main(){
  int n, m, suma, max_a;
  cin >> n;
  priority_queue<int> a;
  for(int i=0;i<n;i++){
    cin >> m;
 	a.push(m);
    suma += m; 
  }
  max_a = a.top();
  string result = "No";
  if (max_a < suma -max_a){
    result = "Yes";
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define alll(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define endl '\n'

struct node {
    int mx1=0,mx2=0;
    void insert(int x) {
        if(x>mx1) mx2=mx1,mx1=x;
        else if(x>mx2) mx2=x;
    }
    void insert(node x) {
        insert(x.mx1);
        insert(x.mx2);
    }
}a[1<<18];
int ans[1<<18];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<1<<n;++i) cin>>a[i].mx1;
    for(int i=0;i<n;++i)
        for(int j=0;j<1<<n;++j)
            if(!(j&(1<<i))) a[j^(1<<i)].insert(a[j]);
    for(int i=1;i<1<<n;++i) ans[i]=a[i].mx1+a[i].mx2;
    for(int i=1;i<1<<n;++i) ans[i]=max(ans[i],ans[i-1]);
    for(int i=1;i<1<<n;++i) cout<<ans[i]<<endl;
}


Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

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

	long long ans = 1;
	while (ans*ans <= N) ans++;
	ans--;
	cout << ans*ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,s[101],d,f[101],g,i,j;
	for(i=1;i<=100;i++){
		f[i]=i;
		//printf("%d\n",f[i]);
	}
	for(i=1;i<=100;i++){
		s[i]=0;
	}
	while(scanf("%d",&a)!=EOF){
		s[a]++;
	}
	for(i=1;i<=100;i++){
		for(j=i+1;j<=100;j++){
			if(s[i]<s[j]){
				d=f[i];
				f[i]=f[j];
				f[j]=d;
				d=s[i];
				s[i]=s[j];
				s[j]=d;
			}
		}
	}
	printf("%d\n",f[1]);
	for(i=2;i<=100;i++){
		if(s[1]==s[i]){
			printf("%d\n",f[i]);
		}
		if(s[1]<s[i]){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static int[] a = new int[3];

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = sc.nextIntArray(n);
		
		int min = Integer.MAX_VALUE;
		
		Arrays.sort(h);
		
		for(int i = k-1; i < n; i++) {
			min = Math.min(min, h[i]-h[i-(k-1)]);
		}
		
		out.println(min);
	}
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 36316
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 10000;
int N;
int a[MAX_N];

int main() {
  cin >> N;
  rep(i,N) cin >> a[i];

  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    int tmp = 0;
    while (a[i]%2 == 0) {
      ++tmp;
      a[i] /= 2;
    }
    ans += tmp;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256