akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define INF 2000000000
#define ull unsigned long long


int main(){
    int c[3][3]={},i,j,r[4][3]={};
    for (i=0; i<3; i++) {
        for (j=0; j<3; j++) {
            scanf("%d",&c[i][j]);
        }
    }
    r[0][0]=c[0][0]-c[1][0];
    r[0][1]=c[0][1]-c[1][1];
    r[0][2]=c[0][2]-c[1][2];
    r[1][0]=c[1][0]-c[2][0];
    r[1][1]=c[1][1]-c[2][1];
    r[1][2]=c[1][2]-c[2][2];
    r[2][0]=c[0][0]-c[0][1];
    r[2][1]=c[1][0]-c[1][1];
    r[2][2]=c[2][0]-c[2][1];
    r[3][0]=c[0][1]-c[0][2];
    r[3][1]=c[1][1]-c[1][2];
    r[3][2]=c[2][1]-c[2][2];
    for (i=0; i<4; i++) {
        for (j=0; j<2; j++) {
            if (r[i][j]!=r[i][j+1]) {
                printf("No");
                return 0;
            }
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>

int main(){
  char str1[101] = {};
  char str2[101] = {};
  int i,num=0;
  int loopnum;
  
  if(scanf("%s",str1)<1)
    exit(1);
  
  strcpy(str2,str1);
  if(strlen(str1) % 2 == 0)
    loopnum = strlen(str1)/2;
  else
    loopnum = strlen(str1)/2 + 1;
  
  for(i = 0; i < loopnum; i++){
    if(str1[i] != str2[strlen(str1) - 1 - i]){
      num++;
    }
  }
  
  printf("%d",num);
  
  return 0;
}

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

using namespace std;

void solve(int n)
{
    if(n==2||n==4||n==5||n==7||n==9)
    {
        cout<<"hon";
    }
    else if(n==3)
    cout<<"bon";
    else 
    cout<<"pon";
}

int main()
{
   int n;
   cin>>n;
   if(n<10)
   {
       solve(n);
   }
   else
   {
       n = n%10;
       solve(n);
   }
   
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		String str = sc.next();
      	str = str.replace("0","");
		// 出力
		System.out.println(str.length());
	}
}

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define pmod 1000000007
#define maxn 100005
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
ll a[1005];
bool c[8000000];


void prime(long long m, ll n){

    ll j=0,num;
    //FOR (i,0,m-1) c[i]=0;

    while (j<=n){
    if (c[m]==0){
    for(ll i=1; i*m<=7368792;i++){
        c[i*m]=1;
    }
    j++;
    //cout<<m<<" ";
    }
    //cout<<c[m]<<" ";

    m++;

    }
    cout<<m-1<<endl;


}

int main()
{ll m=1;ll n;
while (1){
    memset(c,0,sizeof(c));
    cin>>m>>n;
    if (m==0) return 0;

    prime(m,n);


}

         return 0;
}

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

#define mod 1000000007
#define ll long long

ll bow(ll x, ll y) {
  ll res = 1;
  for (ll i = 1; i <= y; ++i) {
    res = res * x % mod;
  }
  return res;
}

void solve() {
  ll n;
  cin >> n;
  ll ans = bow(10, n) - bow(9, n) - bow(9, n) + bow(8, n);
  ans %= mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


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

using namespace std;

int A, B, N, M, a[109][109];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &A, &B), N = M = 100;
A --, B --;
for (int j=1; j<=M; j++)
    a[N / 2][j] = 1;
for (int i=1; i<N / 2; i++)
    for (int j=1; j<=M; j++)
        if (j % 2 == 0 || i % 2 == 0) a[i][j] = 1;
        else
        if (A == 0) a[i][j] = 1;
        else A --, a[i][j] = 0;
for (int j=1; j<=M; j++)
    a[N / 2 + 1][j] = 0;
for (int i=N / 2 + 2; i<=N; i++)
    for (int j=1; j<=M; j++)
        if (j % 2 == 0 || i % 2 == 0) a[i][j] = 0;
        else
        if (B == 0) a[i][j] = 0;
        else B --, a[i][j] = 1;
printf ("%d %d\n", N, M);
for (int i=1; i<=N; i++, printf ("\n"))
    for (int j=1; j<=M; j++)
        if (a[i][j]) printf ("#");
        else printf (".");
return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
#define int long long
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<n; i++)
#define all(v)  v.begin(),v.end()
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00%jousu(10,y00)) / jousu(10, y00-1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}


int f(int x) {
	return x * (x + 1) / 2;
}
signed main() {
	int a = 1, b1, b2, t = 0;
	string s;
	char c;
	vector<int>vec;
	cin >> s;
	c = s[0];
	for (int i = 1; i < s.size(); i++) {
		if (c == s[i]) {
			a++;
		}
		else {
			vec.push_back(a);
			a = 1;
			c = s[i];
		}
	}
	vec.push_back(a);
	if (s[0] == '<') {
		if (s[s.size() - 1] == '>') {
			for (int i = 0; i < (int)vec.size() - 1; i += 2) {
				b1 = min(vec[i], vec[i + 1]);
				b2 = max(vec[i], vec[i + 1]);
				t += (f(b1 - 1) + f(b2));
			}
		}
		else {
			for (int i = 0; i < (int)vec.size() - 1; i += 2) {
				b1 = min(vec[i], vec[i + 1]);
				b2 = max(vec[i], vec[i + 1]);
				t += (f(b1 - 1) + f(b2));
			}
			t += f(vec[vec.size() - 1]);
		}
	}
	if (s[0] == '>') {
		if (s[s.size() - 1] == '>') {
			for (int i = 1; i < (int)vec.size() - 1; i += 2) {
				b1 = min(vec[i], vec[i + 1]);
				b2 = max(vec[i], vec[i + 1]);
				t += (f(b1 - 1) + f(b2));
			}
			t += f(vec[0]);
		}
		else {
			for (int i = 1; i < (int)vec.size() - 1; i += 2) {
				b1 = min(vec[i], vec[i + 1]);
				b2 = max(vec[i], vec[i + 1]);
				t += (f(b1 - 1) + f(b2));
			}
			t += f(vec[0]);
			t += f(vec[vec.size() - 1]);
		}
	}
	cout << t << endl;
}


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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int n, a, b, c, d;
bool ym = 1, my = 1;

int main() {
	read(n);
	d = n % 10, n /= 10;
	c = n % 10, n /= 10;
	b = n % 10, n /= 10;
	a = n % 10;
	if (a * 10 + b > 12 || a * 10 + b == 0) my = 0;
	if (c * 10 + d > 12 || c * 10 + d == 0) ym = 0;
	if (my && ym) puts("AMBIGUOUS");
	else if (!my && !ym) puts("NA");
	else if (my && !ym) puts("MMYY");
	else puts("YYMM");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (b <= 9)b += a * 10;
	else if (b <= 99)b += a * 100;
	else b += a * 1000;
	bool f = false;
	for (int i = 0; i < 1000; i++)if (i*i == b)f = true;
	printf((f) ? "Yes\n" : "No\n");
}

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


int d(int x){
  int total = 0;
  for(int i = 1; i <= x; i++){
    if(x % i == 0) total++;
  }
  return total;
}


int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(i % 2 == 0) continue;
    if(d(i) == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = 0
out = 0

for i in range(1, n+1):
  for j in range(b, n):
    if i == a[j]:
      out += j-b
      b = j+1
      break
  else:
    out += n-b
    break

if out == n:
  out = -1

print(out)

Measured memory_bytes: 24744
a,b,x=map(int,input().split())
x=min(b-a,x)
if x==0:
    print(a)
    exit()
for i in range(x):
    print(a)
    a+=1
x=max(a-1,b-x)
for i in range(x+1,b+1):
    print(i)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>

int main() {
    int a, b, c, x, y;
    scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);

    //先处理成对的棋盘
    int common = x;
    if (x > y) {
        common = y;
    }

    // common * (a + b)
    // common * c * 2
    int sum1 = common * c * 2;
    if (common * c * 2 > common * (a + b)) {
        sum1 = common * (a + b);
    }

    // 先处理剩下的棋盘
    int left = x - common;
    int price = a;
    if (x - common == 0) {
        left = y - common;
        price = b;
    }
    // left * price
    // left * 2 * c
    int sum2 = left * price;
    if (left * price > left * c * 2) {
        sum2 = left * c * 2;
    }
    printf("%d", sum1 + sum2);
    return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {


	int x,a,b;
	scanf("%d%d%d", &x,&a,&b);


	if (abs(x - a) > abs(x - b)) {
		printf("B");
	}
	else printf("A");

}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char input[14];
    char output[20];
    scanf("%s",input);
    int i;
    for(i=0;i<4;i++)
    {
        output[i]=input[i];
    }
    output[4]=' ';
    for(i=5;i<13;i++)
    {
        output[i]=input[i-1];
    }

    printf("%s\n",output);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long N, M;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> N >> M) {
        cout << ((N - M) * 100 + M * 1900) * (1LL<<M) << endl;
    }
}


















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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n)
    cin >> p[i];

    int cnt = 0;

    REP(i, n)
    {
        if (p[i] != i + 1)
            cnt++;
    }

    if (cnt == 2 || cnt == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int shihab;
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
 //   FI(); /// skip this line for compile
    int n,x=1;
    cin >> n;
    while(x<=n){
        x = x << 1;
    }
    cout << x/2 << endl;
    return 0;
    //code end
}
//okbye


Measured memory_bytes: 3616
#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> pii;

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

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

	ll a[3];
	rep(i, 3) cin >> a[i];

	ll b[3];
	rep(i, 3) cin >> b[i];

	ll dp[n+1];
	rep(i, 4) rep(j, n+1) dp[j] = 0;
	dp[0] = n;
	
	rep(i, 3){
		rep(j, n+1) {
			if(j-a[i] >= 0) chmax(dp[j], dp[j-a[i]] + b[i] - a[i]); 
		}
	}

	ll m = 0;
	rep(j, n+1) chmax(m, dp[j]);

	vector<ll> dp2(m+1, 0);
	dp2[0] = m;

	rep(i, 3){
		rep(j, m+1){
			if(j-b[i] >= 0) chmax(dp2[j], dp2[j-b[i]] + a[i] - b[i]);
		}
	}

	ll ans = 0;
	rep(j, m+1) chmax(ans, dp2[j]);
	cout << ans << endl;
}


Measured memory_bytes: 198412
//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <unordered_map>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int MAXN = 100000;
const int MOD = 1000000007;
const long long INFLL = 1000000000000000000LL;

long long v[1 + MAXN];
int dp[1 + MAXN][2], sum[1 + MAXN][2];

int main() {
    int n;
    long long a, b;
    cin >> n >> a >> b;
    v[0] = -INFLL;
    for (int i = 1; i <= n; i++)
        cin >> v[i];
    dp[1][0] = dp[1][1] = sum[1][0] = sum[1][1] = 1;
    int pointer0 = 0, pointer1 = 0, limit1 = 1, limit0 = 1, add0, add1;
    for (int i = 2; i <= n; i++) {
        while (pointer0 < i - 1 && v[i] - v[pointer0 + 1] >= a)
            pointer0++;
        if (pointer0 == i - 1)
            dp[i][0] = dp[i - 1][0];
        if (v[i - 1] - v[i - 2] < b)
            limit1 = i - 1;
        if (pointer0 == i - 1) {
            add0 = 1;
            pointer0--;
        }
        else
            add0 = 0;
        if (pointer0 + 1 >= limit1) {
            dp[i][0] += dp[pointer0 + 1][1];
            if (dp[i][0] >= MOD)
                dp[i][0] -= MOD;
           // dp[i][0] -= sum[limit1 - 1][1];
          //  if (dp[i][0] < 0)
                //dp[i][0] += MOD;
        }
        while (pointer1 < i - 1 && v[i] - v[pointer1 + 1] >= b)
            pointer1++;
        if (pointer1 == i - 1)
            dp[i][1] = dp[i - 1][1];
        if (v[i - 1] - v[i - 2] < a)
            limit0 = i - 1;
        if (pointer1 == i - 1) {
            add1 = 1;
            pointer1--;
        }
        else
            add1 = 0;
        if (pointer1 + 1 >= limit0) {
            dp[i][1] += dp[pointer1 + 1][0];
            if (dp[i][1] >= MOD)
                dp[i][1] -= MOD;
           // dp[i][1] -= sum[limit0 - 1][0];
          //  if (dp[i][1] < 0)
              //  dp[i][1] += MOD;
        }
        sum[i][0] = dp[i][0] + sum[i - 1][0];
        if (sum[i][0] >= MOD)
            sum[i][0] -= MOD;
        sum[i][1] = dp[i][1] + sum[i - 1][1];
        if (sum[i][1] >= MOD)
            sum[i][1] -= MOD;
        pointer0 += add0;
        pointer1 += add1;
    }
    int answer = dp[n][0] + dp[n][1];
    if (answer >= MOD)
        answer -= MOD;
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 2688
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: chars,
    }
    let (mut a, mut b) = (0,0);
    for c in S{
        if c=='0'{
            a += 1;
        }else{
            b += 1;
        }
    }
    println!("{}",min(a,b)*2);
}

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

template<typename T>
istream &operator >> (istream &istr, vector<T> &v){
    for(T &x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream &operator >> (istream &istr, pair<T,U> &p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream &operator << (ostream &ostr, vector<T> &v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream &operator << (ostream &ostr, pair<T,U> &p){
    // ostr << p.first << p.second;
    // ostr << p.first << ", " << p.second;
    ostr << "(" << p.first << ", " << p.second << ")";
    return ostr;
}

template<typename T>
ostream &operator << (ostream &ostr, vector<vector<T>> &vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream &operator << (ostream &ostr, vector<pair<T,U>> &vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]=make_pair(x,y); v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF ((ll)1e+12)
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T> &v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T> &v){sort(all(v));}
template<typename T> inline void rsort(vector<T> &v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T &a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T &a, T b){if(a<b) a=b;}

int main(){
    ll n;
    string s;
    cin >> n >> s;
    if(s.size() > n){
        REP(i,n) cout << s[i];
        cout << "..." << endl;
    }
    else{
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

struct SSS
{
	string str;
	int val;
	SSS(string s = "", int v = 0) :str(s), val(v){};
};

void print(vector<SSS> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i].str << " " << data[i].val << endl;
	}
}

vector<SSS> tmp;
void merge(vector<SSS> &data, int l, int m, int r){
	for (int i = l; i < r; ++i) tmp[i] = data[i];
	int p1(l), p2(m);
	while (p1 < m && p2 < r) {
		if (tmp[p1].val <= tmp[p2].val) data[l++] = tmp[p1++];
		else data[l++] = tmp[p2++];
	}
	while (p1 < m) data[l++] = tmp[p1++];
	while (p2 < r) data[l++] = tmp[p2++];
}

void mergeSort(vector<SSS> &data, int l, int r){
	if (l + 1 < r){
		int m = l + (r - l) / 2;
		mergeSort(data, l, m);
		mergeSort(data, m, r);
		merge(data, l, m, r);
	}
}




int partition1(vector<SSS> &data, int p, int r){
	int p1 = p - 1;
	int p2 = p;
	SSS v = data[r];

	while (p2 < r) {
		if (data[p2].val <= v.val)
			swap(data[++p1], data[p2]);
		p2++;
	}
	swap(data[++p1], data[r]);

	return p1;
}

int partition2(vector<SSS> &data, int l, int r){
	SSS tmp = data[r];
	while (l < r) {
		while (l < r && data[l].val <= tmp.val) l++;
		if (l >= r) break;
		data[r--] = data[l];

		while (l < r && data[r].val >= tmp.val) r--;
		if (l >= r) break;
		data[l++] = data[r];
	}
	data[r] = tmp;
	return r;
}

void quickSort(vector<SSS> &data, int l, int r){
	if (l < r){
		int pos = partition1(data, l, r);
		quickSort(data, l, pos - 1);
		quickSort(data, pos + 1, r);
	}
}



int main(){
	int n; cin >> n;
	vector<SSS> data(n);
	for (int i = 0; i < n; ++i){
		string str; int val;
		cin >> str >> val;
		data[i] = SSS(str, val);
	}
	vector<SSS> d1(data), d2(data);
	tmp.resize(data.size());
	mergeSort(d1, 0, d1.size());
	//print(d1);

	quickSort(d2, 0, d2.size() - 1);
	//print(d2);

	string str = "Stable";
	for (int i = 0; i < d1.size(); ++i) {
		if (d1[i].str != d2[i].str) str = "Not stable";
	}
	cout << str << endl;
	print(d2);
	return 0;
}

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

using namespace std;
int main()
{
    long long n,m;
    cin >> n;
    cin >> m;
    std::vector<long long> h(n,0);
    std::vector<long long> ab(n,0);
    long long buf;
    int i = 0;
    while(n>i){
        cin >> buf;
        h[i] = buf;
        i++;
    }
    long long a,b;
    i = 0;
    while(m>i){
        cin >> a;
        cin >> b;
        a = a-1;
        b = b-1;
        if(h[a]>h[b]){
            ab[b] = 1;
        }
        else if(h[b]>h[a]){
            ab[a] = 1;
        }
        else{
            ab[a] = 1;
            ab[b] = 1;
        }
        //cout << aa[i] << endl;
        i++;
    }
    i = 0;
    long long count = 0;
    while(ab.size()>i){
        if(ab[i]==0){
            count++;
            //cout << i+1 << endl;
        }
        i++;
    }
    cout << count;
}

Measured memory_bytes: 4772
#include<cstdio>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<iostream>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;

set<char> se={'A','T','C','G'};

char s[100005];
int ans[100005];

int main()
{
    int n,q;

    cin>>n>>q;

    scanf("%s",s);
    int len=n;
    int cnt=0;

    for(int i=0;i<len;++i)
    {
        if(i>0&&s[i]=='C'&&s[i-1]=='A')
            ++cnt;
        ans[i]=cnt;
    }

    //for(int i=0;i<len;++i)
        //cout<<i<<" "<<ans[i]<<endl;
    while(q--)
    {
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        cout<<ans[b]-ans[a]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 9999999999999999

struct Data{
	Data(int arg_to,ll arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
	int to;
	ll dist;
};

struct Info{
	bool operator<(const struct Info &arg) const{
		return from_1_dist < arg.from_1_dist;
	};
	int from,to;
	ll dist,from_1_dist;
};

struct State{
	State(int arg_park,ll arg_sum_dist){
		park = arg_park;
		sum_dist = arg_sum_dist;
	}
	bool operator<(const struct State &arg) const{
		return sum_dist > arg.sum_dist;
	};
	int park;
	ll sum_dist;
};

int main(){

	int N,M;
	ll C;

	scanf("%d %d %lld",&N,&M,&C);

	Info* info = (Info*)malloc(sizeof(Info)*M);
	ll* ruisekiwa = new ll[M];

	vector<Data> V[N+1];

	for(int i = 0; i < M; i++){
		scanf("%d %d %lld",&info[i].from,&info[i].to,&info[i].dist);
		V[info[i].from].push_back(Data(info[i].to,info[i].dist));
		V[info[i].to].push_back(Data(info[i].from,info[i].dist));
	}

	ll min_dist[N+1];

	min_dist[1] = 0;
	for(int i = 2; i <= N; i++)min_dist[i] = NUM;

	priority_queue<State> Q;

	for(int i = 0; i < V[1].size(); i++){
		if(min_dist[V[1][i].to] > V[1][i].dist){
			min_dist[V[1][i].to] = V[1][i].dist;
			Q.push(State(V[1][i].to,min_dist[V[1][i].to]));
		}
	}

	while(!Q.empty()){

		if(Q.top().sum_dist > min_dist[Q.top().park]){
			Q.pop();
		}else{

			for(int i = 0; i < V[Q.top().park].size(); i++){
				if(min_dist[V[Q.top().park][i].to] > Q.top().sum_dist + V[Q.top().park][i].dist){
					min_dist[V[Q.top().park][i].to] = Q.top().sum_dist + V[Q.top().park][i].dist;
					Q.push(State(V[Q.top().park][i].to,min_dist[V[Q.top().park][i].to]));
				}
			}
			Q.pop();
		}
	}

	for(int i = 0; i < M; i++){
		if(min_dist[info[i].from] > min_dist[info[i].to]){
			info[i].from_1_dist = min_dist[info[i].from];
		}else{
			info[i].from_1_dist = min_dist[info[i].to];
		}
	}

	sort(info,info+M);
	sort(min_dist+1,min_dist+1+N);

	ruisekiwa[0] = info[0].dist;

	for(int i = 1; i <= M-1; i++){
		ruisekiwa[i] = info[i].dist + ruisekiwa[i-1];
	}

	int* index_table = new int[N+1];


	int min_dist_index = 1,info_index = 0;

	while(min_dist_index <= N){
		while(info_index <= M-2 && info[info_index+1].from_1_dist <= min_dist[min_dist_index])info_index++;
		index_table[min_dist_index++] = info_index;
	}

	ll ans = ruisekiwa[M-1],tmp_cost;

	for(int i = 2; i <= N; i++){
		tmp_cost = C*min_dist[i];
		tmp_cost += ruisekiwa[M-1] - ruisekiwa[index_table[i]];
		ans = min(ans,tmp_cost);
	}

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 23868
#include <iostream>
#include <vector>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll c = a + b;
    if (n % c < a){
        cout << n / c * a + n % c << endl;
    }else{
        cout << n / c * a + a << endl;
    }
}



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

public class Main {
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int gems[] = new int[n]; 
		int cost[] = new int[n]; 
		
		int ans = 0; 
		for(int i = 0; i<n; i++) gems[i] = in.readInt();
		for(int i = 0; i<n; i++) cost[i] = in.readInt(); 
		for(int i = 0; i<n; i++) {
			if(gems[i] > cost[i]) ans += gems[i] - cost[i]; 
		}
		System.out.println(ans); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 21076
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    if(N == 3){
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }
    if(N == 4){
        cout << 2 << " " << 5 << " " << 20 << " " << 63 << endl;
        return 0;
    }
    if(N == 5){
        cout << 2 << " " << 3 << " " << 4 << " " << 6 << " " << 9 << endl;
        return 0;
    }
    vector<int> ans;
    repr(i,1,30001){
        if(i % 2 == 0 || i % 3 == 0){
            ans.push_back(i);
            if(ans.size() == N) break;
        }
    }
    ll sum = 0;
    rep(i,N){
        sum += ans[i];
    }
    if(sum % 6 == 2){
        repr(i,ans[N-1]+1,30001){
            if(i % 6 == 0){
                ans[4] = i;
                break;
            }
        }
    }
    if(sum % 6 == 3){
        repr(i,ans[N-1]+1,30001){
            if(i % 6 == 0){
                ans[5] = i;
                break;
            }
        }
    }
    if(sum % 6 == 5){
        repr(i,ans[N-1]+1,30001){
            if(i % 6 == 4){
                ans[5] = i;
                break;
            }
        }
    }
    rep(i,N) cout << ans[i] << " ";
    cout << endl;

}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define nitro ios_base::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
int main()
{
     nitro
     int a[6],i,j;
     for(i=0;i<6;i++) cin>>a[i];
     for(i=0;i<5;i++)
     {
         for(j=0;j<5;j++)
         {
             if(a[j]-a[i]>a[5])
             {
                 cout<<":(";
                 return 0;
             }
         }
     }     cout<<"Yay!";
     return 0;
}



Measured memory_bytes: 256
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define maxs 1000005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int l[2*maxs],r[2*maxs];
int n;

int arr[maxs];
int main()
{

    string s;
    cin>> s;
    if(s[2]==s[3] and s[4]==s[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i[114514];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=1,f=0;
  cin >>a;
  for(int n=0;n<a;n++) cin >>i[n];
  for(int n=1;n<a;n++){
    if(i[n-1]<i[n]) i[n]--;
    else if(i[n-1]>i[n]){
      d++;
      break;
    }
  }
  if(d==0) cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int h,w,cnt;
vector<int> dx={-1,0,1,0};
vector<int> dy={0,-1,0,1};
void bfs(vector<vector<char>>&mp,vector<vector<int>>&dis){
    queue<pair<int,int>>q;
    q.push(make_pair(0,0));
    dis.at(0).at(0)=0;
    while(q.size()){
        pair<int,int> tmp = q.front();
        q.pop(); 
        if(tmp.first==w&&tmp.second==h)
            break;
        for(int i=0;i<4;i++){
            int x = tmp.first + dx.at(i);
            int y = tmp.second + dy.at(i);
            if(0<=x&&0<=y&&x<=w&&y<=h&&mp.at(y).at(x)=='.'&&dis.at(y).at(x)==-1){
                dis.at(y).at(x) = dis.at(tmp.second).at(tmp.first)+1;
                q.push(make_pair(x,y));
            }
        }
    }
    cnt = dis.at(h).at(w);
}
int main(){
    int blk=0;
    cin >> h >> w;
    vector<vector<char>>mp(h,vector<char>(w));
    vector<vector<int>>dis(h,vector<int>(w,-1));
    --h;
    --w;
    for(int i=0;i<=h;i++)
        for(int j=0;j<=w;j++){
            cin >> mp.at(i).at(j);
            if(mp.at(i).at(j)=='#')
                blk++;
        }
    bfs(mp,dis);
    if(cnt!=-1)
        cout << (h+1)*(w+1)-blk-cnt-1 << endl;
    else
        cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 2e5 + 10;
const int M = 61;

int n;
int parent[N][M];

int32_t main(){_
      
   int steps;
   cin>>n>>steps;

   for (int i = 1; i <= n; ++i)
   {
      int x;
      cin >> x;
      parent[i][0] = x;
   }

   for (int bit = 1; bit < M; ++bit)
   {
      for (int i = 1; i <= n; ++i)
      {
         int first = parent[i][bit-1];
         int other = parent[first][bit-1];
         parent[i][bit] = other;
      }
   }
   
   int start = 1;
   for (int i = 0; i < M; ++i)
   {
      if (steps & (1LL << i)){
         start = parent[start][i];
      }
   }
   
   cout<<start;
   return 0;
}

Measured memory_bytes: 98912
import java.util.Scanner;

public class Main{
  
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    String[] tokens = scanner.nextLine().split(" +");
    
    long a = new Long(tokens[0]);
    long b = new Long(tokens[1]);
    long x = new Long(tokens[2]);
   
    if(a!=b){
      	if(a>0){
    		long n_lower = (a-1)/(x);
    		long n_upper = b/(x);
    		System.out.println(n_upper-n_lower);
        }
      	else{
          	System.out.println(1+b/(x));
        }
    }
    else{
      if(a%x == 0){
        System.out.println("1");
      }
      else{
        System.out.println("0");
      }
    }
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i,n) for(int i = 0 ; i < n ; ++i)

using namespace std;

struct CC{
	string L;
	double P, A, B, C, D, E, F, S, M;
	double ans;

	CC(string l, double p, double a, double b, double c, double d, double e, double f, double s, double m)
		: L(l),P(p), A(a), B(b), C(c), D(d), E(e), F(f), S(s), M(m){}
};


int main(){
	int n;

	while (1){
		vector<CC> arr;
		cin >> n;
		if (!n)break;

		REP(i, n){
			string l;
			double p, a, b, c, d, e, f, s, m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;

			arr.push_back(CC(l, p, a, b, c, d, e, f, s, m));
		}


		REP(i, n){
			CC& x = arr[i];
			x.ans = (x.S*x.F*x.M - x.P) / (x.A + x.B + x.C + (x.D + x.E)*x.M);
		}

		sort(arr.begin(), arr.end(),
			[](CC x, CC y)
		{if (x.ans == y.ans){
			return x.L < y.L;
		}
		else{
			return (x.ans > y.ans);
		}
		});
		

		REP(i, n){
				cout << arr[i].L << endl;
		}
		cout << "#" << endl;
	}
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int K;
    cin >> K;
    vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << vec[K - 1] << endl;
}



Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(void)
{
    int n,k;
    cin >>n >>k;

    double ans = 0;
    vector<vector<double> > dp(18, vector<double>(max(k,n)+1, 0));
    for(int i = 1; i <= n; i++){
        if(i >= k){
            ans +=  1/(double)n;
        }else{
            dp[0][i] = 1/(double)n;
        }

    }

    for(int i = 1; i < 18; i++){
        for(int j = 0; j < k; j++){
            if(dp[i-1][j] != 0){
                if(j*2 < k){
                    dp[i][j*2] += dp[i-1][j] * 0.5;
                }else{
                    ans += dp[i-1][j] * 0.5;
                }
            }
        }
    }


    printf("%.12lf\n", ans);
    return 0;
}

Measured memory_bytes: 15104
S = input()

def solve(S):
    buf = [1] * len(S)

    for i in range(len(buf) - 2):
        if S[i] == "R" and S[i+1] == "R":
            buf[i+2] += buf[i]
            buf[i] = 0

    for i in range(len(buf) - 1, 1, -1):
        if S[i] == "L" and S[i-1] == "L":
            buf[i-2] += buf[i]
            buf[i] = 0

    return " ".join(map(str, buf))

print(solve(S))

Measured memory_bytes: 17136
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;


int main() {
	ll n, x, t;
	cin >> n >> x >> t;

	cout << ((n - 1) / x + 1) * t << endl;

	return 0;
}


Measured memory_bytes: 3180
#include <iostream>
using namespace std;
#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
	int l,r,largest;
	l=2*i;
	r=2*i+1;
	
	if(l<=H&&A[l]>A[i]) largest = l;
	else largest = i;
	if(r<=H&&A[r]>A[largest]) largest=r;
	
	if(largest!=i){
		swap(A[i],A[largest]);
		maxHeapify(largest);
	}
}

int main() {
	
	cin>>H;
	for(int i=1;i<=H;i++) cin>>A[i];
	
	for(int i=H/2;i>=1;i--) maxHeapify(i);
	
	for(int i=1;i<=H;i++){
		cout<<" "<<A[i];
	}
	cout<<endl;
	
	return 0;
}

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

using namespace std;

void Main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    X -= Z;
    int ans = 0;
    while (X > 0) {
        if (X >= Y + Z) {
            X -= Y + Z;
            ++ans;
        }
        else {
            break;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, x, a[30]; bool dp[1000001], prime[1000001];
int main() {
	prime[0] = true, prime[2] = true;
	for(int i = 3; i <= 1000000; i += 2) prime[i] = true;
	for(int i = 3; i <= 1000; i++) {
		if(!prime[i]) continue;
		for(int j = i * i; j <= 1000000; j += i * 2) prime[j] = false;
	}
	while(scanf("%d%d", &n, &x), n) {
		for(int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n);
		for(int i = 0; i < x; i++) dp[i + 1] = false; dp[0] = true;
		for(int i = 1; i <= x; i++) {
			for(int j = 0; j < n && i >= a[j]; j++) {
				if(dp[i - a[j]]) {
					dp[i] = true; break;
				}
			}
		}
		for(int i = x; i >= 0; i--) {
			if(dp[i] && prime[i]) {
				printf(i ? "%d\n" : "NA\n", i); break;
			}
		}
	}
}

Measured memory_bytes: 4588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    string s;
    cin>>n>>s;
    for(i=0; i<s.size(); i++)
    {

        s[i]=s[i]+n;
        if(s[i]>90)
        {
            s[i]=s[i]-26;
        }
    }
cout<<s<<endl;







}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

kk = inputs[0][0]
xx = inputs[0][1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

pd kk
pd xx

left  = [-1000000, xx-(kk-1)].max
right = [1000000, xx+(kk-1)].min

for i in left..right
  print "#{i} "
end
print "\n"


Measured memory_bytes: 1788
import java.util.*;
public class Main
{

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
		}
		long dp[][]=new long[n+1][n+1];
		
		for(int i=n-1;i>=0;i--)
		{
			for(int j=i;j<n;j++)
			{
				if(j==i)
					dp[i][j]= a[i];
				else
				dp[i][j]=Math.max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
			}
		}
		
		System.out.println(dp[0][n-1]);
	}
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


/**
 * 整数の集合 A と、整数 X が与えられる。
 * Aの部分集合 S に対して関数f(S)をSの全要素をexorした値と定義する。
 * X ^ f(S) の最大値を返す
 */
ll maxSubsetExor(vector<ll> A, ll X) {


  const int N = A.size();
  const int M = 62;

  auto at = [&](const int i, const int j) -> int {
    return (A[i] >> (M-j-1) & 1);
  };


  int s = 0;
  REP(j, M) {

    int p = -1;
    for (int i = s; i < N; i++) if (at(i, j)) { p = i; break; }

    if (p != -1) {
      swap(A[s], A[p]);
      for (int i = s+1; i < N; i++) if (at(i, j)) A[i] ^= A[s];
      s++;
    }

  }

  ll ans = X;
  {
    int i = 0;
    REP(j, M) {
      if ((ans >> (M-1-j) & 1) == 0 && at(i, j)) {
        ans ^= A[i];
      }
      if (at(i, j)) {
        i++;
      }
    }
  }

  return ans;
}

int main2() {
  int N; cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];

  ll S = 0;
  REP(i, N) S ^= A[i];

  REP(i, N) A[i] &= ~S;

  ll P = maxSubsetExor(A, 0);
  ll Q = S ^ P;

  cout << P + Q << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin>>s;
    int ans=0;
    for (int i=0;i<s.length();i++){
        if (s[i]=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout<<ans;
}

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

int main() {
  int hug = 0;
  string S;
  cin >> S;
  for(int i = 0; i < S.size(); i++) {
    if (S[i] != S[S.size()-i-1]) {
      S[i] = S[S.size()-i-1];
      hug = hug + 1;
    }
  }
  cout << hug <<endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(true){
            int a = scan.nextInt();
            int b = scan.nextInt();
            if(a == 0 && b == 0) break;
            if(a < b) System.out.println(a + " " + b);
            else System.out.println(b + " " + a);
        }
    }
}

Measured memory_bytes: 27180
using System;

class Program
{
	static void Main()
	{
		var size = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var height = size[0];
		var width = size[1];
		Console.ReadLine();
		var colorCounts = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));

		var answer = new int[width + 2, height + 2];
		for (var y = 0; y < height; ++y) {
			for (var x = 0; x < width; ++x) {
				answer[x + 1, y + 1] = -1;
			}
		}

		var vectorX = 1;
		var vectorY = 0;
		var currentX = 1;
		var currentY = 1;
		for(var i = 0; i < colorCounts.Length; ++i) {
			for (var j = 0; j < colorCounts[i]; ++j) {
				answer[currentX, currentY] = i + 1;

				if (answer[currentX + vectorX, currentY + vectorY] != -1) {
					var newVectorX = vectorY * -1;
					vectorY = vectorX;
					vectorX = newVectorX;
				}

				currentX += vectorX;
				currentY += vectorY;
			}
		}

		for (var y = 0; y < height; ++y) {
			for (var x = 0; x < width; ++x) {
				Console.Write(answer[x + 1, y + 1]);
				if (x < width - 1) {
					Console.Write(" ");
				}
			}

			Console.WriteLine(string.Empty);
		}
	}
}


Measured memory_bytes: 11232