akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint n;
string s1,s2;

void solve(){
  cin >> n;
  cin >> s1 >> s2;
  int p=-1;
  llint ans=1;
  for(int i=0;i<n;i++){
    if(s1[i]==s2[i]){//縦積み
      if(p==-1)ans*=3;
      if(p==0)ans*=2;
      p=0;
    }
    else{//横積み
      if(p==-1)ans*=6;
      if(p==0)ans*=2;
      if(p==1)ans*=3;
      p=1;
      i++;
    }
    ans%=mod;
  }
  cout << ans << endl;
}

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


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

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P);

P dequeue(void);

int min(int, int);


int main(){
  int elaps=0,c;
  int i,q;
  P u;

  scanf("%d%d",&n, &q);
  for(i=1;i<=n;i++){
   scanf("%s",Q[i].name);
   scanf("%d",&Q[i].t);
 }


 head=1;
 tail=n+1;

 while(head!=tail){
   u=dequeue();
   c=min(q,u.t);
   u.t=u.t-c;
   elaps=elaps+c;
   if(u.t>0){
     enqueue(u);
   }
   else{
     printf("%s %d\n",u.name,elaps);
   }
 }

     return 0;
   }


   void enqueue(P x){
     Q[tail]=x;
     tail=(tail+1)%LEN;
   }

   P dequeue(void){
     P x;
     x=Q[head];
     head=(head+1)%LEN;
     return x;
   }


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



Measured memory_bytes: 11840
import java.util.*;

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

    int n = scan.nextInt();
    int k = scan.nextInt();
    if (n == 0) {
      	System.out.println(0);
    	return;
    }
    int[] h = new int[n];
    int[] dp = new int[n];

    for (int i = 0; i < n; i++) {
      h[i] = scan.nextInt();
    }

    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;
    scan.close();

	for (int i = 1; i < n; i++) {
      for (int j = 1; j <= k; j++) {
        if (i - j < 0) continue;
        int currentCost = Math.abs(h[i] - h[i-j]);
        dp[i] = Math.min(dp[i], dp[i - j] + currentCost);
      }
    }

    System.out.println(dp[dp.length - 1]);
  }
}

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

int main(){
    int N,H;cin>>N>>H;
    vector<pair<int,int>> info(N);
    rep(i,N)cin>>info.at(i).first>>info.at(i).second;
    sort(info.begin(),info.end(),greater<pair<int,int>>());
    int maxa=info[0].first;
    vector<int> thr;
    rep(i,N)if(info[i].second>maxa)thr.push_back(info[i].second);
    sort(thr.begin(),thr.end(),greater<int>());
    int i=0,count=0;
    while(H and i<thr.size()){
        H=max(0,H-thr[i]);
        count++;
        i++;
    }
    if(H)count+=(H+maxa-1)/maxa;
    cout<<count<<endl;
    return 0;
}

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


int main() {
  int num, s1, s2, s3, count;
  cin >> num;
  
  s1 = num / 100;
  s2 = num / 10 - s1*10;
  s3 = num - s1*100 - s2*10;
  count = 0;
    
  if (s1 == 1){
    count ++;
  }
   if (s2 == 1){
    count ++;
  } 
  if (s3 == 1){
    count ++;
  }
   cout << count << endl;
}
 


Measured memory_bytes: 256
import sys

A, B, C = map(int, raw_input().split())

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (B * i % A) != 0 and (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')


Measured memory_bytes: 2568
use std::io;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let a: i64 = iter.next().unwrap().parse().unwrap();
    let b: i64 = iter.next().unwrap().parse().unwrap();
    println!("{}", max(max(a + b, a - b), a * b));
}


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

int n, pos;  // nは木の数，posは位置情報
vector<int> pre, in, post;

void rec(int l, int r)
{
    // preで出てきた節点をmとする
    // この節点mに対してinで探索をすると，左部分木(mより前の木)と右部分木(mより後の木)がわかる
    if (l >= r) { // lがr以上の時探索ができないので終了
        return;
    }
    int root = pre[pos++];  // preで出てきた節点をmとする
    int m = distance(in.begin(), find(in.begin(), in.end(), root));  // inにおけるmの位置
    rec(l, m);  // そのnodeより左側を探索する．左側から探索
    rec(m + 1, r);  // 右側を探索．右側はあとで探索
    post.push_back(root);  // leafまで行けばもう探索できずpostの中に入る
}

void solve()
{
    pos = 0;
    rec(0, pre.size());  // postを復元する
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main()
{
    int k;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> k;
        pre.push_back(k);  // preorderで通ったnodeをpreに入れる
    }

    for (int i = 0; i < n; i++) {
        cin >> k;
        in.push_back(k);  // inorderで通ったnodeをinに入れる
    }

    solve();

    return 0;
}


Measured memory_bytes: 3160
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 kotonaru_num(a, b):
	if len(a) != len(b):
		return 1/0
	ret = 0
	for c, s in zip(a, b):
		if c != s:
			ret += 1
			
	return ret
 

def main():
	#a = int(input())
	#b , c = tin()
	s = input()	
	t = input()
	ret = mod
	for i in range(len(s) - len(t)+1):
		cc = s[i:i+len(t)]
		#pa(cc)
		tr = kotonaru_num(cc, t)
		ret = min(ret, tr)
	print(ret)
		
	
	
#+++++
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: 67408
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n;i++){
        cin >> a[i];   
    }
    int count = 0;
    for(int i = 0; i < n;i++){
        if (a[i] >= k) count++;
    }
    cout << count;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int K,S;
	scanf("%d",&K);
	scanf("%d",&S);
	int c = 0;
	for(int x=0;x<=K;x++){
		if(x>S) break;
		for(int y=0;y<=K;y++){
			if(S-x-y>=0 && S-x-y<=K) c++;
		}
	}
	printf("%d\n",c);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  
  n--;
  for(int k=0; k<=n; k++){
    ll r = a + d*k - c*(n-k);
    ll l = a + c*k - d*(n-k);

    if(l <= b && b <= r){
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


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

typedef long long int ll;
const ll MOD = 1000000007;

int bit[300010][61];

void binary(ll num, ll i){
    // ll ans = 0;
    for (ll j = 0; num>0 ; j++)
    {
        // ans = ans+(bina%2)*pow(10,i);
        bit[i][j] = num % 2;
        num = num/2;
    }
    // return ans;
}

ll bitmod(ll i){
    if(i==0){
        return 1;
    }
    ll a=1;
    for(ll j=0; j<i; j++){
        a = (a*2) % MOD;
    }
    return a;
}

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

    vector<ll> A(N);

    for(ll i=0; i<N; i++){
        cin >> A[i];
    }
    for(ll i=0; i<N; i++){
        for(ll j=0; j<61; j++){
            bit[i][j] = 0;
        }
    }
    for(ll i=0; i<N; i++){
        for(ll j=0; j<61; j++){
            binary(A[i], i);
        }
    }

    ll C[61];
    for(ll i=0; i<61; i++){
        C[i] = 0;
    }

    for(ll i=0; i<N; i++){
        for(ll j=0; j<61; j++){
            if(bit[i][j] == 1){
                C[j]++;
            }
        }
    }
    ll ans=0;
    for(ll i=0; i<61; i++){
        // ans += ((((C[i]) * ((N-C[i])) %MOD) * bitmod(i))) % MOD;
        ans += (((C[i]%MOD) * ((N-C[i])%MOD)) % MOD) * bitmod(i);
        // cout << i << ":" << C[i] << ":" << bitmod(i) << endl;
        // cout << ans << endl;
        ans = ans % MOD;
    }
    cout << ans % MOD << endl;
}


Measured memory_bytes: 74112
N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [False] * (K+1)
for i in range(1,K+1):
    for a in A:
        if i-a < 0: break
        if not dp[i-a]:
            dp[i] = True
print('First' if dp[-1] else 'Second')

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

int main() {
  int a;
  int b;
  int ave;
  int remainder;
  
  cin >> a >> b;
  
  ave = (a + b) / 2;
  remainder = (a + b) % 2;
  
  cout << ave + remainder << endl; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right; 
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;
Node root;

void insert(int);
Node find(Node,int);
void preprint();
void inprint();

int main(){
  int i, m, k, flag[10];
  char c[7];
  Node f;

  scanf("%d",&m);
  for(i = 0; i < m; i++){
    scanf("%s",c);
    if(c[0] == 'i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(c[0] == 'f'){
      scanf("%d",&k);
      f = find(root,k);
      if(f != NULL) printf("yes\n");
      else printf("no\n");
    }
    else if(c[0] == 'p'){
      inprint(root);
      printf("\n");
      preprint(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  Node x = root, y = NULL, z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

Node find(Node r, int k){
  while(r != NULL && k != r->key){
    if(k < r->key) r = r->left;
    else r = r->right;
  }
  return r;
}
  
void preprint(Node p){
  if(p != NULL){
    printf(" %d",p->key);
    if(p->left != NULL) preprint(p->left);
    if(p->right != NULL) preprint(p->right);
  }
}

void inprint(Node i){
  if(i != NULL){
    if(i->left != NULL) inprint(i->left);
    printf(" %d",i->key);
    if(i->right != NULL) inprint(i->right);
  }
}

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

int main() {
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for (int i=0; i<N; i++) {
    cin >> x[i];
  }
  for (int i=0; i<M; i++) {
    cin >> y[i];
  }
  int XMAX=X;
  int YMIN=Y;
  for (int i=0; i<N; i++) {
    X=max(X, x[i]);
  }
  for (int i=0; i<M; i++) {
    Y=min(Y, y[i]);
  }
  if (X<Y) {
    cout << "No War" << endl;
  }
  else {
    cout << "War" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int a,b;
    cin >> a >> b;
    if(b%a == 0) cout << a+b << endl;
    else cout << b-a << endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
int main(){
    map<string,int> a;
    int n;
    cin >> n;
    string s;
    for(int i=0;i<n;i++){
       cin >> s;
        if(a.find(s) == a.end())a[s] = 1;
        else a[s]++;
    }
    auto itr = a.begin();
    int ma = 0;
    int m=a.size();
    for(int i=0;i<m;i++){
        ma = max(ma,itr->second);
        itr=next(itr,1);
    }
    itr = a.begin();
    for(int i=0;i<m;i++){
        if(ma == itr->second)cout <<itr->first <<endl;
        itr=next(itr,1);
    }
    
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11


int main()
{
    ll n,w;
    cin >> n >> w;
    ll w0;
    vector<ll> v[4];
    rep(i,n){
        ll a,b; cin >> a >> b;
        if(i == 0) w0 = a;
        v[a-w0].push_back(b);
    }
    rep(i,4){
        sort(all(v[i]));
        reverse(all(v[i]));
    }
    ll ans = 0;
    for(int i = 0; i < v[0].size()+1 ; i++){
        for(int j = 0; j < v[1].size()+1; j++){
            for(int k = 0; k < v[2].size()+1; k++){
                for(int l = 0; l < v[3].size()+1; l++){
                    if(w0*i + (w0+1)*j + (w0+2)*k + (w0+3)*l <= w){
                        ll tmp = 0;
                        rep(m,i) tmp += v[0][m];
                        rep(m,j) tmp += v[1][m];
                        rep(m,k) tmp += v[2][m];
                        rep(m,l) tmp += v[3][m];
                        ans = max(ans,tmp);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def f(num):
    if num % 2:
        return 3*num+1
    else:
        return num // 2


ref = [int(input())]
cnt = 1

while True:
    cnt += 1
    dup = f(ref[-1])
    if dup in ref:
        print(cnt)
        exit(0)
    else:
        ref.append(dup)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int solve(int cur,int mul,int p,int q,int a,int n)
{
	if(p==0) return 1;
	if(n==0) return 0;
	int res=0;
	for(int i=cur;mul*i<=a;i++){
		int num=p*i-q,den=q*i;
		if(num>=0 && n-1>=0)
			res+=solve(i,mul*i,num,den,a,n-1);
	}
	return res;
}

int main()
{
	for(int p,q,a,n;cin>>p>>q>>a>>n,p|q|a|n;)
		cout<<solve(1,1,p,q,a,n)<<endl;
	
	return 0;
}

Measured memory_bytes: 0
N,x=map(int,input().split())
a=list(map(int,input().split()))
b=0
for i in range(N-1):
    if a[i]+a[i+1]>x:
        if a[i]<=x:
            b+=max(0,a[i+1]-x+a[i])
            a[i+1]=max(0,x-a[i])
        else:
            b+=a[i]-x+a[i+1]
            a[i+1]=0
            a[i]=x
b+=max(0,a[-2]+a[-1]-x)
print(b)

Measured memory_bytes: 14588
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define inf 1000000009
using namespace std;
vector<int> pat[1000009];
int deg[1000009],dis[1000009];
int conv(int x,int y){
	return max(x,y)+min(x,y)*1000;
}
int main(){
	ll n;
	ios::sync_with_stdio(false);
	cin>>n;
	vector<int> a[1001];
	for(int i=0;i<n;i++){
		for(int j=0;j<n-1;j++){
			int x;
			cin>>x;
			a[i].pb(x-1);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<n-1;j++){
			pat[ conv(i,a[i][j-1]) ].pb( conv(i,a[i][j]) );
			deg[ conv(i,a[i][j]) ] ++;
		}
	}
	queue<int> que;
	for(int i=0;i<1000000;i++){
		int first = i/1000;
		int second = i%1000;
		if( first<n && second<n && first<second && deg[i] == 0)que.push(i);
	}
	int cnt = 0;
	while(!que.empty()){
		int cur = que.front(); que.pop();
		cnt++;
		for(int i=0; i<pat[cur].size();i++){
			int d = pat[cur][i];
			dis[d] = max(dis[d], dis[cur]+1);
			deg[d]--;
			if(deg[d]==0)que.push(d);
		}
	}
	if(cnt < n*(n-1)/2)cout<<-1<<endl;
	else{
		int ans = 0;
		for(int i=0;i<1000000;i++){
			if(ans < dis[i])ans = dis[i];
		}
		cout<<ans+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 51200
#include<iostream>
#include<queue>
#include<cstring>

typedef std::pair<int, int> P;

int w, h;
int field[100][100];
int xs, ys, xg, yg;
int n;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };

int main()
{
	while( std::cin >> w >> h, w | h )
	{
		memset( field, 0, sizeof( field ) );

		std::cin >> xs >> ys >> xg >> yg >> n;
		for( int i = 0; i != n; ++i )
		{
			int c, d, x, y;
			std::cin >> c >> d >> x >> y;
			for( int j = 0; j != 8; ++j )
			{
				int nx = x + ( d ? j % 2 : j / 2 ),
					ny = y + ( d ? j / 2 : j % 2 );

				field[ny-1][nx-1] = c;
			}
		}

		std::queue<P> que;
		int col = field[ys-1][xs-1];
		bool ans = false;
		que.push( P( xs, ys ) );

		while( !que.empty() )
		{
			P p = que.front(); que.pop();
			if( p.first == xg && p.second == yg )
			{
				ans = true;
				break;
			}

			field[p.second-1][p.first-1] = 0;

			for( int i = 0; i != 4; ++i )
			{
				int nx = p.first + dx[i],
					ny = p.second + dy[i];
				
				if( nx > 0 && nx <= w && ny > 0 && ny <= h && field[ny-1][nx-1] && field[ny-1][nx-1] == col )
					que.push( P( nx, ny ) );
			}
		}

		std::cout << ( ans ? "OK" : "NG" ) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1360
//A-Traveling_Budget
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  if(b>a) swap(a,b);
  if(d>c) swap(c,d);
  cout<<b+d<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String b = sc.next();
        if (b.equals("A")) {
            System.out.println("T");
        } else if (b.equals("T")) {
            System.out.println("A");
        } else if (b.equals("C")) {
            System.out.println("G");
        } else {
            System.out.println("C");
        }
        sc.close();
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  cout<<700+100*count(ALL(s),'o')<<endl;
}


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

const int N_MAX = 100005;

int main(){
    int n, x;
    cin >> n >> x;
    int A[N_MAX];
    A[0] = 0;
    for(int i = 1; i <= n;i++){
        cin >> A[i];
    }
    long long int ans = 0;
    for(int i = 1; i <= n; i++){
        int eat = (A[i-1] + A[i]) - x;
        eat = max(eat, 0);
        ans += eat;
        A[i] -= eat;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    ll n, k, h[301];
    cin >> n >> k;
    rep(i, n) cin >> h[i + 1];

    ll dp[309][309];
    rep(i, 309) rep(j, 309) dp[i][j] = 1LL << 60;
    dp[0][0] = 0;
    ll ans = 1e18;
    FOR(i, 1, n + 1)
    FOR(j, 1, n + 1)
    rep(l, i) chmin(dp[i][j], dp[l][j - 1] + max(0ll, h[i] - h[l]));

    rep(i, n + 1) chmin(ans, dp[i][n - k]);
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"



int main() {
  int N,K;cin>>N>>K;
  vector<int>anss;
  if(N==0){
    if(K==0){
      anss=vector<int>{0,0};
    }else{
      anss=vector<int>{-1};
    }
  }
  else if(N==1){
    if(K==0){
      anss=vector<int>{0,0,1,1};
    }else {
      anss=vector<int>{-1};
    }
  }else{
    if(K>=(1<<N)){
      anss=vector<int>{-1};
    }else{
      int num=K;
      for(int i=0;i<(1<<N);++i){
	if(i!=num)anss.push_back(i);
      }
      anss.push_back(num);
      for(int i=(1<<N)-1;i>=0;--i){
	if(i!=num)anss.push_back(i);
      }
      anss.push_back(num);
    }
  }
  for(auto ans:anss){
    cout<<ans<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2932
import Control.Applicative

stohms :: Int -> [Int]
stohms t = [t`div`3600,(t-(t`div`3600)*3600)`div`60,t`mod`60]

main = do
	a <- (stohms.(read::String->Int)) <$> getLine
	putStrLn $ (show (a !! 0)) ++ ":" ++ (show (a !! 1)) ++ ":" ++ (show (a !! 2))

Measured memory_bytes: 3580
import numpy as np
N, K = map(int,input().split())
A = np.array(list(map(int,input().split())))
F = np.array(list(map(int,input().split())))
A.sort()
F.sort()
A = A[::-1]
left = 0
right = np.max(A * F)
for _ in range(50):
    judge = (left + right) // 2
    rec = judge // F
    recK = np.sum(np.maximum(np.zeros(N), A - rec))
    if recK <= K:
        right = judge
    else:
        left = judge + 1
    if left == right:
        print(left)
        break

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

int32_t main()
{
	int k,a,b;
	cin>>k>>a>>b;
	if(b-a<=2)
	{
		cout<<(k+1)<<"\n";
		return 0;
	}
	k-=(a-1);
	int n=k/2;
	int t=a+n*(b-a);
	if(k%2) t++;
	cout<<t<<"\n";
	return 0;
}

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

int main()
{
    // input
    int a, b;
    cin >> a >> b;

    // output
    if (a > b)
    {
        cout << "a > b" << endl;
    } else if(a == b) {
        cout << "a == b" << endl;
    } else if(a < b) {
        cout << "a < b" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3084
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        int N = int.Parse(ReadLine());
        var dic = new Dictionary<int, int>();
        for (int i = 0; i < N; i++) {
            var A = int.Parse(ReadLine());
            if (dic.ContainsKey(A)) {
                dic[A]++;
            } else {
                dic.Add(A, 1);
            }
        }

        WriteLine(dic.Count(kvp => kvp.Value % 2 == 1));
    }
}

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

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

  long long int ans = 0; 
  for(int i = 1; i <= 2 * n; i += 2){ ans += a[i]; }
  cout << ans << endl;
  
  return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

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


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

using namespace std;

char s[13];

int main() {
	scanf("%s", s);
	for (int i = 0; i < 12; i++) {
		printf("%c", s[i]);
		if (i == 3) printf(" ");
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)

typedef long long ll;

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    vector<ll> dp(N,0);
    rep(i,N) cin >> h[i];
    rep(i,N) {

        if (i==0) {dp[i] = 0; continue;}

        ll vmin = std::numeric_limits<ll>::max();
        for(int j=i-1; i-j<=K && j>=0; j--){
            vmin = min(vmin, dp[j]+abs(h[i]-h[j]));
        }
        dp[i] = vmin;
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4][4],flag=0;
	for(int i=1;i<=3;++i)
	for(int j=1;j<=3;++j)
	cin>>a[i][j];
	int n;cin>>n;
	for(int i=0;i<n;++i)
	{
		int b;cin>>b;
		for(int j=1;j<=3;++j)
		for(int k=1;k<=3;++k)
		{
			if(b==a[j][k])
			a[j][k]=0;
		}
	}int sum[8];
	sum[0]=a[1][1]+a[1][2]+a[1][3];
	sum[1]=a[2][1]+a[2][2]+a[2][3];
	sum[2]=a[3][1]+a[3][2]+a[3][3];
	sum[3]=a[1][1]+a[2][1]+a[3][1];
	sum[4]=a[1][2]+a[2][2]+a[3][2];
	sum[5]=a[1][3]+a[2][3]+a[3][3];
	sum[6]=a[1][1]+a[2][2]+a[3][3];
	sum[7]=a[3][1]+a[2][2]+a[1][3];
	for(int i=0;i<8;++i)
	if(sum[i]==0) flag=1;
	if(flag==1) cout<<"Yes";
	if(flag==0) cout<<"No";
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())
A = []
for i in range(n):
    A.append(list(map(int, input().split())))
B = []
for i in range(m):
    B.append(list(map(int, input().split())))
C = [[0 for i in range(l)]for j in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for i in range(n):
    for j in range(l):
        if j > 0:
            print(" ", end="")
        print(C[i][j], end="")
    print()


Measured memory_bytes: 7144
using System;

class Program
{
    static void Main(string[] args)
    {
        int[] input = GetInt(' ');
        int N = input[0];
        int X = input[1];
        int[] m = new int[N];
        int sum = 0;
        int cnt = N;
        for (int i = 0; i < N; i++)
        {
            int inp = GetInt();
            m[i] = inp;
            sum += inp;
        }
        Array.Sort(m);
        while (sum+m[0] <= X)
        {
            sum += m[0];
            N++;
        }
        Output(N);
    }

    #region Tools
    static string GetInput()
    {
        return Console.ReadLine();
    }
    static string[] GetInput(char split)
    {
        return Console.ReadLine().Split(split);
    }
    static int GetInt()
    {
        return int.Parse(Console.ReadLine());
    }
    static int[] GetInt(char split)
    {
        string[] strarray = GetInput(split);
        int[] res = new int[strarray.Length];
        for (int i = 0; i < strarray.Length; i++)
        {
            res[i] = int.Parse(strarray[i]);
        }
        return res;
    }

    static void Output(string str)
    {
        Console.WriteLine(str);
    }
    static void Output(int str)
    {
        Console.WriteLine(str + "");
    }
    #endregion
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    string s;
    cin>>s;
    vi cnt(s.size());
    int od=0,ev=0; // l,r
    int li;
    REPA(i,s){
        swap(od,ev);
        ev++;
        if(s[i]=='R'){
            if(s[i+1]=='L'){ // \/ tani
                cnt[i]=ev;
                cnt[i+1]=od+1; // i+1
                ev=0;
                od=0;
                li=i;

                i++;
            }

        }else{
            if(i==s.size()-1 || s[i+1]=='R'){ // end / /\ yama
                //if(i!=s.size()-1)od++; // i+1
                cnt[li]+=ev;
                cnt[li+1]+=od;
                od=0;
                ev=0;
            }
        }


    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;



int main(){
  int a,b;
  cin >> a >>b;
  cout << (a+b+1)/2 << endl;

}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    int ans[] = {0,0,0,0,0,0,14,9,4,0,0,8,3,2,0,0,15,10,15,10,6,12,7,9,11,6,23,18,13,8,3,23,18,13,8,3,34,29,24,22,17,28,23,24,19,27,34,29,35,30,28,31,28,23,24,28,42,37,32,27,22,42,37,32,27,22,53,48,43,41,36,47,42,43,38,46,64,59,54,49,44,61,56,51,46,44,72,67,62,57,52,72,67,62,57,52,83,78,73,71};
    while(cin >> n){
        printf("%d\n", ans[n]);
    }
    return 0;
}


Measured memory_bytes: 3192
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 

void solve(long long A, long long B, long long K){
    if(A+B<K){
        cout<<0<<" "<<0<<endl;
    }
    else if(K>A){
        cout<<0<<" "<<(A+B)-K<<endl;
    } else {
        cout<<A-K<<" "<<B<<endl;
    }
}
 
signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


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

int main() {
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i == 0 || i == h- 1 || j == 0 || j == w - 1)cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		}
		return 0;
	}



Measured memory_bytes: 3100
#include <iostream>
using namespace std;
    int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(A+B > C+D){
        cout << "Left" << endl;
    }if(A+B < C+D){
        cout << "Right" << endl;
    }if(A+B == C+D){
        cout << "Balanced" << endl;
    }
    }

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	int n,a[3];

	cin >> n;

	for (int j = 0; j < n; j++)
	{
		for (int i = 0; i < 3; i++)
		{
			cin >> a[i];
		}

		sort (a,a + 3);

		if ((a[0] * a[0]) + (a[1] * a[1]) == (a[2] * a[2]))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
		a[0] = 0;
		a[1] = 0;
		a[2] = 0;
	}
}




Measured memory_bytes: 3036
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		sc.close();
		if(n < 1200) ou.println("ABC");
		else ou.println("ARC");
		ou.flush();
    }
}

Measured memory_bytes: 35812
#include <iostream>
#include <string>

//old school way

using namespace std;

void solve()
{
    string S;
    int Day;
    cin >> S;

    if (S == "SUN")
        Day = 7;
    if (S == "MON")
        Day = 6;
    if (S == "TUE")
        Day = 5;
    if (S == "WED")
        Day = 4;
    if (S == "THU")
        Day = 3;
    if (S == "FRI")
        Day = 2;
    if (S == "SAT")
        Day = 1;

    cout << Day << endl;
}

int main()
{

    solve();

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  S = regex_replace(S, regex("hi"), "A");
  S.erase(unique(S.begin(), S.end()), S.end());
  cout << ((S == "A") ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
/* ALDS1_8_A: Binary search trees II */
/* 20181126 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct BinaryTreeNode_ {
	int key;
	struct BinaryTreeNode_ *left;
	struct BinaryTreeNode_ *right;
} BinaryTreeNode;

void insert(BinaryTreeNode *node, int value);
int find(BinaryTreeNode *node, int value);
void print(BinaryTreeNode *node);
void Inorder(BinaryTreeNode *node);
void Preorder(BinaryTreeNode *node);

int main(void) {
	int i, n, value;
	char cmd[7];

	BinaryTreeNode *root = NULL;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", cmd);
		if(cmd[0] == 'i') { /* strcmp(cmd, "insert") == 0 */
			scanf("%d", &value);
			if(root == NULL) {
				root = (BinaryTreeNode *)malloc(sizeof(BinaryTreeNode));
				root->key = value;
				root->left = NULL;
				root->right = NULL;
			}else {
				insert(root, value);
			}
		}else if(cmd[0] == 'f') {  /* else if(strcmp(cmd, "find") == 0)  */
			scanf("%d", &value);
			if(find(root, value)) puts("yes");
			else puts("no");
		}else { /* else if(strcmp(cmd, "print") == 0)  */
			print(root);
		}
	}

	free(root);

	return 0;
}


void insert(BinaryTreeNode *node, int value) {
	if(value < node->key) {
		if(node->left == NULL) {
			node->left = (BinaryTreeNode *)malloc(sizeof(BinaryTreeNode));
			node->left->key = value;
			node->left->left = NULL;
			node->left->right = NULL;
		}else {
			insert(node->left, value);
		}
	}else {
		if(node->right == NULL) {
			node->right = (BinaryTreeNode *)malloc(sizeof(BinaryTreeNode));
			node->right->key = value;
			node->right->left = NULL;
			node->right->right = NULL;
		}else {
			insert(node->right, value);
		}
	}
}

int find(BinaryTreeNode *node, int value) {
	int ret;

	if(node == NULL) {
		ret = 0;
	}else {
		if(node->key == value) {
			ret = 1;
		}else if(node->key > value) {
			ret = find(node->left, value);
		}else{
			ret = find(node->right, value);
		}
	}

	return ret;
}

void print(BinaryTreeNode *node) {
	Inorder(node);
	printf("\n");
	Preorder(node);
	printf("\n");
}

void Inorder(BinaryTreeNode *node) {
	if(node == NULL) return ;
	Inorder(node->left);
	printf(" %d", node->key);
	Inorder(node->right);
}

void Preorder(BinaryTreeNode *node) {
	if(node == NULL) return;
	printf(" %d", node->key);
	Preorder(node->left);
	Preorder(node->right);
}


Measured memory_bytes: 14292
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
m = int(input())
list = input()
newlist = []
n = len(list)
for i in range(n):
	if int(alpha.find(list[i])) + m < 26:
		newlist.append(alpha[int(alpha.find(list[i])) + m])
	else:
		newlist.append(alpha[int(alpha.find(list[i])) + m -26]) 
moji = ''.join(newlist)
print(moji)

Measured memory_bytes: 3064
#!/usr/bin/env python3
# %%
import numpy as np
# %%
stdin = open(0)

# %%
K, Q = map(int, stdin.readline().split())
D = np.array(stdin.readline().split(), np.int64)
m = map(int, stdin.read().split())
query = tuple(zip(m, m, m))


# %%
def solve(n, x, m):
    Dm = D % m
    Dcum = np.cumsum(Dm)
    q, r = divmod(n - 1, K)
    last = x + Dcum[-1] * q
    if r:
        last += Dcum[r - 1]
    is_zero = np.cumsum(Dm == 0).astype(np.int64)
    stable = is_zero[-1] * q
    if r:
        stable += is_zero[r - 1]
    decr = (last // m) - (x // m)
    return n - 1 - stable - decr


# %%
for n, x, m in query:
    print(solve(n, x, m))

# %%


Measured memory_bytes: 15476
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		int count = solve(a);

		System.out.println(count);
		sc.close();
	}

	public static int solve(int[] a) {
		boolean flag = true;
		int count = 0;
		while (flag) {
			for (int i = 0; i < a.length; i++) {
				if (a[i] % 2 == 1) {
					flag = false;
				}
			}
			if (flag) {
				for (int i = 0; i < a.length; i++) {
					a[i] /= 2;
				}
				count++;
			}
		}
		return count;
	}

}

Measured memory_bytes: 35612
N = int(input())
A = [int(a) for a in input().split()]
print(*A)

for i in range(1, N):
    v = A[i]
    j = i - 1
    while 0 <= j and v < A[j]:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(*A)


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

double dp[100100];

li num(li x, li y) {
    li res = 0;
    while (x < y) {
        x *= 2;
        res++;
    }
    return res;
}

li cnt[100];

int main() {
    li n, k;
    cin >> n >> k;
    rep(i, n) {
        cnt[num(i + 1, k)]++;
    }

    li sum = 0;
    li bunbo = 1;
    rep(i, 20) {
        sum += cnt[i];
        sum *= 2;
        bunbo *= 2;
    }
    printf("%.12f\n", sum * 1.0 / bunbo / n);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k,x;
    cin>>k>>x;
    std::deque<int> deq;
    deq.emplace_back(x);
    int tmp1=x,tmp2=x;
    for (int i=0;i<k-1;i++) {
        tmp1--;
        deq.emplace_back(tmp1);
    }
    for (int j=0;j<k-1;j++) {
        tmp2++;
        deq.emplace_back(tmp2);
    }
    sort(deq.begin(),deq.end());
    for (int l=0;l<deq.size();l++) {
        if (l==deq.size()-1) {
            cout<<deq[l]<<endl;
        } else {
            cout<<deq[l]<<" ";
        }
    }
}


Measured memory_bytes: 256
W,H,x,y,r = map(int,input().split())
answer = "Yes"
if x-r < 0:
    answer = "No"
elif x+ r > W:
    answer = "No"   
elif y-r < 0:
    answer = "No"
elif y+r > H:
    answer = "No"
print(answer)


Measured memory_bytes: 5596
using System;
using System.Linq;
namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var foo = readIntArray();
            var N = foo[0];
            var D = Math.Pow(foo[1], 2);

            var Count = 0;
            for (int i = 0; i < N; i++)
            {
                var point = readIntArray();
                if(Math.Pow(point[0],2) + Math.Pow(point[1],2) <= D){
                    Count++;
                }
            }
            Console.WriteLine(Count);
        }
        static int readInt(){
            var foo = Console.ReadLine().Trim();
            return int.Parse(foo);
        }
        static String [] readArray(){
            return Console.ReadLine().Trim().Split();
        }
        static int [] readIntArray(){
            return readArray().Select(x => int.Parse(x)).ToArray();
        }

    }
}


Measured memory_bytes: 23264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
 
const int N = 303;
int n;
ll a[N][N];
ll ans = 0;
 
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
 
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			scanf("%lld", &a[i][j]);
		}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < i; j++) {
			ll w = a[i][j] + 1;
			for (int k = 0; k < n; k++) {
				if (i == k || j == k) continue;
				w = min(w, a[i][k] + a[k][j]);
			}
			if (w < a[i][j]) {
				printf("-1\n");
				return 0;
			}
			if (w > a[i][j]) ans += a[i][j];
		}
	printf("%lld\n", ans);
 
	return 0;
}

Measured memory_bytes: 896
#include <iostream>

int main()
{
  long long n0;
  long long sn = 0;

  std::cin >> n0;
  long long n = n0;
  
  while(n > 9){
    sn = sn + n % 10;
    n /= 10;
  }
  sn = sn + n;
  
  if(n0 % sn == 0){
    std::cout << "Yes";
  }
  else{
    std::cout << "No";
  }
}

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


int main() {
  string S;
  cin >> S;
  auto dp = vector< ll >(2019);
  ll ret = 0;
  for(auto &c : S) {
    auto dp2 = vector< ll >(2019);
    for(int i = 0; i < 2019; i++) {
      dp2[(i * 10 + (c - '0')) % 2019] += dp[i];
    }
    dp2[c - '0']++;
    ret += dp2[0];
    dp.swap(dp2);
  }
  cout << ret << endl;
}


Measured memory_bytes: 3716
using System;

namespace _0066
{
    class Program
    {
        readonly static int CELL_NUMBER = 9;
        static void Main(string[] args)
        {

            while (true)
            {
               var inputString = Console.ReadLine();
                if (string.IsNullOrEmpty(inputString))
                {
                    break;
                }

                var answer = "d";
                var cellField = inputString.ToCharArray();
                if(IsWin(cellField,'o'))
                {
                    answer = "o";
                }else if(IsWin(cellField,'x'))
                {
                    answer = "x";
                }
                Console.WriteLine(answer);
            }
        }

        static bool IsWin(char[] cellField,char mark)
        {
            for (int i = 0; i < Math.Sqrt(CELL_NUMBER); i++)
            {
                if ((cellField[i] == mark)&&(cellField[i+(int)Math.Sqrt(CELL_NUMBER)*(1)] == mark)&&(cellField[i+(int)Math.Sqrt(CELL_NUMBER)*(2)] == mark))
                {
                       return true;
                }
                else if ((cellField[(int)Math.Sqrt(CELL_NUMBER) * (i)] == mark) && (cellField[(int)Math.Sqrt(CELL_NUMBER) * (i)+1] == mark) && (cellField[(int)Math.Sqrt(CELL_NUMBER) * (i)+2] == mark))
                {
                    return true;              
                }
            }
            if ((cellField[0] == mark) && (cellField[4] == mark) && (cellField[8] == mark))
            {
                return true;
            }
            else if ((cellField[2] == mark) && (cellField[4] == mark) && (cellField[6] == mark))
            {
                return true;           
            }
            return false;
        }
    }
}

Measured memory_bytes: 5272
import sys

#+++++
		
def main():
	a = int(input())
	s = input()
	ret = 'red' if a < 3200 else s
	print(ret)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main()
{
	int n, d;
	cin >> n >> d;
	int s = 1 + d * 2;
	if (n%s == 0)
		cout << n / s;
	else
		cout << n / s + 1;
	return 0;
}

Measured memory_bytes: 256