akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,x,k,K,i;
    cin>>n>>K;
    vector<int> v;
    vector<int> dp(n);
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    dp[0]=0;
    dp[1]=abs(v[0]-v[1]);
    x=INT_MAX;
    for(int i=2;i<n;i++)
    {
        x=INT_MAX;
        for(k=1;k<=K;k++)
        {
        	if(i-k>=0)
        	{
        		x=min(x,dp[i-k]+abs(v[i-k]-v[i]));
        	}
        }
        dp[i]=x;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1276
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;



class Program
{
    public const int INF = 1 << 25;

    static void Main()
    {
		string[] input = Console.ReadLine().Split(' ');
		double a = double.Parse(input[0]);
		double b = double.Parse(input[1]);
		a *= b;
		Console.WriteLine("{0}", a / 3.305785);
    }
}

Measured memory_bytes: 5776
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
#define ll long long

void solve_B(){
    string s;
    cin >> s;

    int n = s.size();
    int ans = 10000;
    for(int i = 0; i < n-2; i++){
        int x = 100 * (s[i] - '0') + 10 * (s[i+1] - '0') + (s[i+2] - '0');
        int sa = fabs(x - 753);
        ans = min(ans, sa);
    }

    cout << ans << endl;
}

int main(void){
    solve_B();
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

	count := 0
	i := min(a, b)
	for {
		if a%i == 0 && b%i == 0 {
			count++
		}
		if count == k {
			fmt.Println(i)
			return
		}
		i--
	}
}


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

using namespace std;

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

    if(N>=M){
        cout << "0" << endl;
        return 0;
    }

    vector<int> x(M);
    
    for(int i=0; i<M; i++){
        cin >> x.at(i);
    }

    sort(x.begin(),x.end());

    vector<int> L(M-1);

    for(int i=0; i<M-1; i++){
        L.at(i) = x.at(i+1) - x.at(i);
    }
    
    sort(L.begin(),L.end());

    int ans =0;
    for(int i=0; i<M-N; i++){
        ans += L.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3972
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

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

	int n; cin >> n;
	vector<ll> a(n);
	rep(i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());

	vector<ll> s(n + 1), t(n + 1);
	rep(i, 0, n) s[i + 1] = s[i] + a[i];

	rep(i, 0, n - 1) {
		if (s[i + 1] * 2 < a[i + 1]) t[i + 1] = 0;
		else t[i + 1] = t[i] + 1;
	}
	cout << t[n - 1] + 1 << endl;
	return 0;
}


Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll N = 1e3+9;
const ll MOD = 1e9+7;

ll n;

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for(int i = 2; i * i <= n; i++) {
        while(n % i == 0)  res[i]++, n /= i;
    }
    if(n != 1)  res[n]++;
    return res;
}

int main() {
    cin >> n;

    map<ll, ll> pf;
    for(int num = 1; num <= n; num++) {
        map<ll, ll> pfn = prime_factor(num);
        for(auto x : pfn)  pf[x.first] += x.second;
    }

    ll ans = 1;
    for(auto x : pf) {
        ans *= x.second + 1;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	bool ans=true;
	set<string> a;
	ll n;
	cin>>n;
	char now;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		a.insert(s);
		char end=s[s.size()-1];
		if(i!=0){
			if(now!=s[0]){
				ans=false;
			}
		}
		now=end;
	}
	if(a.size()!=n){
		ans=false;
	}
	cout << (ans?"Yes":"No");
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;

	vector < pair<long long int, long long int >> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;

	sort(a.begin(), a.end());

	long long now = 0, ans = 0;
	for (int i = 0; i < n; i++){
		now += a[i].second;
		ans += a[i].second*a[i].first;

		if (now > m){
			ans -= (now - m)*a[i].first;
			break;
		}
		else if (now == m)
			break;
	}
	cout << ans << endl;


	return 0;
}


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

int n,a;
vector<int> c, rui;

int f(int x){
    auto it = lower_bound(c.begin(), c.end(), x);
    int i = (int)(it - c.begin());
    return (n-i) + rui[i] / x;
}

signed main(){
    cin >> n;
    c.resize(n);
    REP(i,n){
        cin >> a;
        c[a-1]++;
    }
    sort(c.begin(), c.end());
    rui.resize(n+1);
    REP(i,n) rui[i+1] = rui[i] + c[i];

    int ans = n;
    REP(i,n){
        while(ans && f(ans) < i+1) ans--;
        cout << ans << "\n";
    }
}

Measured memory_bytes: 3200
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	h, w, k = tin()
	bl = [[1 if c == '#' else 0 for c in list(input())] for _ in range(h)]
	#print(bl)
	cc = 0
	for hhi in range(2**h - 
	1):
		for wwi in range(2**w -	1):
			n = 0
			for hi, l in enumerate(bl):
				if hhi & (2**hi) > 0:
					continue
				for wi, v in enumerate(l):
					if wwi & (2**wi) > 0:
						continue
					n += v
			if n == k:
				#pa((hhi, wwi))
				cc += 1
			
	return cc
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 9256
#include<iostream>
#include<map>
#include<tuple>
using namespace std;

typedef tuple<int,int,int> T;
map<T,int> memo;

int dp(int n, int k, int s) {
  if (s < k || n < 1 || s < 1) {
    return 0;
  } else if (k == 1 && s <= n) {
    return 1;
  } else if (memo.find(make_tuple(n, k, s)) != memo.end()) {
    return memo[make_tuple(n, k, s)];
  } else {
    int ans = dp(n - 1, k, s - k) + dp(n - 1, k - 1, s - k);
    memo[make_tuple(n, k, s)] = ans;
    return ans;
  }
}

int main() {
  int n, k, s;
  while (cin >> n >> k >> s && n) {
    cout << dp(n, k, s) << endl;
  }
}

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

typedef long long ll;

int main(){
    ll n, ans = 0;
    cin >> n;
    if (n % 2 == 0) {
        ll k = 5;
        while (n / k) {
            ans += n / (2 * k);
            k *= 5;
        }
    }
    cout << ans << endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
  int n;
  cin >> n;

  vector<vector<char>> s(n, vector<char>(10));
  rep(i, n){
    rep(j, 10) cin >> s.at(i).at(j);
  }

  rep(i, n) sort(s.at(i).begin(), s.at(i).end());

  //rep(j, 10) cout << s.at(0).at(j);

  sort(s.begin(), s.end());
  int64_t ans=0;
  int64_t pair = 1;

  rep(i, n-1) {
    if(s.at(i)==s.at(i+1)) pair++;
    else ans+=pair*(pair-1)/2, pair=1;
  }
  ans+=pair*(pair-1)/2;
  cout << ans;
  
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))

int maximum(int x,int y)
{
	if(x > y)
		return x;
	else
		return y;
}

int minimum(int x,int y)
{
	if(x < y)
		return x;
	else
		return y;
}


int main()
{
	int len[2];
	char** str = mem(char*,2);
	int max;
	int i,j;
	str[0] = mem(char,4001);
	str[1] = mem(char,4001);
	while(scanf("%s",str[0]) != EOF)
	{
		max = 0;
		scanf("%s",str[1]);
		len[0] = strlen(str[0]);
		len[1] = strlen(str[1]);
		if(len[0] > len[1]);
		{
			char* tmp = str[0];
			str[0] = str[1];
			str[1] = tmp;
			len[0] ^= len[1];
			len[1] ^= len[0];
			len[0] ^= len[1];
		}
		int match = 0;
		for(i = -len[0]+1;i < len[1];i++)
		{
			for (j = maximum(0,i); j < minimum(len[1],i+len[0]); j += 1)
			{
				if(str[0][j-i]==str[1][j])
				{
					match++;
					if(match > max)
					{
						max = match;
					}
				}
				else
				{
					match = 0;
				}
			}
			match = 0;
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 0
def main():
    N = int(input())
    A, B = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]

    cnt = [0]*3
    for p in P:
        if p <= A:
            cnt[0] += 1
        elif p <= B:
            cnt[1] += 1
        else:
            cnt[2] += 1

    print(min(cnt))


if __name__ == '__main__':
    main()


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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int n = scanner.nextInt();
        double ans = 0;
        for(int i = 0; i < n; i++) {
            ans += (1.0/ scanner.nextInt());
        }
        out.println(1/ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
int main(){
	int n=read(),m=read(),d=read();
	int ans=n-d;
	if(d>0) ans*=2;
	printf("%.10lf",1.0*ans/n/n*(m-1));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;
using Int = long long;

int main()
{
    int A, B, C, X;
    int count = 0;
    cin >> A >> B >> C >> X;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == X) count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define INF 1000000007

typedef long long int lli;

typedef struct
{
  int front;
  int rear;
  int data[MAX][3];
} queue;

queue que;

void initQueue(queue *p)
{
  p->front = p->rear = 0;
}

bool emptyQueue(queue *p)
{
  return p->front == p->rear;
}

bool fullQueue(queue *p)
{
  return (p->front - 1 == p->rear) || (p->front == 0 && p->rear == MAX - 1);
}

void queuePop(queue *p)
{
  if (emptyQueue(p))
  {
    printf("UnderFlow\n");
    exit(1);
  }
  else
  {
    p->front++;
    if (p->front == MAX)
      p->front = 0;
  }
}

void queuePush(queue *p, int x, int y, int d)
{
  if (fullQueue(p))
  {
    printf("OverFlow\n");
    exit(1);
  }
  else
  {
    p->data[p->rear][0] = x;
    p->data[p->rear][1] = y;
    p->data[p->rear][2] = d;
    p->rear++;
    if (p->rear == MAX)
      p->rear = 0;
  }
}


int main(void) {
  char s[22][22];
  int h, w;
  scanf("%d %d", &h, &w);
  rep(hi, 0, h) {
    scanf("%s", s[hi]);
  }

  int mx[4] = { 0, 1, 0, -1 };
  int my[4] = { 1, 0, -1, 0 };
  int ans = 0;
  rep(hi, 0, h) {
    rep(wi, 0, w) {
      if ( s[hi][wi] == '#' ) continue;
      int visited[21][21] = {0};
      initQueue(&que);
      visited[hi][wi] = 1;
      queuePush(&que, hi, wi, 0);
      while ( !emptyQueue(&que) ) {
        int x = que.data[que.front][0];
        int y = que.data[que.front][1];
        int d = que.data[que.front][2];
        queuePop(&que);
        ans = max(ans, d);
        rep(mi, 0, 4) {
          int nextX = x + mx[mi];
          int nextY = y + my[mi];
          if ( nextX < 0 || h <= nextX ) continue;
          if ( nextY < 0 || w <= nextY ) continue;
          if ( visited[nextX][nextY] )   continue;
          if ( s[nextX][nextY] == '#' )  continue;
          visited[nextX][nextY] = 1;
          queuePush(&que, nextX, nextY, d + 1);
        }
      }
    }
  }

  printf("%d\n", ans);
  return 0;
}


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

int n;
double x[100],y[100];

double distance(double p){
  double sum=0;
  for(int i=0;i<n;i++){
    double w=abs(x[i]-y[i]);
    sum += pow(w,p);
  }
  return pow(sum,1.0/p);
}

int main(){
  cout<<fixed<<setprecision(12);
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i<n;i++){
    cin>>y[i];
  }
  cout<< distance(1) <<endl;
  cout<< distance(2) <<endl;
  cout<< distance(3) <<endl;
  double mx=0;
  for(int i=0;i<n;i++){
    mx=max(mx, abs(x[i]-y[i]) );
  }
  cout<< mx <<endl;
  return 0;
}



Measured memory_bytes: 3436
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
dp0 = [0] * (n+11)
dp1 = [0] * (n+11)
dp2 = [0] * (n+11)
for i,ai in enumerate(A):
  dp2[i+11] = (max(dp0[i+7] + ai, dp1[i+8] + ai, dp2[i+9] + ai) if i >= 2 else 0)
  dp1[i+11] = (max(dp0[i+8] + ai, dp1[i+9] + ai) if i >= 1 else 0)
  dp0[i+11] = dp0[i+9] + ai 
if n % 2 == 0:
  print(max(dp0[n + 9], dp1[n + 10]))
else:
  print(max(dp0[n + 8], dp1[n + 9], dp2[n + 10]))

# debug
# print(dp0,dp1,dp2,sep="\n")




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

int main(){
  
  long int a,b,k,c;
  
  cin >> a >> b >> k;
  
  if(a < k){
    c = k-a;
    if(b < c){
      cout << 0 << " " << 0;
      return 0;
    }
    cout << 0 << " " << b-c;
  }
  
  else if(a >= k)
    cout << a-k << " " << b;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=210;
int MOD;
inline int add(register int a,register int b) {return a+=b,a>=MOD?a-MOD:a;}
inline int del(register int a,register int b) {return a-=b,a<0?a+MOD:a;}
inline int mul(register int a,register int b) {return 1LL*a*b%MOD;}
inline int quickpower(register int a,register int b)
{
	register int i,s;
	for(i=a,s=1;b;b>>=1,i=mul(i,i))
		if(b&1) s=mul(s,i);
	return s;
}
int fac[MAXN],facinv[MAXN];
int f[MAXN][MAXN][MAXN][2],g[MAXN][MAXN][MAXN],h[MAXN][MAXN][MAXN];
int n,m,k;
inline void init()
{
	fac[0]=1;
	for(register int i=1;i<=max(n,m);i++) fac[i]=mul(fac[i-1],i);
	facinv[max(n,m)]=quickpower(fac[max(n,m)],MOD-2);
	for(register int i=max(n,m)-1;~i;i--) facinv[i]=mul(facinv[i+1],i+1);
	return;
}
inline int C(register int a,register int b)
{
	return mul(fac[a],mul(facinv[b],facinv[a-b]));
}
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>m>>k>>MOD;
	init();
	for(register int c=1;c<=k;c++)
	{
		register int wn;
		for(register int i=0;i<=m;i++)
		{
			wn=mul(del(quickpower(c,m-i),quickpower(c-1,m-i)),quickpower(k-c+1,i));
			for(register int w=1,j=0;j<=n;j++,w=mul(w,wn)) g[c][i][j]=w;
		}
	}
	for(register int c=1;c<=k;c++)
	{
		register int wn;
		for(register int i=0;i<=n;i++)
		{
			wn=mul(del(quickpower(k-c+1,i),quickpower(k-c,i)),quickpower(c,n-i));
			for(register int w=1,j=0;j<=m;j++,w=mul(w,wn)) h[c][i][j]=w;
		}
	}
	f[0][0][0][0]=1;
	for(register int c=0;c<k;c++)
		for(register int i=0;i<=n;i++)
			for(register int j=0;j<=m;j++)
			{
				for(register int k=0;k<=n-i;k++) f[c][i+k][j][1]=add(f[c][i+k][j][1],mul(C(n-i,k),mul(f[c][i][j][0],g[c+1][j][k])));
				for(register int k=0;k<=m-j;k++) f[c+1][i][j+k][0]=add(f[c+1][i][j+k][0],mul(C(m-j,k),mul(f[c][i][j][1],h[c+1][i][k])));
			}
	cout<<f[k][n][m][0]<<endl;
	return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 2005;

/* ...o(^-^)o... */

int main(){
    lint x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<lint> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];

    sort(all(p), greater<lint>());
    sort(all(q), greater<lint>());
    sort(all(r), greater<lint>());

    vector<lint> s;
    rep(i, x) s.push_back(p[i]);
    rep(i, y) s.push_back(q[i]);

    sort(all(s), greater<lint>());

    lint ans = 0;
    rep(i, x+y) ans += s[i];
    int j = 0;
    while(r[j] > s[x+y-j-1]){
        ans += r[j] - s[x+y-j-1];
        j++;
        if(j == c || j == x+y) break;
    }

    out(ans);
}

Measured memory_bytes: 4724
#include <cstdint>
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <limits>
#include <array>

using i64t=int64_t;
using i64pt=std::pair<i64t,i64t>;

i64t solve(i64t n,i64t a,i64t b,i64t c,i64t d) {
  std::priority_queue<i64pt> q;
  q.push(std::make_pair(n,0));
  i64t prev=n+1,ans=std::numeric_limits<i64t>::max();
  const std::array<i64t,3> costs = { a,b,c };
  const std::array<i64t,3> divs = { 2,3,5 };
  const std::array<i64t,3> thrs = { (a-1)/d+1, (b-1)/d+1, (c-1)/d+1 };

  while ( !q.empty() ) {
    auto p=q.top();
    // std::cerr << "** " << p.first << ", " << p.second << ", " << ans << std::endl;
    q.pop();
    auto val=p.first;
    if ( val==prev )
      continue;
    prev=val;
    auto cost=p.second;
    for ( int i=0; i<3; i++ ) {
      auto div=divs[i];
      auto thr=thrs[i];
      if ( val<div ) {
        ans = std::min(ans,d*val-cost);
        continue;
      }
      auto costadd=costs[i];
      i64t x,y;
      x=val/div;
      y=val%div;
      if ( y==0 ) {
        if ( val-x < thr ) {
          ans = std::min(ans,d*val-cost);
        }
        else {
          auto costnew = cost-costadd;
          if ( -costnew < ans ) {
            q.push(std::make_pair(x,costnew));
          }
        }
      }
      else {
        if ( val-x+y < thr ) {
          ans = std::min(ans,d*val-cost);
        }
        else {
          auto costnew = cost-d*y-costadd;
          if ( -costnew < ans ) {
            q.push(std::make_pair(x,costnew));
          }
        }
        if ( val-(x+1)+(div-y) < thr ) {
          ans = std::min(ans,d*val-cost);
        }
        else {
          auto costnew = cost-d*(div-y)-costadd;
          if ( -costnew < ans ) {
            q.push(std::make_pair(x+1,costnew));
          }
        }
      }
    }
  }
  return ans;
}

int main(void) {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int t;
  std::cin >> t;
  for ( int i=0; i<t; i++ ) {
    i64t n,a,b,c,d;
    std::cin >> n >> a >> b >> c >> d;
    std::cout << solve(n,a,b,c,d) << std::endl;
  }
}


Measured memory_bytes: 3760
import math
a, b, h, m = map(int, input().split())
jishinnodo = 30 * h + 0.5 * m
bunshinnodo = m * 6
kakudo = abs(jishinnodo - bunshinnodo)
rad = math.radians(kakudo)
coskakudo = math.cos(rad)
shahennonijou = a ** 2 + b ** 2 - 2 * a * b * coskakudo
print(shahennonijou**0.5)

Measured memory_bytes: 9512
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    if(m < n)
        swap(n, m);

    long long ans = 0;
    if(n == 1){
        if(m == 1)
            ans = 1;
        else if(m > 2)
            ans = m - 2;
    }
    else if(n > 2){
        ans = (n - 2LL) * (m - 2LL);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	double a, b, x;
	cin >> a >> b >> x;
	if (x * 2.0 == a * a*b) {
		cout << fixed << setprecision(12) << (double)45 << endl;
	}
	else if (x * 2.0<a*a*b) {
		double X = 2.0 * x / (a*b);
		cout << fixed << setprecision(12) << 180.0*atan2(b,X)/M_PI << endl;
	}
	else {
		double X = 2.0 * (a*a*b - x) / (a * a);
		cout << fixed << setprecision(12) << 180.0*atan2(X,a)/M_PI << endl;
	}
	return 0;
}


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

vector<long long> ans;
vector<long double> snk;
long long now=1,k,countn=0;

int main(){
  long long i,j;
  cin >> k;
  for(i=0;i<=15;i++){
    for(j=0;j<=150;j++){
      ans.push_back((j+1)*now-1);
    }
    now*=10;
  }
  sort(ans.begin(),ans.end());
  for(i=0;i<ans.size();i++){
    long long nk=ans[i],nks=0;
    while(nk>0){
      nks+=nk%10;
      nk/=10;
    }
    snk.push_back((long double)ans[i]/nks);
  }
  /*for(i=1;i<1000;i++){
    if(ans[i]<100)cout << ans[i] <<"\t"<< snk[i] << endl;
    }*/
  for(i=1;i<ans.size();i++){
    if(ans[i]==ans[i-1])continue;
    for(j=i+1;j<ans.size();j++){
      if(snk[i]>snk[j])break;
      if(j==ans.size()-1){
	cout << ans[i] << endl;
	countn++;
	if(k==countn)break;
      }
    }
    if(k==countn)break;
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());

        int p = x-k+1;
        StringJoiner sj = new StringJoiner(" ");
        for(Integer i=p; i < x+k; i++){
            sj.add(i.toString());
        }
        System.out.println(sj.toString());

        sc.close();
    }
}

Measured memory_bytes: 24020
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
    arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
    for (auto& i : arr) {
        fill_all(i, v);
    }
}

int32_t K;
int64_t A[6000];
int64_t D[6000];

int main()
{

    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    int Q;
    in >> K >> Q;
    for (size_t i = 0; i < K; i++)
    {
        in >> A[i];
    }

    while(Q--)
    {
        int64_t N, x, M;
        in >> N >> x >> M;

        x %= M;
        for (size_t i = 0; i < K; i++)
        {
            D[i] = A[i]%M;
        }
        //if (N-1 <= K) {

        //    int64_t count = 0;
        //    for (size_t i = 0; i < N-1; i++)
        //    {
        //        //next == a[i+1]
        //        int64_t next = (x + D[i])%M;
        //        if (x < next) {
        //            ++count;
        //        }
        //        x = next;
        //    }
        //    out << count << '\n';

        //    continue;
        //}

        int64_t min_count = 0;
        for (size_t i = 0; i < K; i++)
        {
            if (D[i] == 0) {
                ++min_count;
            }
        }
        min_count *= ((N - 1) / K);
        int64_t Dsum = 0;
        for (size_t i = 0; i < K; i++)
        {
            Dsum += D[i];
        }
        auto a_nk = (x + Dsum * ((N - 1) / K));
        min_count += (a_nk / M);
        x = a_nk % M;

        int64_t count = 0;
        for (size_t i = 0, i_end = ((N - 1) % K); i < i_end; ++i)
        {
            //next == a[i+1]
            int64_t next = (x + D[i]) % M;
            if (x < next) {
                ++count;
            }
            x = next;
        }

        out << (((N - 1) / K) * K - min_count) + count << '\n';
    }


    return 0;
}
#endif


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,r,d;
    scanf("%d%d%d",&l,&r,&d);
    if(l%d==0)
      printf("%d\n",r/d-l/d+1);
    else
      printf("%d\n",r/d-l/d);
    return 0;
}


Measured memory_bytes: 3820
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	string s;
	cin>>s;
	multiset<char> ms;
	for(char c:s)ms.insert(c);
	bool even = true;
	for(char c:ms) {
		if(ms.count(c)!=2)even=false;
	}
	if(even)cout<<"Yes";
	else cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

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

	ll n,d;
	cin >> n >> d;
	ll ans = 0;
	d = d*d;
	while(n--){
		ll x,y;
		cin >> x >> y;
		if(x*x + y*y <= d) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; string s; cin >> n >> s;
    int ans = 0;
    for (int w = 1; w < n; w++) {
        int c = 0, a = 0;
        for (int i = 0, j = w; j < n; i++, j++)
            if (s[i] == s[j]) a = max(a, ++c);
            else c = 0;
        ans = max(ans, min(a, w));
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[]a=new int[n];
		int min=Integer.MAX_VALUE;
		int max=0;
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			if(min>a[i])min=a[i];
			if(max<a[i])max=a[i];
		}
		
		for(int i=0;i<n;i++){
		int A=a[i];
		int B=min;
		int r=a[i]%min;
		
		while(r!=0){
			A=B;
			B=r;
			r=A%B;
		}
		if(min>B)min=B;
		}
		
		if(max<k){
			System.out.println("IMPOSSIBLE");
			return;
		}
		
		for(int i=0;i<n;i++){
			if(a[i]==k){
				System.out.println("POSSIBLE");
				return;
			}
		}
		
		if(n==1){
			if(a[0]!=k){
				System.out.println("IMPOSSIBLE");
				return;
			}
		}
		
		boolean flag=false;
		
		for(int i=0;i<n;i++){
			if(a[i]%min!=0)flag=true;
		}
		
		if(min==1){
			System.out.println("POSSIBLE");
			return;
		}
		if(k%min==0){
			System.out.println("POSSIBLE");
			return;
		}
		
		if(flag){
			System.out.println("POSSIBLE");
		}else{
			System.out.println("IMPOSSIBLE");
		}
		
	}
}


Measured memory_bytes: 48752
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b)swap(a,b);
    if(b>c)swap(b,c);
    if(a>b)swap(a,b);
    cout<<a<<" "<<b<<" "<<c<<endl;
}




Measured memory_bytes: 3096
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k; cin>>n>>k;
	string s; cin>>s;
	s[k-1]+=32;
	cout<<s;
	
	return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)



function main(N)
    t = 'a':'z'
    if N <= 26
        return t[N]
    else
        if N % 26 == 0
            return main(N ÷ 26 - 1) * 'z'
        else    
            return main(N ÷ 26 ) * t[N % 26]
        end
    end
end

N = parseInt(readline())
println(main(N))

Measured memory_bytes: 173068
#include <stdio.h>
#include <limits.h>

int max(int a, int b){
	return a > b ? a : b;
}

int main(){
	int n;
	scanf("%d",&n);
	int w[n][3];
	int i;
	for(i = 0;i < n;i++){
		scanf("%d%d%d",&w[i][0],&w[i][1],&w[i][2]);
	}

	int c[n][3];
	c[0][0] = w[0][0];
	c[0][1] = w[0][1];
	c[0][2] = w[0][2];
	for(i = 1; i < n;i++){
		c[i][0] = w[i][0] + max(c[i-1][1],c[i-1][2]);
		c[i][1] = w[i][1] + max(c[i-1][0],c[i-1][2]);
		c[i][2] = w[i][2] + max(c[i-1][1],c[i-1][0]);
	}
	printf("%d\n",max(c[n-1][0],max(c[n-1][1],c[n-1][2])));
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, A, B, C, D;
  std::cin >>  N >> A >> B >> C >> D;
  for(int m=0;m<N;m++){
    if(C*(N-1-m)-D*m<=B-A&&B-A<=-C*m+D*(N-1-m)){
      std::cout << "YES" << '\n';
      return 0;
    }else if(m==N-1) std::cout << "NO" << '\n';
  }
  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void)
{
  int n, m, result = 0;
  
  scanf("%d %d", &n, &m);
  
  
  result += n * (n-1) / 2;
  result += m * (m-1) / 2;
  
  printf("%d\n", result);
  
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;


int main() {
	int N;
	cin >> N;
	if (N == 0) {
		cout << "0" << endl;
		return 0;
	}
	string Ans = "";
	while (abs(N) > 1) {
		if (N < 0 && N % 2 != 0) {
			int mod = N % (-2);
			Ans += to_string(mod)[1];
			N /= -2;
			N++;
		} else {
			int mod = N % (-2);
			Ans += to_string(mod);
			N /= -2;
		}
	}
	reverse(Ans.begin(), Ans.end());
	if (N == -1)Ans = "1" + Ans;
	cout << "1" + Ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k; cin >> n >> k;
  int h[100005];
  for(int i=0;i<n;++i) cin >> h[i];
  sort(h,h+n);
  int ans=1000000000;
  for(int i=0;i<=n-k;++i) ans = min(ans,h[i+k-1]-h[i]); 
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());

    int count = 0;
    int i = 0;
    while(1){
        int num = lower_bound(a.begin(),a.end(),a[i] + 1) - lower_bound(a.begin(),a.end(),a[i]);
        if(num <  a[i]) count += num;
        if(num >= a[i]) count += num - a[i];
        i += num;
        if(i == n) break;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin>>s;
  int L=s/100;
  int R=s%100;
  if(1<=L&&L<=12&&1<=R&&R<=12){
      cout<<"AMBIGUOUS"<<endl;
    }
    else if(1<=L&&L<=12){
    cout<<"MMYY"<<endl;
    }
  else if(1<=R&&R<=12){
    cout<<"YYMM"<<endl;
  }
  else{
    cout<<"NA"<<endl;
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,e=0,w=0;
  cin>>n;
  char c[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(c[i]=='E')
      e++;
    else
      w++;
  }
  int dp[n];
  if(c[0]=='E'){
    dp[0]=e-1;
  }else{
    dp[0]=e;
  }
  int m=dp[0];
  for(int i=1;i<n;i++){
    if(c[i]=='E'&&c[i-1]=='E'){
      dp[i]=dp[i-1]-1;
    }else if(c[i]=='E'&&c[i-1]=='W'){
      dp[i]=dp[i-1];
    }else if(c[i]=='W'&&c[i-1]=='E'){
      dp[i]=dp[i-1];
    }else{
      dp[i]=dp[i-1]+1;
    }
    m=min(m,dp[i]);
  }
  cout<<m;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n;
  long sum=0,sum2=0,a=0,count=0;
	cin >> n;
	vector<int> v(n);
	r(i,n) {
      cin >>v.at(i);
      v.at(i) -= i+1;
    }
  sort(v.begin(),v.end());
  if(n%2==0) a=(v.at(n/2)+v.at(n/2-1))/2;
    else a=v.at((n-1)/2);
  r(i,n) count+=abs(v.at(i) - a);
  cout << count << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>

template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  if(!v.empty()) {
    std::copy(v.begin(), v.end() - 1, std::ostream_iterator<T>(out, " "));
    out << v.back();
  } else {
    out << "";
  }
  return out;
}

int selection_sort(std::vector<int> &xs) {
  int len = xs.size();
  int cnt_swap = 0;

  for(int i = 0; i < len; ++i) {
    int minj = i;
    for(int j = i; j < len; ++j) {
      if(xs[j] < xs[minj])
        minj = j;
    }
    if(i != minj) {
      std::swap(xs[i], xs[minj]);
      cnt_swap++;
    }
  }

  return cnt_swap;
}

int main(void) {
  int n;
  std::cin >> n;

  std::vector<int> xs;
  int x;
  for(int i = 0; i < n; ++i) {
    std::cin >> x;
    xs.push_back(x);
  }

  int cnt = selection_sort(xs);

  std::cout << xs << std::endl;
  std::cout << cnt << std::endl;

  return 0;
}

Measured memory_bytes: 3152
function Main(input) {
    var S = input.trim();
    var count = 0;
    for(var i = 0; i < S.length; i++){
        if(S.charAt(i) == 'x'){
            count++;
        }
    }
    var output;
    if(count > 7){
        output = "NO";
    }
    else{
        output = "YES";
    }
    console.log(output);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s;
	cin>>s;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '?')s[i] = 'D';
	}
	cout<<s<<'\n';

	return 0;
}

Measured memory_bytes: 3784
#include<stdio.h>
int main(){
  int a,copy;
  scanf("%d",&a);
  int keta=1;
  copy = a;
  while(a>9){
    keta += 1;
    a = a/10;
  }
  int ans;
  if(keta==6){
    ans = 90909;
  }
  else if(keta==5){
    ans = 909;
    ans += (copy-10000+1);
  }
  else if(keta==4){
    ans = 909;
  }
  else if(keta==3){
    ans = 9;
    ans += (copy-100+1);
  }
  else if(keta==2){
    ans = 9;
  }
  else if(keta==1){
    ans = copy;
  }
  printf("%d",ans);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> A(N + 1);
  A[0] = 2;
  A[1] = 1;
  
  for (int i = 0; i < N - 1; i++) {
    A[i+2] = A[i] + A[i+1];
  }
  
  cout << A[N] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;

#define NMAX 31
typedef pair <int, int> PII;
typedef pair <int, PII> PIP;

bool P[NMAX][NMAX][NMAX][NMAX];
int w, h;

bool isValid( PII p )
{
    int x = p.second;
    int y = p.first;
    return ( x >= 0 && x < w ) && ( y >= 0 && y < h );
}

bool isGoal( PII p )
{
    return p.first == h-1 && p.second == w-1;
}

int main( void )
{
    while ( cin >> w >> h && w && h )
    {
        // input
        int np;
        memset( P, false, sizeof( P ) );
        for ( int i = 0; i + 1 < 2 * h; i++ )
        {
            for ( int j = 0; j < ( i % 2 == 0 ? w - 1 : w ); j++ )
            {
                cin >> np;
                if ( !np )
                {
                    if ( i % 2 == 0 )
                    {
                        P[i/2][j][i/2][j+1] = P[i/2][j+1][i/2][j] = true;
                    }
                    else
                    {
                        P[i/2+1][j][i/2][j] = P[i/2][j][i/2+1][j] = true;
                    }
                }
            }
        }

        int answer = 0;
        set <PII> V;
        queue <PIP> Q;
        PIP s( 0, PII( 0, 0 ) );
        int dx[4] = { 0, 0, 1, -1 };
        int dy[4] = { 1, -1, 0, 0 };
        Q.push( s );
        V.insert( s.second );
        while ( !Q.empty() )
        {
            PIP e = Q.front();
            Q.pop();

            if ( isGoal( e.second ) )
            {
                answer = e.first + 1;
                break;
            }

            int t = e.first + 1;
            for ( int i = 0; i < 4; i++ )
            {
                PII pos = e.second;
                pos.first += dy[i];
                pos.second += dx[i];
                if ( !isValid( pos ) ) continue;
                if ( !P[e.second.first][e.second.second][pos.first][pos.second] ) continue;
                PIP next( t, pos );
                if ( V.find( pos ) != V.end() ) continue;
                Q.push( next );
                V.insert( pos );
            }
        }

        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 1844
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    using Int = long long;
    
    const Int mod = 1000000007;
    
    int n, m;
    cin >> n >> m;
    
    vector<int> s(n), t(m);
    
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    
    vector<vector<Int>> dp(n + 1, vector<Int>(m + 1));
    
    for (int i = 0; i <= n; i++) {
        dp[i][0] = 1;
    }
    
    for (int i = 0; i <= m; i++) {
        dp[0][i] = 1;
    }
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            (dp[i][j] += dp[i][j - 1]) %= mod;
            (dp[i][j] += dp[i - 1][j]) %= mod;
            
            if (s[i - 1] != t[j - 1]) {
                (dp[i][j] += mod - dp[i-1][j-1]) %= mod;   
            }
        }
    }
    
    cout << dp[n][m] << endl;
}

Measured memory_bytes: 31616
#include<stdio.h>
int main(){
    int a, b ,c ;
    scanf("%d%d%d",&a,&b,&c);
    int sum = c  , i ;
    for(i = 0 ;i<10 ; i++){
        
        sum = sum*a - b ; 
        printf("%d\n",sum) ;
    }
    
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,p,a,b,x,y;
double d[31][31],t,uma[31],dp[1<<8][31];
main(){
  while(cin>>n>>m>>p>>a>>b,a){
    r(i,31)r(j,31)d[i][j]=1e9;
    a--;b--;
    r(i,n)cin>>uma[i];
    r(i,p){
      cin>>x>>y>>t;x--;y--;
      d[x][y]=t;
      d[y][x]=t;
    }
    r(i,1<<8)r(j,31)dp[i][j]=1e8;
    dp[(1<<n)-1][a]=0;
    for(int S=(1<<n)-1;S>=0;S--)r(v,m)r(i,n)if((S>>i)&1)r(j,m)
      if(d[v][j]>=0)dp[S-(1<<i)][j]=min(dp[S-(1<<i)][j],dp[S][v]+d[v][j]/uma[i]);
    double ans=1e9;
    r(i,1<<n)ans=min(ans,dp[i][b]);
    if(ans==1e8)cout<<"Impossible"<<endl;
    else printf("%.10f\n",ans);
  }
}

Measured memory_bytes: 3260
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

#define SZ(a) (int)(a).size()
using ll = long long;

int main() {
    cin.sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    printf("%lld\n", b + min(c, a + b + 1));
    return 0;
}


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

int main(){
    int x_h,x_at,y_h,y_at;
    int x_times,y_times;
    cin >> x_h >> x_at >> y_h >> y_at;
    x_times = (y_h + x_at - 1) / x_at;
    y_times = (x_h + y_at - 1) / y_at;
    if(x_times > y_times)cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

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

	int N, D;
	cin >> N >> D;
	D = 2 * D + 1;
	if (N % D == 0) {
		cout << N / D;
	}
	else cout << N / D + 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    LL N, M, D;
    cin >> N >> M >> D;
    LL cnt = N * (1 + (D != 0)) - D * 2;
    cout << fixed << setprecision(10) << 1. * cnt * (M - 1) / (N * N) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st=new StringTokenizer(br.readLine());
		int a=Integer.parseInt(st.nextToken());
		String op=st.nextToken();
		int b=Integer.parseInt(st.nextToken());
		int c=0;

		if(op.equals("+")) {
			c=a+b;
		}else if(op.equals("-")) {
			c=a-b;
		}else if(op.equals("*")) {
			c=a*b;
		}else if(op.equals("/")) {
			c=a/b;
		}

		while(!op.equals("?")) {
			System.out.println(c);

			StringTokenizer sa=new StringTokenizer(br.readLine());
			a=Integer.parseInt(sa.nextToken());
			op=sa.nextToken();
			b=Integer.parseInt(sa.nextToken());

			if(op.equals("+")) {
				c=a+b;
			}else if(op.equals("-")) {
				c=a-b;
			}else if(op.equals("*")) {
				c=a*b;
			}else if(op.equals("/")) {
				c=a/b;
			}

		}

	}

}



Measured memory_bytes: 24188
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int main() {
	ull a,b,k;
  cin>>a>>b>>k;
  if(a>=k) a-=k;
  else {
  	k-=a; a=0;
    if(b>=k) b-=k; 
    else b=0;
  }
  cout<<a<<" "<<b;
}


Measured memory_bytes: 256
N=int(input())
sp=[]
for i in range(N):
    s,p=map(str,input().split())
    sp.append([s,int(p),i+1])
sp.sort(key=lambda x:x[1],reverse=True)
sp.sort(key=lambda x:x[0])
for e in sp:
    print(e[2])

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    int n;
    cin>>n;
    vector<int>h(n);
    int mx = 0,count = 0;
    cin>>h[0];
    for(int i = 1;i < n;i++)
    {
        cin>>h[i];
        if(h[i] <=  h[i-1])
        {
            count++;
            if(mx < count)mx = count;
        }
        else 
        {
            count = 0;
        }
    }

    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 640