akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define RG register
#define LL long long
using namespace std;
const int N=9e5+10;
int n,cnt,num=1;
LL h,w,col[N],ans[12],zro;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
//	freopen("Snuke's Coloring.in","r",stdin);
	//freopen(".out","w",stdout);
	read(h,w,n); zro=(h-2)*(w-2);
	for(int i=1,a,b;i<=n;i++)
	{
		read(a,b);
		for(int x=-2;x<=0;x++)
		 for(int y=-2;y<=0;y++)
		  if(a+x>0 && a+x<=h-2 && b+y>0 && b+y<=w-2)
		   col[++cnt]=(a+x-1)*(w)+(b+y);
	}
	sort(col+1,col+cnt+1);
	for(int i=1;i<=cnt;i++)
	 if(col[i]==col[i+1]) num++;
	 else ans[num]++, zro--, num=1;
	printf("%lld\n",zro);
	for(int i=1;i<10;i++) printf("%lld\n",ans[i]);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b,c;
  cin >> a >> b >> c;
  if(a<=c && c<=b)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;

}

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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
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); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  Bint a, b;
  cin >> a >> b;
  cout << a * b << endl;

  return 0;
}



Measured memory_bytes: 3264
import java.util.*;
class Main{
    public static void main(String[] args){
    	//final int MAX =200000;
    	
    
    	Scanner sc = new Scanner(System.in);
    	//int n = Integer.parseInt(sc.next());
    	int n =sc.nextInt();
    	int[] R=new int[n];
    	
    	for(int i=0;i<n;i++){
    		// R[i]=Integer.parseInt(sc.next());
    		 R[i]=sc.nextInt();
    	}
    	int maxv=-2000000000;
    			 
    	int minv=R[0];
    	for(int i=1;i<n;i++){
    		maxv=Math.max(maxv,R[i]-minv);
    		minv=Math.min(minv,R[i]);
    	}
    	System.out.println(maxv);
    	
    }
}

Measured memory_bytes: 96588
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

// const int kMaxN;

int a, b;
int ans = 0;

signed main() {
  cin >> a >> b;

  ans = a-1;
  if (a <= b) { ++ans; }

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


Measured memory_bytes: 256
N, M = map( int, input().split() )


MOD = 1000000007

ans = 0
if abs( N - M ) <= 1: 
    if N == M: ans = ( N + M ) * N
    else:      ans = N * M
    
    while N > 1 and M > 1:
            ans *= ( N - 1 ) * ( M - 1 ) % MOD
            ans %= MOD
            N -= 1
            M -= 1

print( ans )

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


int main(){
    int N;
    cin >> N;
    vector<int> s(N);
    ll sum=0;
    for(int i=0;i<N;i++){
        cin >> s[i];
        sum+= s[i];
    }
    sort(s.begin(),s.end());
    int target =0;
    while(sum%10 ==0&&target<N){
        if(s[target]%10 !=0){
            sum -= s[target];
        }
        target++;
    }
    if(sum%10 ==0){
        cout << 0<<endl;
    }else{
        cout <<sum<<endl;
    }

    return 0;
}

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

int main()
{
    int n; cin >> n;
    int a{0}, w{0}, t{0}, r{0};
    string str;
    for(int i = 0; i < n; i++)
    {
        cin >> str;
        if(str == "AC")
            a++;
        else if(str == "WA")
            w++;
        else if(str == "TLE")
            t++;
        else if(str == "RE")
            r++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll n;
	cin>>n;
	n = n%10;
	if(n==2 || n==4 || n==5 || n==7 || n==9) cout<<"hon\n";
	else if(n==0 || n== 1 || n==6 || n==8) cout<<"pon\n";
	else cout<<"bon\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3652
(defun comb (N)
  (if (> N 1)
      (/ (* N (1- N)) 2) 0 ))

(defvar N (read))
(defvar l (loop :repeat N :collect (read)))

(defvar arr (make-array N :initial-element 0))

(dolist (x l)
  (incf (aref arr (1- x))))

(defvar not-banned
  (reduce (lambda (x y)
                  (+ x (comb y)))
          arr :initial-value 0))

(dolist (x l)
  (princ
   (+ (- not-banned
         (comb (aref arr (1- x))))
      (comb (1- (aref arr (1- x))))))
  (princ #\newline))

Measured memory_bytes: 72160
import java.io.*;
import java.util.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
        String w = input.readLine();
        String t;
        int num = 0;
 
        while (!(t = input.readLine()).equals("END_OF_TEXT")) {
            t = t.toLowerCase();
            Scanner scan = new Scanner(t);
            while (scan.hasNext()) {
                String str = scan.next();
                if (str.equals(w))
                    num++;
            }
 
        }
 
        System.out.println(num);
    }
}

Measured memory_bytes: 19056
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

signed main(){
  int n; cin>>n;
  int ans=n/11;
  if(n%11>6) cout<<2*ans+2<<en;
  else if(n%11==0) cout<<2*ans<<en;
  else cout<<2*ans+1<<en;
}



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

int main(){
  int a, b; cin >> a >> b;
  int mi = min(a,b);
  int mx = max(a,b);

  rep(i,mx){
    cout << mi;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
import collections
import heapq
def main():

    N, M = map(int, input().split())
    graph = collections.defaultdict(dict)
    for _ in range(M):
        a, b, c = map(int, input().split())
        graph[a-1][b-1] = -c

    dist = [float('inf') for _ in range(N)]
    dist[0] = 0
    for _ in range(N-1):
        for a in graph:
            for b in graph[a]:
                dist[b] = min(dist[b], dist[a] + graph[a][b])

    ans = dist[N-1]

    negative = [False for _ in range(N)]
    for _ in range(N):
        for a in graph:
            if dist[a] != float('inf'):
                for b in graph[a]:
                    if dist[b] > dist[a] + graph[a][b]:
                        negative[b] = True
                        dist[b] = dist[a] + graph[a][b]
                    if negative[a] == True:
                        negative[b] = True

    if negative[N-1] == True:
        return "inf"
    else:
        return -ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 52568
import collections
a=raw_input()
trans=[None]*(len(a)+1)
trans[len(a)]=[None]*26
for i, ch in reversed(list(enumerate(a))):
	trans[i]=trans[i+1][:]
	trans[i][ord(ch)-ord('a')]=i+1
q=collections.deque([0])
prev=[None]*(len(a)+1)
prev[0]=-1
try:
	while True:
		cur=q[0]
		q.popleft()
		for i in xrange(26):
			if trans[cur][i]==None:
				result=[chr(ord('a')+i)]
				while cur!=0:
					result.append(a[cur-1])
					cur=prev[cur]
				raise KeyboardInterrupt
			elif prev[trans[cur][i]]==None:
				prev[trans[cur][i]]=cur
				q.append(trans[cur][i])
except KeyboardInterrupt:
	print "".join(reversed(result))

Measured memory_bytes: 120476
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
    int b, f, r, v;;
    int house[5][4][11];
    int i, n;
    
    for (b = 1; b <= 4; b++) {
        for (f = 1; f <= 3; f++) {
            for (r = 1; r <= 10; r++) house[b][f][r] = 0;
        }
    }
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d%d%d%d", &b, &f, &r, &v);
        house[b][f][r] += v;
    }
    
    for (b = 1; b <= 4; b++) {
        for (f = 1; f <= 3; f++) {
            for (r = 1; r <= 10; r++) printf(" %d", house[b][f][r]);
            putchar('\n');
        }
        if (b < 4) puts("####################");
    }
    return 0;
}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
int main(){
    int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    bool flag;
    if( m <= 4 ){
        flag = true;
    }else{
        flag = false;
    }
    if(flag){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

const ll MAXN = 18;
ll n, a[MAXN + 5][2];
ll dp[(1 << 20) + 5][55];
const ll inf = (ll)1e9;

ll rek(int mask, int prev){
	if(!mask)
		return 0;
	ll &ret = dp[mask][prev];
	if(ret != -1)
		return ret;
	ret = inf;
	for(int i = 0 ; i < n ; ++i){
		if(!(mask & (1 << i)))
			continue;
		int cur = n - __builtin_popcount(mask);
		int br = cur - (i - __builtin_popcount(mask & ((1 << i) - 1)));
		//cout << mask << ' ' << cur << ' ' << br << ' ' << i << endl;
		cur = abs(cur - i);
		int sad = a[i][(cur & 1)];
		if(sad >= prev){
			ret = min(ret, rek(mask ^ (1 << i), sad) + br);
		}
	}
	return ret;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 0 ; i < n ; ++i){
	cin >> a[i][0];
}
for(int i = 0 ; i < n ; ++i){
	cin >> a[i][1];
}
memset(dp, -1, sizeof(dp));
ll sol = rek((1 << n) - 1, 0);
if(sol >= inf){
	cout << -1 << endl;
}
else{
	cout << sol << endl;
}

return 0;
}

Measured memory_bytes: 450944
#include<iostream>
#include<cmath>
#define DIM 70000
#define mod 1000000007
using namespace std;
int n, k, i, j, r, nr, st, dr, mid;
int v[DIM], u[DIM], s[105][DIM];
int main(){
    cin>> n >> k;
    r = sqrt(n * 1.0);
    for(i = 1; i <= r + r; i++){
        if(n / i <= r){
            break;
        }
        v[++nr] = i;
    }
    for(i = r; i >= 1; i--){
        v[++nr] = n / i;
    }
    for(i = 1; i <= nr; i++){
        st = 1;
        dr = nr;
        while(st <= dr){
            mid = (st + dr) / 2;
            if(n / v[i] >= v[mid]){
                st = mid + 1;
            }
            else{
                dr = mid - 1;
            }
        }
        u[i] = dr;
        s[1][i] = s[1][i - 1] + v[i] - v[i - 1];
    }
    for(i = 2; i <= k; i++){
        for(j = 1; j <= nr; j++){
            s[i][j] = (s[i][j - 1] + s[i - 1][ u[j] ] * 1LL * (v[j] - v[j - 1]) ) % mod;
        }
    }
    cout<< s[k][nr];
}


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

typedef struct Node {
    int key;
    struct Node *prev, *next;
} node;

node *nil;

// 番兵を示すNILのノードを生成し、prevとnextを番兵につなぐ
void init() {
    nil = (node *)malloc(sizeof(node));
    nil->prev = nil;
    nil->next = nil;
}

// 与えられたキーを持つノードを生成し、それをリストの先頭に追加する
void insert(int key) {
    node *x = (node *)malloc(sizeof(node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

// 与えられたキーを持つノードを探し、そのポインタを返す
node* listSearch(int key) {
    // NILLの次のノードから調べていく
    node *cur = nil->next;
    while(cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

// 指定されたノードtを削除する
void deleteNode(node* t) {
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

// 指定されたキーを持つ要素を削除する
void delete(int key) {
    deleteNode(listSearch(key));
}

// リストの先頭要素を削除する
void deleteFirst() {
    deleteNode(nil->next);
}

// リストの末尾要素を削除する
void deleteLast() {
    deleteNode(nil->prev);
}

// リストの要素をすべて表示する
void printList() {
    int isf=0;
    node *cur = nil->next;
    if(cur == nil) return;
    while(cur != nil) {
        if(isf) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
        isf++;
    }
    printf("\n");
}

int main()
{
    int N, key, i, j, size=0;
    char str[20];
    init();

    scanf("%d", &N);
    for(i=0; i < N; i++){
        scanf("%s", str);
        
        if(str[0] == 'i') {
            scanf("%d", &key);
            insert(key);
            size++;
        } else if(str[0] == 'd' && str[6] == 'F' && size > 0) {
            deleteFirst();
            size--;
        } else if(str[0] == 'd' && str[6] == 'L' && size > 0) {
            deleteLast();
            size--;
        } else if(str[0] == 'd' && size > 0){
            scanf("%d", &key);
            delete(key);
            size--;
        } else {
            continue;
        }
    }

    printList();
    return 0;
}



Measured memory_bytes: 32964
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,a[101010]={},b[101010]={};
	cin>>n;
	FOR(i,0,n)cin>>a[i]>>b[i];
	LL ans=0;
	FORD(i,n,0){
		a[i]+=ans;
		ans+=(a[i]+(b[i]-1))/b[i]*b[i]-a[i];
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
n = input()
k = int(input())
dp = [[0]*(k+1) for _ in range(2)]
dp[0][0] = 1
for i in range(len(n)):
    newdp = [[0]*(k+1) for _ in range(2)]
    for j in range(k+1):
        if n[i]=='0':
            newdp[0][j] = dp[0][j]
            newdp[1][j] = dp[1][j]
            if j>0:
                newdp[1][j] += dp[1][j-1]*9
        else:
            newdp[1][j] = dp[0][j] + dp[1][j]
            if j>0:
                newdp[0][j] = dp[0][j-1]
                newdp[1][j] += dp[0][j-1]*(int(n[i])-1) + dp[1][j-1]*9
    dp = newdp
print(dp[0][k]+dp[1][k])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int>h(n+1);
    for (int i=0;i<n;i++){
        cin>>h.at(i);
    }
    int ans=0;
    for(int i=0;i<n;i++){
    if(h.at(i)>=k)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, n) {cin >> a[i];}
#define readmat(a, n, m) int a[(n) + 1][(m) + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    readb(n, W)
    int v[n+1], w[n+1];

    fori (i, 1, n) cin >> w[i] >> v[i];

    int dp[n + 1][W + 1] = {};

    fori (i, 1, n)
    {
        fori (j, 0, W) 
            if(j - w[i] >= 0) dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j - w[i]]);
            else dp[i][j] = dp[i-1][j];
    }

    print(dp[n][W])

    return 0;
}


Measured memory_bytes: 82360
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String k = sc.next();
        
        int maxIndex = s.length();
        if(Long.parseLong(k) < s.length()){
            maxIndex = Integer.parseInt(k);
        }

        boolean isOne = true;
        int printIndex = 0;
        for(printIndex = 0; printIndex < maxIndex; printIndex++){
            if(s.charAt(printIndex) != ('1')){
                isOne = false;
                break;
            }
        }
        if(isOne){
            System.out.println("1");
        }else{
            System.out.println(s.charAt(printIndex));
        }
    }
}


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

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


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const double PI = acos(-1);

int main2() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;

  double t1 = 2 * PI * (H * 60 + M) / 720;
  double t2 = 2 * PI * M / 60;

  double x1 = A * cos(t1);
  double y1 = A * sin(t1);
  double x2 = B * cos(t2);
  double y2 = B * sin(t2);

  double ans = hypot(x1-x2, y1-y2);
  printf("%.10f\n", ans);

  return 0;
}

int main() {

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

Measured memory_bytes: 4100
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
using namespace std;
typedef long long LL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
const int INF = 0x7fffffff;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 100 + 10;
char s[maxn];
char s2[maxn];
int num[30];
void init() {
    ms(s, 0);
    ms(num, 0);
}
bool allsame(int cnt)
{
    char ju = s2[0];
    int n = strlen(s2) - cnt;
    for(int i = 0;i<n;i++){
        if(s2[i] != ju){
            return false;
        }
    }
    return true;
}
void change(int ch, int cnt)
{
    int tu = ch + 'a';
    int n = strlen(s2) - cnt;
    for(int i = 0;i<n;i++){
        if(s2[i]==tu &&i-1>=0){
            s2[i-1] = tu;
        }
    }
}
void solve() {
    scanf("%s", s);
    int n = strlen(s);
    for(int i = 0;i<n;i++){
        num[s[i]-'a'] = 1;
    }
    int ans = inf;
    for(int i = 0;i<26;i++){
        if(num[i]){
//            printf("%c\n", i+'a');
            strcpy(s2, s);
            int cnt = 0;
            while(1){
                if(allsame(cnt)){
                    ans = min(cnt, ans);
                    break;
                }
                cnt++;
                change(i, cnt);
            }
        }
    }
    printf("%d\n", ans);
}
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
#endif
    init();
    solve();
    return 0;
}


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

const int mxN = 1e7 + 6;
int cnt[mxN];

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)
		for(int j = i; j < mxN; j += i)
			++cnt[j];
	long long answer = 0;
	for(long long i = 1; i <= n; ++i) {
		answer += (i * cnt[i]); 
	}
	cout << answer;
}


Measured memory_bytes: 42668
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int mod=1000000007 ;

void solve(){
	
	int n  ;
	cin>> n ;
	double ans=4*acos(0.0)*(double)n ;
	cout<<ans ;
	
}


int main(){

	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3784
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            String a = Console.ReadLine();

            // スペース区切りの整数の入力
            int D = int.Parse(a.Split(' ')[0]);
            int Tani = (int)(Math.Pow(100, D));
            int N = int.Parse(a.Split(' ')[1]);

            // 100の倍数はSkipする
            N += N / 100;

            int result = Tani * N;

            //出力
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;
 
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
 
	static class TaskD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			if (n % 2 == 1) {
				out.println("First");
				return;
			}
			List<Integer>[] adj = new List[n];
			for (int i = 0; i < n; i++) {
				adj[i] = new ArrayList<>();
			}
			for (int i = 0; i < n - 1; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				adj[a].add(b);
				adj[b].add(a);
			}
			int[] adjLeaves = new int[n];
			for (int i = 0; i < n; i++) {
				for (int j : adj[i]) {
					if (adj[j].size() == 1) {
						++adjLeaves[i];
					}
				}
				if (adjLeaves[i] >= 2) {
					out.println("First");
					return;
				}
			}
			for (int i = 0; i < n; i++) {
				if (adj[i].size() == 1) {
					continue;
				}
				int bad = 0;
				for (int j : adj[i]) {
					if (adjLeaves[j] > 0) {
						++bad;
					}
				}
				if (bad == adj[i].size()) {
					out.println("First");
					return;
				}
			}
			out.println("Second");
		}
 
	}
 
	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;
 
		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}
 
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(next());
		}
 
	}
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) V vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int r,d,x;
  cin>>r>>d>>x;
  rep(i,10){
    int res=r*x-d;
    cout<<res<<endl;
    x=res;
  }  
  
  
  return 0;
}



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

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int[] data = new int[10];
		for(int i=0;i<10;i++){
			data[i] = stdIn.nextInt();
		}
		
		Arrays.sort(data);
		
		for(int i=data.length-1;i>=data.length-3;i--){
			System.out.println(data[i]);
		}
	}
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1000003;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll N_MAX = 3000005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll powLL(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res *= a;
            res %= mod;
        }
        a = a*a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

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

    ll Q;
    cin >> Q;
    while(Q--){
    	ll x, d, n;
    	cin >> x >> d >> n;
    	ll dn = powLL(d, n);
    	if(d==0||x==0){
    		cout << powLL(x, n) << endl;
    		continue;
    	}
    	if(n>=mod){
    		cout << 0 << endl;
    		continue;
    	}
    	ll invx = x * inv[d] % mod;
    	if(invx/mod != (invx+n-1)/mod){
    		cout << 0 << endl;
    		continue;
    	}
    	ll res = dn * fac[invx+n-1] % mod;
    	res *= finv[invx-1];
    	res %= mod;
    	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 71168
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;

template<typename T = long long>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }

// value
int A, B;

void solve() {

	cin >> A >> B;

	if ((A + B) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
		return;
	}

	cout << (A + B) / 2 << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


Measured memory_bytes: 256
# import doctest


def solve(N, abc):
    """
    >>> solve(3, [(10, 40, 70), (20, 50, 80), (30, 60, 90)])
    210
    """
    # dp[i][j] = i日目にjの活動を選んだ時の幸福度総和の最大値
    # 本日の活動を幸福度が高い順にx, y, zとして、
    # dp[i][j] = max(dp[i - 1][y] + x, dp[i - 1][z] + x, dp[i - 1][x] + y, dp[i - 1][z] + y)
    dp = [[None, None, None] for _ in range(N + 1)]
    a1, b1, c1 = abc[0]
    # a, b, c を 0, 1, 2と読み替える
    dp[1][0] = a1
    dp[1][1] = b1
    dp[1][2] = c1
    for i in range(2, N + 1):
        a, b, c = abc[i - 1]
        dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a)  # aを選ぶとき
        dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b)  # bを選ぶとき
        dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c)  # cを選ぶとき
    return max(dp[N][0], dp[N][1], dp[N][2])


# doctest.testmod()
N = int(input())
abc = [tuple(map(int, input().split())) for _ in range(N)]
print(solve(N, abc))


Measured memory_bytes: 40224
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            amount = 500 * ai + 100 * bi + 50 * ci
            if amount == x:
                ans += 1

print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)

	A := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&A[i])
	}

	fmt.Println(answerABC161B(n, m, A))
}

func answerABC161B(n int, m int, A []int) string {
	var amountVotes int
	for _, vote := range A {
		amountVotes += vote
	}

	var passedItemCount int
	var threshold = 1 / (4 * float64(m))

	for _, vote := range A {
		voteRate := float64(vote) / float64(amountVotes)

		if voteRate >= threshold {
			passedItemCount++
		}
	}

	if passedItemCount >= m {
		return "Yes"
	} else {
		return "No"
	}

}


Measured memory_bytes: 1840
check :: String -> Int
check []           = 0
check [x]          = 0
check ('P':'D':cs) = 1 + check ('D':cs)
check ('D':cs)     = 1 + check cs
check (x:xs)       = check xs


main :: IO ()
main = do
  str <- getLine
  putStrLn $ map (\x -> if x == '?' then 'D' else x) str


Measured memory_bytes: 11840
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<ll, int> ll_i;
struct edge { int u, v; ll w; };

ll gcd(ll a, ll b) {
	if (b == 0) return abs(a);
	else return gcd(b, a % b);
}

int main() {
	ll a, b;
	while (cin >> a >> b) {
		ll x = gcd(a, b);
		cout << x << " " << a * b / x << endl;
	}
}

Measured memory_bytes: 1156
def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int, ss_raw())

INF = 1 << 29
DIV = 10**9 +7
N,X  = ints_raw()
dp = [{} for x in xrange(X+1)]

Ss = ints_raw()

Ss.sort()


def rec(n,idx):
    if idx == 0:
        return n%Ss[0]
    elif idx in dp[n]:
        return dp[n][idx]
    else:
        ans = (rec(n,idx-1)*idx + rec(n%Ss[idx],idx-1))%DIV
        dp[n][idx]=ans
        return ans

def ans():
    return rec(X,N-1)

print ans()


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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;

#define sz(a) ((ll)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator

#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a, n)  \
    fo(n) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)

typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }

const ll INF = 0xFFFFFFFFFFFFFFFL;;
const ll N = 1e9 + 7;
void swap1(ll a,ll b){
    ll temp;
    temp=a;
    a=b;
    b=temp;
}
void solve()
{
char a;
cin>>a;
if(a>='a' && a<='z')cout<<'a';
else cout<<'A';

}



int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/

    ll t;
   // cin >> t;
    t=1;
   while (t--)
        solve();

    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b;
    if (b == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == n-1) {
      cout << "Three" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
//解説AC

//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

ll dp[110][10];

int
main(void){  
  ios_base::sync_with_stdio(false);

  int h, w, k;

  cin >> h >> w >> k;

  //if(w == 1){ cout << "1" << endl; return 0;}
  dp[0][0] = 1;
  
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      for(int bit=0; bit < 1 << (w-1); bit++){
	int ok = true;  
	for(int l=0; l<w-2; l++){
	  if( (bit >> l & 1) == 1 && (bit >> (l+1) & 1) == 1 ){
	    //cout << "bit:" << bit << " l:" << l << " false" << endl;
	    ok = false;
	  }
	}
	if(ok){
	  if(j >= 1 && (bit >> j-1 & 1) == 1){
	    dp[i+1][j-1] += dp[i][j];
	    dp[i+1][j-1] %= MOD;
	  }
	  else if( j <= w-2 && (bit >> j & 1) == 1){
	    dp[i+1][j+1] += dp[i][j];
	    dp[i+1][j+1] %= MOD;
	  }
	  else{
	    dp[i+1][j] += dp[i][j];
	    dp[i+1][j] %= MOD;
	  }
	}
      }
    }
  }

  cout << dp[h][k-1] << endl;

  
  return 0;
}


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

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

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

const long long INF = 1LL << 60;
long long weight[110], value[110];

long long dp[110][100010] = {0};

int main()
{
  int N, W;
  cin >> N >> W;
  for (int i = 0; i < N; i++)
  {
    cin >> weight[i] >> value[i];
  }

  for (int i = 0; i < N; i++)
  {
    for (int sum_w = 0; sum_w <= W; sum_w++)
    {

      // i番目の品物を選ぶ場合
      if (sum_w - weight[i] >= 0)
      {
        chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }

      // i番目の品物を選ばない場合
      chmax(dp[i + 1][sum_w], dp[i][sum_w]);
    }
  }

  cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ans = 1;
    for (int i = 1; i * i <= N; i++) {
      ans = i * i;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 25428
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

use std::cmp::max;

fn main() {
    let (a, b) = parse_pair::<isize, isize>();

     println(max(a * b, max(a + b, a - b)));
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

#define int long long

const int N = 200005;

int n, d, a;
vector < pair <int, int> > vec;
multiset <int> ms;
map <int, int> id;
int cnt;

int st[4 * N];
int lazy[4 * N];

int left(int x) {
  return (x << 1);
}

int right(int x) {
  return (x << 1) + 1;
}

void update(int p, int L, int R, int i, int j, int val) {
  if (lazy[p]) {
    st[p] += lazy[p];
    if (L != R) {
      lazy[left(p)] += lazy[p];
      lazy[right(p)] += lazy[p];
    }
    lazy[p] = 0;
  }
  if (L > j || R < i) return;
  if (i <= L && R <= j) {
    st[p] += val;
    if (L != R) {
      lazy[left(p)] += val;
      lazy[right(p)] += val;
    }
    return;
  }
  int mid = (L + R) >> 1;
  update(left(p), L, mid, i, j, val);
  update(right(p), mid + 1, R, i, j, val);
  st[p] = st[left(p)] + st[right(p)];
}

int query(int p, int L, int R, int i, int j) {
  if (lazy[p]) {
    st[p] += lazy[p];
    if (L != R) {
      lazy[left(p)] += lazy[p];
      lazy[right(p)] += lazy[p];
    }
    lazy[p] = 0;
  }
  if (L > j || R < i) return 0;
  if (i <= L && R <= j) {
    return st[p];
  }
  int mid = (L + R) >> 1;
  int x = query(left(p), L, mid, i, j);
  int y = query(right(p), mid + 1, R, i, j);
  return x + y;
}

int32_t main() {
  cin >> n >> d >> a;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    vec.push_back({x, y});
    ms.insert(x);
  }
  vec.push_back({(int) 2e9 + 5, 0});
  ms.insert((int) 2e9 + 5);
  sort(vec.begin(), vec.end());
  for (int i = 0; i < vec.size(); i++) {
    if (!id[vec[i].first]) {
      id[vec[i].first] = ++cnt;
    }
  }
  for (int i = 0; i < vec.size(); i++) {
    int idx = id[vec[i].first];
    update(1, 1, N - 1, idx, idx, vec[i].second);
  }
  int ans = 0;
  for (int i = 0; i < vec.size(); i++) {
    int idx = id[vec[i].first];
    int here = query(1, 1, N - 1, idx, idx);
    if (here <= 0) continue;
    int bombs = (here + a - 1) / a;
    int dmg = bombs * a;
    ans += bombs;
    auto it = ms.upper_bound(vec[i].first + 2 * d); it--;
    int r = id[*it];
    update(1, 1, N - 1, idx, r, -dmg);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 37996
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  char str[21];
  int i=0;
  cin>>str;
  while(1){
	  if(str[i]=='\0'){
		  break;
	  }
	  i++;
  }
  for(i>0;i--;){
	  cout<<str[i];
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 3068
$drc = [[0, 1], [0, -1], [1, 0], [-1, 0]]
def dfs(y, x, d, n)
  return true if n == $max
  $fld[y][x] = false
  4.times do |i|
    next if i == 'UDLR'.index(d)
    ny, nx = y, x
    loop do
      nx += $drc[i][0]; ny += $drc[i][1]
      break if $fld[ny][nx].nil?
      if $fld[ny][nx]
        $ans[n] = 'DURL'[i]
        return true if dfs(ny, nx, 'DURL'[i], n + 1)
        break
      end
    end
  end
  $fld[y][x] = true
  false
end


sx = sy = 0; d = ''
r, c = gets.split.map(&:to_i)
$fld = r.times.map{ [] }
r.times.each do |y|
  l = gets.chomp.split('')
  l.each do |a|
    if a != '.' && a != 'o'
      sx = l.index(a) + 1
      sy = y + 1
      d = a
    end
  end
  $fld[y] = [nil, *l.map{ |a| a == '.' ? false : true }, nil]
end
$fld = [[nil] * (c + 2), *$fld, [nil] * (c + 2)]
$max = $fld.flatten.count(true) - 1
$ans = ['x'] * $max
dfs(sy, sx, d, 0)
puts $ans.join

Measured memory_bytes: 8908