akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
int D, N;
cin >> D >> N;
int S = 1; 
for(int i = 0 ;i < D; i++)S *= 100;
if( N == 100){
    cout << S * 101 << endl;
}
else{
    cout << S*N << endl;
}
}


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

int main() {
  int N, M, c1, c2;
  cin >> N >> M;
  vector<int> city(N);
  for(int i = 0; i < M; i++) {
    cin >> c1 >> c2;
    city.at(c1-1)++;
    city.at(c2-1)++;
  }
  for(int i= 0; i < N; i++)
    cout << city.at(i) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    p(N/3);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll Q;
  cin >> Q;
  vector<bool> prime(100001,1);
  prime[0]=prime[1]=0;
  rep(i,100001){
    if(prime[i]==1){
      ll k=2*i;
      while(k<=100000){
        prime[k]=0;
        k+=i;
      }
    }
    else{
      continue;
    }
  }
  vl dp(100001,0);
  for(ll i=3;i<=100000;i+=2){
    dp[i]=dp[i-2];
    if(prime[i]==1&&prime[(i+1)/2]==1){
      dp[i]++;
    }
  }
  rep(t,Q){
    ll l,r;
    cin >> l >> r;
    if(l!=1)
    l-=2;
    cout << dp[r]-dp[l] << endl;
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
const int N=1407,K=38,P=37;


int main(){
	cout<<N<<" "<<K<<endl;
	REP(i,K){
		cout<<N;
		REP(j,P){
			cout<<" "<<i*P+j+1;
		}
		cout<<endl;
	}
	REP(i,P){
		REP(j,P){
			cout<<P*P+i+1;
			REP(k,P){
				cout<<" "<<P*P+1-P-k*P+((i*k+j)%P);
			}
			cout<<endl;
		}
	}
	
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(),c.end()
#define rep(i,a,n) for(long long i=a;i<=n;i++)
typedef long long ll;

#define NDEBUG
#ifdef  NDEBUG
#define dbg(...)
#else
#include"debug.cpp"
#endif

const int N=2e7+10;
long long T, n, m, k, x, y, z, l, r, q, ans, p[N], b[N], mod = 1e9+7;

void solve(){
	ll d;
	cin >> l >> r >> d;
	cout<<r/d-(l-1)/d<<"\n";
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//cin >> T; while(T--)
	solve();
}


Measured memory_bytes: 3592
// AOJ 0115
#include<cstdio>
#include<cmath>
#define rep(i,a) for(int i=0;i<(a);++i)

const double EPS = 1e-8;

struct Pt
{
	double x, y, z;

	Pt( double x = 0, double y = 0, double z = 0 )
	:	x(x), y(y), z(z)
	{}

	Pt& operator+= ( const Pt &p )
	{
		x += p.x;
		y += p.y;
		z += p.z;

		return *this;
	}

	Pt& operator-= ( const Pt &p )
	{
		x -= p.x;
		y -= p.y;
		z -= p.z;

		return *this;
	}

	Pt operator+ ( const Pt &p ) const
	{ return Pt( x+p.x, y+p.y, z+p.z ); }

	Pt operator- ( const Pt &p ) const
	{ return Pt( x-p.x, y-p.y, z-p.z ); }

	Pt operator* ( double k ) const
	{ return Pt( k*x, k*y, k*z ); }

	Pt operator/ ( double k ) const
	{ return Pt( x/k, y/k, z/k ); }

	bool operator== ( const Pt &p ) const
	{ return x==p.x && y==p.y && z==p.z; }

	double dot( const Pt &p ) const
	{ return x*p.x+y*p.y+z*p.z; }

	double norm() const
	{ return sqrt(x*x+y*y+z*z); }

	Pt cross( const Pt &p ) const
	{ return Pt( y*p.z-z*p.y, z*p.x-x*p.z, x*p.y-y*p.x ); }
};

Pt uaz, enemy, v[3];

double area( const Pt &a, const Pt &b, const Pt &c )
{ return (b-a).cross(c-a).norm()/2; }

int main()
{
	double x, y, z;
	scanf( "%lf%lf%lf", &x, &y, &z ); uaz = Pt(x,y,z);
	scanf( "%lf%lf%lf", &x, &y, &z ); enemy = Pt(x,y,z);
	rep( i, 3 )
		scanf( "%lf%lf%lf", &x, &y, &z ), v[i] = Pt(x,y,z);

	double a = (enemy-uaz).x, b = (enemy-uaz).y, c = (enemy-uaz).z;
	double x0 = uaz.x, y0 = uaz.y, z0 = uaz.z;

	Pt n = (v[1]-v[0]).cross(v[2]-v[0]);
	double d = n.x, e = n.y, f = n.z;
	double x1 = v[0].x, y1 = v[0].y, z1 = v[0].z;

	if( fabs(a*d+b*e+c*f) < EPS )
	{ puts("HIT"); return 0; }

	double t = (d*(x1-x0)+e*(y1-y0)+f*(z1-z0))/(a*d+b*e+c*f);
	Pt inr( a*t+x0, b*t+y0, c*t+z0 );

	if( area(inr,v[0],v[1])+area(inr,v[1],v[2])+area(inr,v[2],v[0]) > area(v[0],v[1],v[2])+EPS )
		puts("HIT");
	else
		puts( (uaz-inr).dot(enemy-inr)>EPS ? "HIT" : "MISS" );

	return 0;
}

Measured memory_bytes: 1036
program main
    implicit none
    integer n,m
    integer,allocatable::a(:)
    read(*,*) n,m
    allocate(a(m))
    read(*,*) a(1:m)
    n=n-sum(a(1:m))
    if(n>=0) write(*,*) n 
    if(n<0) write(*,*) "-1"
end program main



Measured memory_bytes: 2872
import java.util.*;

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

        int num = S.length(); 
        if(S. equals (T.substring(0,num))){  
                System.out.println("Yes");
          }else{
                System.out.println("No");
            }      
	}
}


Measured memory_bytes: 35552
n,a,b=map(int,input().split())
h=[int(input())for _ in range(n)]
h.sort(reverse=True)
l=-1
r=(max(h)-1)//b+1
while r-l>1:
	mid=(l+r)//2
	cnt=0
	for i in range(n):
		if h[i]-b*mid<=0:
			break
		else:
			cnt+=(h[i]-b*mid-1)//(a-b)+1
	if cnt>mid:
		l=mid
	else:
		r=mid
print(r)



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, l;
  cin >> n >> l;
  
  vector<ll> v(n);
  REP(i,n)
    v[i] = l + (i + 1) - 1;
  
  int minv = 0;
  REP(i,n){
    if(abs(v[minv]) > abs(v[i]))
      minv = i;
  }
  
  cout << accumulate(v.begin(), v.end(), 0) \
    - v[minv] << "\n";
  
}

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

#include <iostream>
#include <vector>
#include <string>
#include <numeric>
using namespace std;


void solve(long long N, long long K, std::vector<long long> V){
    long long maximum = 0;
    for (auto i = 0;i<=K && i<=N;i++){
        for (auto j=0;j<=min(K-i,N-i);j++){
            std::vector<long long> current_vec(i+j,0);
            for (int num=0;num<i;num++){
                current_vec[num] = V[num];
            }
            for (int num=0;num<j;num++){
                current_vec[i+num] = V[N-1-num];
            }
            std::sort(current_vec.begin(),current_vec.end());
            long long num_negative_elem = 0;
            for (int idx=0;idx<i+j;idx++){
                if (current_vec[idx]<0){
                        num_negative_elem+=1;
                }else {
                    break;
                }
            }
            long long cand;
            if(num_negative_elem <= K-j-i){
                cand = std::accumulate(current_vec.begin()+num_negative_elem,current_vec.end(),0LL);
            }else{
                cand = std::accumulate(current_vec.begin()+K-j-i,current_vec.end(),0LL);
            }
            if (cand>maximum) maximum=cand;
            //printf("%lld %lld %lld %lld\n",i,j,num_negative_elem,cand);

        }

    }
    printf("%lld\n",maximum);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> V(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&V[i]);
    }
    solve(N, K, std::move(V));
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a[100001];
inline int read(){
	int x=0,f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())
		if(c=='-')
			f=-1;
	for(;isdigit(c);c=getchar())
		x=x*10+c-'0';
	return x*f;
}
int main(){
	int N=read(),ans=0;
	for(int i=1;i<=N;i++) a[i]=read();
	for(int i=1;i<=N;i++){
		
		if(a[i]==i){
			if(i==1){
				swap(a[i],a[i+1]);
				ans++; 
			}
			else if(i==N){
				ans++;
			}
			else if(a[i-1]==i-1){
				swap(a[i],a[i-1]);
				ans++;
			}
			else if(a[i+1]==i+1){
				swap(a[i],a[i+1]);
				ans++;
			}
			else{
				int p=1,q=N;
				for(int j=i-1;j>=1;j--)
					if(a[j]==j)	
						{p=j;break;}
				for(int k=i+1;k<=N;k++)
					if(a[k]==k)
						{q=k;break;}
				if(i-p>q-i) swap(a[i],a[i+1]);
				if(i-p<q-i) swap(a[i],a[i-1]);
				ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
s = input()
t = input()

s_list = [ 0 for i in range(26) ]
t_list = [ 0 for i in range(26) ]
for i in range(len(s)):
    s_list[ord(s[i])-97] += 1
    t_list[ord(t[i])-97] += 1

s_list = sorted(s_list)
t_list = sorted(t_list)

if s_list == t_list:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 41840
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,K,Q = map(int, input().split())
    P = [Q]*N
    for i in range(Q):
        a = int(input())-1
        P[a] -= 1
    for p in P:
        if K > p:
            print("Yes")
        else:
            print("No")



if __name__ == '__main__':
    main()


Measured memory_bytes: 8660
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(int argc, char const *argv[]) {
    long long h, n, a[1001], b[1001];
//    vector<vector<int> > v;
    long long dp[10010];
    cin >> h >> n;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0;i<=h;i++){
        dp[i]=INF;
    }
    dp[0]=0;
    for(int i=0;i<=h;i++){
        for (int j=0;j<n;j++) {
            if(i-a[j]<0){
                chmin(dp[i],b[j]);
            }else {
                chmin(dp[i], dp[i - a[j]] + b[j]);
            }
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 384
"""
B - Small and Large Integers
"""

a, b, k = map(int, input().split())

numbers = []
for i in range(a, a + k):
    if a <= i and i <= b:
        numbers.append(i)
    else:
        break

for i in range(b - k + 1, b + 1):
    if a <= i and i <= b:
        if i not in numbers:
            numbers.append(i)
    else:
        break

for i in numbers:
    print(i)


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


int main() {
  priority_queue<int> a;
  int n, m;
  cin >> n >> m;
  rep(i,n) {
    int x;
    cin >> x;
    a.push(x);
  }
  while(m>0) {
    a.push(a.top()/2);
    a.pop();
    m--;
  }
  ll ans=0;
  while (a.size()>0) {
    ans+=a.top();
    a.pop();
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <cmath>

using namespace std;

typedef long long int ll;

ll minCost(int arr[] , int n)
{
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i=2 ; i<n ; i++)
        dp[i] = min( abs(arr[i]-arr[i-1]) + dp[i-1] , abs(arr[i]-arr[i-2]) + dp[i-2]);

    return dp[n-1];
}

int main() 
{
    int n;
    cin >> n;
    int arr[n];

    for(int i=0 ; i<n ; i++)
        cin >> arr[i];

    cout << minCost(arr , n);

    return 0;
}


Measured memory_bytes: 1408
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(all(a));

    int i = 0;
    pair<ll,ll> maxn = make_pair(0,0);
    while(i < N){
        ll tmp = a[i],cnt = 0;
        while(i < N && a[i] == tmp){
            i++;
            cnt++;
        }
        if (cnt >= 2){
            maxn = make_pair(tmp,cnt);
        }
    }

    i = 0;
    pair<ll,ll> maxn2 = make_pair(0,0);
    while(i < N){
        ll tmp = a[i],cnt = 0;
        while(i < N && a[i] == tmp){
            i++;
            cnt++;
        }
        if (cnt >= 2 && tmp != maxn.first){
            maxn2 = make_pair(tmp,cnt);
            //maxn2 = tmp;
        }
    }
    if (maxn.second >= 4){
        cout << maxn.first * maxn.first << endl;
    } else {
        cout << maxn.first * maxn2.first << endl;
    }


    return 0;
}


Measured memory_bytes: 768
N = int(input())
times = []
for i in range(N):
    A, B = map(int, input().split())
    times.append([A, B])

times.sort(key=lambda x:x[1])

t = 0
for i in range(N):
    t += times[i][0]
    if t > times[i][1]:
        print('No')
        exit()

print('Yes')

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i = 0; i < N; ++i) cin >> P[i];
  int ans = 0, ma = 0;
  for(int i = 0; i < N; ++i){
    ans += P[i];
    ma = max(ma, P[i]);
  }
  ans -= (ma+1)/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
  long n;
  string s;
  cin >> n >> s;
  long bl = 0;
  long wh = 0;
  int ans =0;
  long blmax = 0;
  bool black = false;
  fr(i,n){
   if(s.substr(i, 1)=="#"){black = true; bl += 1; blmax+=1;}
   else if(black){
     bl -=1;
     if(bl < 0){
       ans += blmax;
       bl =0;
       blmax=0;
     }
   }
  }
  ans += blmax- bl;
  cout << ans << endl;
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

gA = [1, 3, 5, 7, 8, 10, 12]
gB = [4, 6, 9, 11]
gC = [2]

x, y = MAP()

for l in [gA, gB, gC]:
	if x in l and y in l:
		print("Yes")
		break
else:
	print("No")

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

struct Node{
  int key;
  struct Node* parent; //親
  struct Node* left; //左の子
  struct Node* right; //右の子
};

typedef struct Node node;

node* insert(node* r, int k) {
  node* x = r;
  node* y = NULL;
  node* z = (node*)malloc( sizeof(node) );
  z->key = k;
  z->left = NULL;
  z->right = NULL;
  z->parent = NULL;

  while( x != NULL) {
    y = x;

    if( z->key < x->key ) {
      x = x->left;
    }else {
      x = x->right;
    }

  }
  z->parent = y;

  if( y == NULL) {
    r = z;
  }else if( z->key < y->key) {
    y->left = z;
  }else {
    y->right = z;
  }

  return r;

}


void printInorder(node* r) { //左->自身->右
  
  if(r->left != NULL) {
    printInorder( r->left );
  }

  printf(" %d", r->key);

  if(r->right != NULL) {
    printInorder( r->right );
  }

}


void printPreorder(node* r) {

  printf(" %d", r->key);

  if(r->left != NULL) {
    printPreorder( r->left );
  }

  if(r->right != NULL) {
    printPreorder( r->right );
  }

}


node* find(node* r, int k) {

  while(1) {
    
    if( r == NULL ) {
      return NULL;
    }

    if(r->key == k) {
      return r;
    }
    
    if( r->key > k ) {
      r = r->left;
    }else if ( r->key < k ) {
      r = r->right;
    }
    
  }
}


void isExist( node* r, int k) {
  
  if( find( r, k) == NULL ) {
    printf("no\n");
  }else {
    printf("yes\n");
  }
}


int main() {

  int m, k;
  node* r = NULL;
  char o[10];
  int i;

  //命令の数を取得
  scanf("%d", &m);

  for( i=0; i<m; i++) {

    //命令を取得
    scanf("%s", o);

    if( !strcmp( o, "insert") ) { //挿入
      scanf("%d", &k);
      r = insert( r, k);
    }

    if( !strcmp( o, "print") ) { //出力
      printInorder( r );
      printf("\n");

      printPreorder( r );
      printf("\n");
    }

    if( !strcmp( o, "find") ) { //探査
      scanf("%d", &k);
      isExist( r, k);
    }

  }

  return 0;

}

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

long long dis(long long x, long long y) {
  return x * x + y * y;
}

int main()
{
  int N; cin >> N;
  const long long INF = 1e18 + 10;
  vector<tuple<double, int, int>> E;
  for (int i = 0; i < N; i++)
  {
    int x, y; cin >> x >> y;
    double r;
    if (x == 0) {
      if (y < 0) r = -INF;
      else r = -1e9;
    }
    else {
      r = (double)y / x;
      if (x > 0) r -= 2 * 1e9;
    }
    E.push_back(tie(r, x, y));
  }
  sort(E.begin(), E.end());
  for (int i = 0; i < N; i++)
  {
    E.push_back(E[i]);
  }

  long long ansx = 0;
  long long ansy = 0;
  for (int i = 0; i < N; i++)
  {
    long long sumx = 0;
    long long sumy = 0;
    for (int j = 0; j < N; j++)
    {
      sumx += get<1>(E[i + j]);
      sumy += get<2>(E[i + j]);
      if (dis(ansx, ansy) < dis(sumx, sumy)) {
        ansx = sumx;
        ansy = sumy;
      }
    }
  }
  double ans = sqrt(dis(ansx, ansy));
  printf("%50.12lf\n", ans);
}

Measured memory_bytes: 256
function main(input) {
  const i = input.split(' ');
  let tHealth = parseInt(i[0]);
  let tStrength = parseInt(i[1]);
  let aHealth = parseInt(i[2]);
  let aStrength = parseInt(i[3]);
  while (tHealth > 0 && aHealth > 0) {
  	aHealth -= tStrength;
    if (aHealth <= 0) break;
    tHealth -= aStrength;
    if (tHealth <= 0) break;
  }
  if (tHealth > 0) console.log('Yes');
  else console.log('No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29600
// https://atcoder.jp/contests/abc090/tasks/arc091_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k, ans = 0;
    cin >> n >> k;
    if (k == 0) {
        cout << n * n << endl;
        return 0;
    }
    // 割る数はk+1以上
    FOR(d, k + 1, n + 1) {
        ans += n / d * (d - k);
        ans += max(0LL, n % d - k + 1);
        // cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, t;
    cin >> x >> t;
    if(x > t){
        cout << x-t << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x  =  sc.nextLong();

        long ans = 0;
        while (n >= 0) {
            long center = getCenter(n);
            if (n == 0) {
                ans += 1;
                break;
            }
            if (x == getALL(n)) {
                ans += getAllP(n);
                break;
            }
            if (x == 1) {
                break;
            }

            if (x > center) {
                ans += getAllP(n - 1) + 1;
                x -= center;
                n--;
                if (x == 1 && n != 0) {
                    break;
                }
            } else if (x < center) {
                n--;
                x--;

            } else {
                ans += getAllP(n - 1) + 1;
                break;
            }
        }





        System.out.println(ans);
    }

    static long getAllP(int n ) {
        return (long) (Math.pow(2, n + 1) - 1);
    }
    static long getCenter(int n) {
        return (long) (Math.pow(2, n + 1) - 1);
    }
    static long getALL(int n) {
        return (long) (Math.pow(2, n + 2) - 3);
    }

}

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

using namespace std;

int main()
{
   int x;
   int sum = 0;
   for (int i = 0; i < 3; i++)
   {
      cin >> x;
      sum += x;
   }

   if (sum > 21)
      cout << "bust" << endl;
   else
      cout << "win" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final String S = sc.next();
        final long K = sc.nextLong();


        char c = 1;
        int index = S.length();
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) != '1') {
                c = S.charAt(i);
                index = i;
                break;
            }
        }

        if (K <= index) {
            System.out.println(1);
        } else {
            System.out.println(c);
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
 
signed main(){
    int m;
    cin >> m;
    ll d, c;
    ll sum1 = 0, sum2 = 0;
    REP(i,m){
        cin >> d >> c;
        sum1 += c;
        sum2 += d * c;
    }
    cout << sum1 + (sum2 - 1) / 9 - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
n, m,c = map(int, input().split())
b=list(map(int,input().split()))
d=0
for i in range(n):
  aaa=0
  a=list(map(int,input().split()))
  for j in range(m):
    aaa+=a[j]*b[j]
  if aaa+c>0:
      d+=1

print(d)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	ll arr[10][10] = {};
	for(int i = 1; i <= n; i++){
		int x = i;
		while(x >= 10) x/= 10;
		arr[x][i%10]++;//Kaçının başında x sonunda i%10 var
	}
	ll res = 0;
	for(int i = 1; i <= n; i++){
		int x = i;
		while(x >= 10) x/= 10;
		res += arr[i%10][x];//Kaçının başında i%10 sonunda x var(ters)
		//Burada sayımızın başında x, başında i%10 var. Sorunun istediği durumları topluyoruz.
	}
 	cout<<res;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int main(){
	int a;scanf("%d",&a);
	int ret=mod;
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);int tmp=0;
		while(p%2==0){p/=2;tmp++;}
		ret=min(ret,tmp);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e8
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


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 mxa = a[n-1];

	int mxr = a[0];
	for (int i = 0; i < n; i++) {
		if (abs(2*a[i] - mxa) < abs(2*mxr - mxa))mxr = a[i];
	}
		
	cout << mxa << " " << mxr << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a;
	cin>>a;
	cout<<3*a*a<<endl;
	
	return 0;
}

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

template<long long int MODVALUE>
class modllint{
  long long int val;
  void mod(){
    while( this->val < 0 ) this->val += MODVALUE;
    this->val %= MODVALUE;
  }
  void assign(const long long int val){
    this->val = val;
    mod();
  }
public:
  modllint(): val(0){};
  modllint(const long long int val){assign(val);};
  
  modllint operator+(const long long int val){
    return modllint<MODVALUE>(this->val + val);
  }
  modllint operator+(const modllint& obj){return *this + obj.val;}
  modllint& operator+=(const long long int val){
    this->assign(this->val + val);
    return *this;
  }
  modllint& operator+=(const modllint& obj){
    this->assign(this->val + obj.val);
    return *this;
  }
  
  modllint operator*(const long long int val){
    return modllint<MODVALUE>(this->val * val);
  }
  modllint operator*(const modllint& obj){return *this * obj.val;}
  modllint& operator*=(const long long int val){
    this->assign(this->val * val);
    return *this;
  }
  modllint& operator*=(const modllint& obj){
    this->assign(this->val * obj.val);
    return *this;
  }

  modllint& operator=(const modllint& obj){
    assign(obj.val);
    return *this;
  }
  modllint& operator=(const long long int intvalue){
    assign(intvalue);
    return *this;
  }
  
  friend std::ostream& operator<<(std::ostream& os, const modllint<MODVALUE>& val){
    os << val.val;
    return os;
  }
  friend std::istream& operator>>(std::istream& is, modllint<MODVALUE>& val){
    is >> val.val;
    return is;
  }
};

const int MOD = 1000000007;

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

  std::vector<bool> v(2*n);
  for(int i=0; i<2*n; i++){
    v[i] = (s[i]=='B');
  }
  for(int i=0; i<2*n; i++){
    if(i%2 == 0) v[i] = !v[i];
  }

  modllint<MOD> result = 1;
  int l_count = 0;
  for(int i=0; i<2*n; i++){
    if(v[i]){ //R
      if(l_count == 0){
	std::cout << 0 << std::endl;
	return 0;
      }
      result *= l_count--;
    }else{
      l_count++;
    }
  }
  if(l_count != 0){
    std::cout << 0 << std::endl;
  }else{
    modllint<MOD> fac = 1;
    for(int i=1; i<=n; i++){
      fac *= i;
    }
    std::cout << (result * fac) << std::endl;
  }
  return 0;
}


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

void fail(){
	cout << "Impossible" << '\n';
	exit(0);
}

mt19937 mt(48);

vector<int> inv(vector<int> x){
	reverse(x.begin(), x.end());
	for(int& a : x) a = -a;
	return x;
}

vector<int> make(vector<int> val){
	if(val.size() == 1){
		return val;
	}
	vector<int> nval[2];
	vector<int> nx[2];
	for(int i = 0; i < (int)val.size(); i++){
		nval[i & 1].push_back(val[i]);
	}
	nx[0] = make(nval[0]);
	nx[1] = make(nval[1]);
	vector<int> x;
	for(int r : nx[0]) x.push_back(r);
	for(int r : nx[1]) x.push_back(r);
	for(int r : inv(nx[0])) x.push_back(r);
	for(int r : inv(nx[1])) x.push_back(r);
	return x;
}

void pr(vector<int> x){
	vector<pair<int,int> > path;
	path.push_back({0, 0});
	for(int f : x){
		int c = 0;
		int val = abs(f) - 1;
		while(c < val){
			c++;
			path.push_back({c, 0});
		}
		if(f > 0){
			path.push_back({c, 1});
			path.push_back({c+1, 1});
			path.push_back({c+1, 0});
			path.push_back({c, 0});
		} else {
			path.push_back({c+1, 0});
			path.push_back({c+1, 1});
			path.push_back({c, 1});
			path.push_back({c, 0});
		}
		while(c > 0){
			c--;
			path.push_back({c, 0});
		}
	}
	cout << "Possible" << '\n';
	cout << (int)path.size() - 1 << '\n';
	for(pair<int,int> a : path){
		cout << a.first << ' ' << a.second << '\n';
	}
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	int N = (1 << n);
	string s(N, '0');
	cin >> s;
	// for(int j = 0; j < N; j++){
	// 	s[j] = "01"[(__builtin_popcount(j | (j >> 1)) <= 3)];
	// }

	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if((i & j) == i){
				if(s[i] < s[j]){
					fail();
				}
			}
		}
	}
	vector<vector<int> > q;
	for(int i = 0; i < N; i++){
		if(s[i] == '1') continue;
		vector<int> val;
		bool fail = false;
		for(int j = 0; j < n; j++){
			if((i >> j) & 1){
				val.push_back((j+1));
				if(s[i ^ (1 << j)] == '0') fail = true;
			}
		}
		if(fail) continue;
		q.push_back(val);
	}
	vector<int> ans;
	for(vector<int> val : q){
		vector<int> z = make(val);
		for(int v : z) ans.push_back(v);
	}
	bool works = true;
	for(int j = 0; j < N; j++){
		vector<int> stk = {0};
		for(int f : ans){
			if((j >> (abs(f) - 1)) & 1){
				if(stk.back() == -f){
					stk.pop_back();
				} else {
					stk.push_back(f);
				}
			}
		}
		int wins = (stk.size() == 1);
		if(wins != s[j] - '0'){
			cerr << j << ' ' << wins << ' ' << (s[j] - '0') << '\n';
			works = false;
			break;
		}
	}
	cerr << ans.size() << '\n';
	for(int x : ans){
		cerr << x << ' ';
	}
	cerr << '\n';
	pr(ans);
}

Measured memory_bytes: 640
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b = deque()

# print(a)
rev = False
for i in a:
    if rev:
        b.appendleft(i)
    else:
        b.append(i)
    rev = not rev

if rev:
    b.reverse()

for i in b:
    print(i)


Measured memory_bytes: 32464
#include <stdio.h>

int main(void)
{
	float w;
	
	while (scanf("%f", &w) != EOF){
		if (w <= 48.00){
			printf("light fly\n");
		}
		else if (w <= 51.00){
			printf("fly\n");
		}
		else if (w <= 54.00){
			printf("bantam\n");
		}
		else if (w <= 57.00){
			printf("feather\n");
		}
		else if (w <= 60.00){
			printf("light\n");
		}
		else if (w <= 64.00){
			printf("light welter\n");
		}
		else if (w <= 69.00){
			printf("welter\n");
		}
		else if (w <= 75.00){
			printf("light middle\n");
		}
		else if (w <= 81.00){
			printf("middle\n");
		}
		else if (w <= 91.00){
			printf("light heavy\n");
		}
		else if (w > 91.00){
			printf("heavy\n");
		}
	}
	return (0);
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s, t;
int main() {
    cin >> s >> t;
    if (s[0] != t[2] || s[1] != t[1] || s[2] != t[0])
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}


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

int A[30],n;

int slove(int i,int m){
  if(m == 0) return true;
  if( i >= n) return false;
  int res = slove(i + 1, m) || slove(i + 1, m - A[i]);
  return res;
}

int main(){
  int q,i,M;
  cin >> n;
  for(i = 0; i < n; i++) cin >> A[i];
  cin >> q;
  for(i = 0; i < q; i++){
    cin >> M;
    if(slove(0,M)) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>

int main(void){
    int n;
    long a[100000],x,res=0,sum=0;
    scanf("%d %ld",&n,&x);
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
    }
    for(int i=0;i<n-1;i++){
        sum = a[i] + a[i+1];
        if(sum > x){
            if(a[i+1] < sum - x){
                a[i] -= sum - x - a[i+1];
                a[i+1] = 0;
            }else{
                a[i+1] -= sum - x;
            }
            res += sum - x;
        }
    }
    printf("%ld\n",res);
    return 0;
}

Measured memory_bytes: 896
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class APassword {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n;
        in>>n;
        out<<n*n*n<<endl;
    }
};

int main() {
    APassword solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
 ll h,w ;cin>> h>> w ;
 char  d[h][w] ;
 int dist[h][w] ;
 int res=0 ;

 
 vector<P> A ;
 rep(i,h){
   rep(j,w){
      cin>> d[i][j] ;
     if(d[i][j]=='.') {
       A.pb(mpa(i,j)) ;  
        res++ ;
   }
   }
 }
 res-- ;
 int aans = 0 ;

 for(auto main :A){
 queue<P> q ;
 bool seen[h][w] ;
 rep(i,h){
   rep(j,w) {
     seen[i][j]=0 ;
     dist[i][j]=0 ;
     }

 }
 
 q.push(main) ;



while(!q.empty()){
   auto x= q.front() ;
   q.pop() ;
   seen[x.fi][x.se]= 1 ;
   int a= x.fi ; int b=x.se ;
   if(a-1>=0&& seen[a-1][b]==0&&d[a-1][b]=='.'){
   dist[a-1][b]= dist[a][b]+1 ;
   seen[a-1][b]=1 ;
   q.push(mpa(a-1,b)) ;
   res-- ;
   }
   
   if(a+1<=h-1&& seen[a+1][b]==0&&d[a+1][b]=='.'){
   dist[a+1][b]= dist[a][b]+1 ;
   seen[a+1][b]=1 ;
   q.push(mpa(a+1,b)) ;
   res-- ;
   }
   
   if(b-1>=0&& seen[a][b-1]==0&&d[a][b-1]=='.'){
   dist[a][b-1]= dist[a][b]+1 ;
   seen[a][b-1]=1 ;
   q.push(mpa(a,b-1)) ;
   res--;
   }
  
  if(b+1<=w-1 && seen[a][b+1]==0&&d[a][b+1]=='.'){
    dist[a][b+1]=dist[a][b]+1 ;
    seen[a][b+1]=1 ;
    q.push(mpa(a,b+1)) ;
    res-- ;
  }
 
 }
 
 
 int ans= 0;
 rep(i,h){
   rep(j,w) ans= max(ans,dist[i][j]) ;
 }
   aans = max(aans,ans) ;
   }  
   cout<<aans<<endl ;
  return 0;
  }

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
struct City {
	int year, pref, id;
	City() {}
	City(int y, int p, int i):
	year(y), pref(p), id(i) {}
	bool operator< (const City& other) { return year < other.year; }
};

const int N = 100010;
string ans[N];
vi pre[N];
int n, m;

string gen (int p, int x) {
	string a (6, '0');
	string b (6, '0');
	int itr = 5;
	while (p) {
		a[itr--] = (p % 10) + '0';
		p /= 10;
	}
	itr = 5;
	while (x) {
		b[itr--] = (x % 10) + '0';
		x /= 10;
	}
	return a + b;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> n >> m;
	vector<City> v;
	int y, p;
	Foz(i, m) {
		cin >> p >> y;
		v.pb({y, p, i + 1});
	}
	sort(all(v));
	Foz(i, m) pre[v[i].pref].push_back(v[i].id);
	For(i, 1, n + 1) {
		Foz(j, sz(pre[i])) ans[pre[i][j]] = gen(i, j + 1);
	}
	For(i, 1, m + 1) cout << ans[i] << '\n';
}



Measured memory_bytes: 13684
from collections import Counter
from itertools import product

N, W = map(int, input().split())
items = {}
weight = []

for i in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    
    if items.get(w, None) is None:
        items[w] = []
    items[w].append(v)
    items[w] = sorted(items[w], reverse = True)

cnt = Counter(weight)

w_num = [] #各重さの個数。組み合わせのために使う。[range(0,2), range(0,3), range(0,2)]のような出力
w_set = [] # 重さは w0 <= wi <= w0+3の４通りしかない

for w in range(weight[0], weight[0] + 4):
    if cnt[w] == 0:
        continue
    
    w_num.append(range(cnt[w] + 1))
    w_set.append(w)

ans = 0

for i in product(*w_num):
    w = sum(map(lambda x: x[0] * x[1], zip(i, w_set)))
    if 1 > w or w > W:
        continue
    v = sum([sum(items[k][:j]) for j, k in zip(i, w_set)])
    if ans < v:
        ans = v

print(ans)

Measured memory_bytes: 3444
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		while(in.hasNext()){
			double v=in.nextDouble();
			double t=v/9.8;
			double y=4.9*t*t;
			int ans=(int)(y+5)/5+1;
			System.out.println(ans);
		}
		in.close();
	}
}

Measured memory_bytes: 28076
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

pii INIT = pii(-1, -1);
int board[33][33];
int acc[33][33];
pii memo[33][33][33][33];

int H, W, E, S;

int getsum(int p, int q, int x, int y) {
    return board[x][y] - board[p][y] - board[x][q] + board[p][q];
}

// ?°???°??? (??????) ??????????????????
pii solve(int lx, int ly, int rx, int ry) {
    pii& ans = memo[lx][ly][rx][ry];
    if(ans != INIT) return ans;

    // ?°???°???????????¶???????????????????????§??????????????±???????????????????????????????????????
    int sum = getsum(lx, ly, rx, ry);
    if(sum < E - S) return ans = pii(0, INF);

    // ??????
    ans = pii(1, sum);

    // ?¨??????????
    rep(i,lx+1,rx) {
        pii ra = solve(lx, ly, i, ry);
        pii rb = solve(i, ly, rx, ry);
        pii temp = pii(ra.first + rb.first, min(ra.second, rb.second));
        chmax(ans, temp);
    }

    // ????????????
    rep(i,ly+1,ry) {
        pii ra = solve(lx, ly, rx, i);
        pii rb = solve(lx, i, rx, ry);
        pii temp = pii(ra.first + rb.first, min(ra.second, rb.second));
        chmax(ans, temp);
    }
    return ans;
}

signed main() {
    while(cin >> H >> W >> S, H || W || S) {
        memset(board, 0, sizeof(board));
        rep(i,0,33) rep(j,0,33) rep(k,0,33) rep(l,0,33)
            memo[i][j][k][l] = INIT;
        rep(i,0,H) rep(j,0,W) cin >> board[i+1][j+1];
        rep(i,0,H) rep(j,0,W) board[i+1][j+1] += board[i+1][j];
        rep(j,0,W) rep(i,0,H) board[i+1][j+1] += board[i][j+1];

        E = getsum(0, 0, H, W);
        pii ans = solve(0, 0, H, W);
        printf("%lld %lld\n", ans.first, S - (E - ans.second));
    }
    return 0;
}

Measured memory_bytes: 21692
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		fmt.Scan(&a[i+1])
	}

	m := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		m[i] = make([]int, n+1)
	}

	for d := 2; d <= n; d++ {
		for s := 0; s+d <= n; s++ {
			min := 1 << 30
			for j := s+1; j < s+d; j++ {
				val := m[s][j] + m[j][s+d] + a[s]*a[j]*a[s+d]
				if val < min {
					min = val
				}
			}
			m[s][s+d] = min
		}
	}
	fmt.Println(m[0][n])
}



Measured memory_bytes: 1180
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 100010;
const int inf = 0x0fffffff;
#define LL long long
const long long mod = 1000000007;

pair<int, int> pi[maxn];
int N;
LL K;

int main()
{
	cin >> N >> K;
	int i;
	for (i = 0; i < N; i ++)
	{
		int a, b;
		cin >> a >> b;
		pi[i] = make_pair(a, b);
	}
	sort(pi, pi + N);
	for (i = 0; i < N && K > pi[i].second; i ++)
		K -= pi[i].second;
	cout << pi[i].first;
	return 0;
}

Measured memory_bytes: 1024
<?php
$s = str();
$n = strlen($s);
$rArray[0] = 1;
for($i = 1; $i < $n; $i++){
  if($s[$i] == "R"){
    $rArray[$i] = $rArray[$i-1] + 1;
  }else{
    $rArray[$i] = 0;
  }
}
$lArray[$n-1] = 1;
for($i = $n-2; $i >= 0; $i--){
  if($s[$i] == "L"){
    $lArray[$i] = $lArray[$i+1] + 1;
  }else{
    $lArray[$i] = 0;
  }
}
for($i = 0; $i < $n; $i++){
  $result[$i] = 0;
}
for($i = 0; $i < $n - 1; $i++){
  if(substr($s,$i,2) == "RL"){
    $c = $rArray[$i] + $lArray[$i+1]; 
    if($c % 2 == 0){
      $result[$i] += $c/2;
      $result[$i+1] += $c/2;
    }else{
      $result[$i] += floor($c/2);
      $result[$i+1] += floor($c/2);
      if((($rArray[$i] > $lArray[$i+1]) + max($rArray[$i], $lArray[$i+1])) % 2 == 1){
        $result[$i+1]++;
      }else{
        $result[$i]++;
      }
    }
  }
}
echo implode(" ", $result);

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 23280
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
 
    public static void main(String[] args) {
      int i,N;
      Scanner sc=new Scanner(System.in);
      N=sc.nextInt();
      ArrayList<Integer> a=new ArrayList<Integer>();
      for(i=0;i<N;i++){
        int scan=sc.nextInt();
        a.add(scan);
      }
      
      System.out.println(N-solve(a));
      sc.close();
    }

  
  static int solve(ArrayList<Integer> ia){
    int i=0;
    for(int b:ia){
      if(b==i+1)
        i++;
    }
    if(i>0)
     return i;
    else
     return ia.size()+1; 
  }
}
 


Measured memory_bytes: 90464
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    map<ll,ll> map_;
    rep(i,n){
        ll a; cin >> a;
        map_[a]++;
    }
    ll ans = 0;
    vector<Pll> vec;
    for(auto itr = map_.begin(); itr != map_.end();itr++){
        if((*itr).second >= 2)vec.emplace_back((*itr).first, (*itr).second);
    }
    sort(all(vec), greater<Pll>());
    if(vec.size() >= 2){
        if(vec[0].second >= 4)ans = vec[0].first * vec[0].first;
        else ans = vec[0].first * vec[1].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
 
using namespace std;
 
int main () {
  int n;
  int a[3];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if ((a[2] * a[2]) == (a[1] * a[1]) + (a[0] * a[0]))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1168