akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fa(i, a, b) for (auto (i) = (a); (i) < (b); ++(i))
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m,n,x,a,b;
   string s;

   cin>>n;
   cout<<n*(n+1)/2<<endl;
   return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    double t,x;
    cin >> t >> x;
    double ans = t/x;
    cout << ans << endl;
}

Measured memory_bytes: 3764
x, y, z, K = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse = True)
b = sorted(list(map(int, input().split())), reverse = True)
c = sorted(list(map(int, input().split())), reverse = True)
lst = []

for i in range(len(a)):
    for j in range(len(b)):
        for k in range(len(c)):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            lst.append(a[i] + b[j] + c[k])

new_lst = sorted(lst, reverse = True)
for i in range(K):
    print(new_lst[i])


Measured memory_bytes: 9548
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#define MN 100
#define D 20
#define mod 998244353
#define ull unsigned long long
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
struct Bit
{
	ull a,b;
	Bit operator >> (int s)
	{
		if(s>=64) return (Bit){b>>s-64,0};
		else return (Bit){(a>>s)|(b<<64-s),b>>s}; 	
	}
	void Cut(int s){s>=64?b&=((1ULL<<s-64)-1):(b=0,a&=((1ULL<<s)-1));}
	void Mod(int s){s>=64?b^=1ULL<<s-64:a^=1ULL<<s;}
	void operator &=(ull s){a&=s;}
	bool operator < (const Bit&y)const{return a==y.a?b<y.b:a<y.a;} 
}pre;
int n,f[D+1][1<<D],g[D+1][1<<D];
char s[MN+5];
map<Bit,int> mp[2][105];
int Calc(int len,int r,Bit s)
{
	s.Cut(len);
	if(len<=D) return r?f[len][s.a]:g[len][s.a];
	if(mp[r][len].count(s)) return mp[r][len][s];	
	int res=0;
	if(r) for(int j=1;j<len;++j) res=(res+1LL*Calc(j,0,s)*Calc(len-j,1,s>>j))%mod;
	for(int j=2;j<=len;++j) if(len%j==0)
	{
		int l=len/j;Bit S,t=s;S.a=(ull)-1;S.b=0;
		for(int k=1;k<=j;++k) S.a&=(t.a&((1ULL<<l)-1)),t=t>>l;
		res=(res+Calc(l,1,S))%mod;
	}
	return mp[r][len][s]=res;
}

int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	f[1][0]=g[1][0]=1;f[1][1]=g[1][1]=2;
	for(int i=2;i<=D;++i)
		for(int j=0;j<1<<i;++j)
		{
			for(int k=1;k<i;++k) f[i][j]=(f[i][j]+1LL*g[k][j&((1<<k)-1)]*f[i-k][j>>k])%mod;
			for(int k=2;k<=i;++k) if(i%k==0)
			{
				int l=i/k,res=(1<<i)-1;
				for(int t=1,S=j;t<=k;++t) res&=S&((1<<l)-1),S>>=l;
				g[i][j]=(g[i][j]+f[l][res])%mod;
				f[i][j]=(f[i][j]+f[l][res])%mod;
			}
		}
	for(int i=1;i<=n;++i) if(s[i]=='1') pre.Mod(i-1);
	printf("%d\n",Calc(n,1,pre));
	return 0;
}



Measured memory_bytes: 94208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;
const double PI = acos(-1);

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long gcd(long long a, long long b) {
  if(a % b == 0) return b;
  else return gcd(b, a % b);
}
int main() {
  string s;
  cin >> s;
  bool reversed = false;
  string former, latter;
  int q;
  cin >> q;
  rep(i, q) {
    int r;
    cin >> r;
    if(r == 1) reversed = 1 - reversed;
    else {
      int f;
      char c;
      cin >> f >> c;
      if(!reversed) {
        if(f == 1) former += c;
        else latter += c;
      } else {
        if(f == 1) latter += c;
        else former += c;
      }
    }
  }
  if(reversed) {
    reverse(latter.begin(), latter.end());
    reverse(s.begin(), s.end());
    cout << latter << s << former << endl;
  }
  else {
    reverse(former.begin(), former.end());
    cout << former << s << latter << endl;
  }
 } 


Measured memory_bytes: 1088
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int w, h, n;
    cin >> w >> h >> n;

    int l = 0, r = w, d = 0, u = h;
    rep (i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) l = max(l, x);
        if (a == 2) r = min(r, x);
        if (a == 3) d = max(d, y);
        if (a == 4) u = min(u, y);
    }

    cout << (u - d <= 0 || r - l <= 0 ? 0 : (u - d) * (r - l)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	cout << 'A' << s[1][0] << 'C' << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
	vector <int> a,b;
	int x,y;
	do{
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}while(x || y);
	
	for(int t=0;t< a.size()-1;t++){
		for (int i=0;i<a.at(t);i++){
			for (int j=0;j<b.at(t);j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3080
N,D=map(int,input().split())
S=[0]*N;cnt=0;z=0
for i in range(N):
  x,y=map(int,input().split())
  S[i]=[x,y]

#print(S)
for i in range(N):
  if D>=(S[i][0]**2+S[i][1]**2)**0.5:
    cnt=cnt+1
print(cnt)

Measured memory_bytes: 39360
#include <stdio.h>
#include <iostream>

#include <algorithm>
#include <cmath>

#include <vector>
#include <list>
#include <string>

using namespace std;


int main() {
  int A, B;

  scanf("%d", &A);
  scanf("%d", &B);

  int ans = A * B - (A * 1 + B * 1 - 1 * 1);

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

  return 0;
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

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


int main()
{
    int n;
    cin >> n;
    set<string> S;
    while(n--) {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << sz(S);
}


Measured memory_bytes: 19152
N, X, Y = map(int, input().split())

ans = [0] * N

for a in range(1, N+1):
    for b in range(a+1, N+1):
        t = b - a
        t2 = abs(X-a) + abs(Y-b) + 1
        t = t if t < t2 else t2
        ans[t] += 1

for i in range(1, N):
    print(ans[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define Max(xx,yy) (xx > yy ? xx : yy)
#define Min(xx,yy) (xx < yy ? xx : yy)
#define all(v) v.begin(),v.end();

template<typename... T>
void dbg(T... args) {
	#ifdef Local
    	((cout << args << " "), ...) << '\n';
    #endif
}

template<typename... T>
void print(T... args) {
    ((cout << args << " "), ...) << '\n';
}

namespace data{
    const long long n = 2 * 1e5 + 7;	
    const long long m = 0 + 7;
    const long long mod = 0;
    const long long INF = 0;
}


int main(){    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);

    #ifdef Local
    	for(int i = 1;i <= 51;i++) cout << "*\n"[i == 51];
    	cout << "Running on Halit's Computer, Good Luck Halit\n";
    	for(int i = 1;i <= 51;i++) cout << "*\n"[i == 51];
    #endif	

    long long a,b;
	cin >> a >> b;
	if(a > b)
		cout << "safe";
	else 
		cout << "unsafe";

}	


Measured memory_bytes: 3640
#!/usr/bin/env python3

def main():
    N, D = map(int, input().split())
    xy = [list(map(int, input().split())) for i in range(N)]
    ans = 0
    for i in range(N):
        d = xy[i][0]**2 + xy[i][1]**2
        if D**2 >= d:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 45328
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = [input() for i in range(n)]

a = 0
b = 0
ab = 0
c = 0
for x in s:
    ab += x.count("AB")
    if x[0] == 'B' and x[-1] == 'A':
        c += 1
    elif x[0] == 'B':
        b += 1
    elif x[-1] == 'A':
        a += 1
    
print( ab + max(c-1, 0) + min(a, b) + (1 if a + b != 0 and c > 0 else 0))

Measured memory_bytes: 10532
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

//#define _DEBUG_ 3
void run() {
	int N, M;
	cin >> N >> M;

	vector<int> a(M + 1), b(M + 1);
	vector<ll>  c(M + 1);

	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	ll inf = numeric_limits<ll>::max() / 8;
	vector<ll> dist(N + 1, inf);
	vector<bool> vis(N + 1, false);
	dist[1] = 0;
	bool negCycle = false;
	for (int i = 0; i < 2 * N; i++) {
		bool update = false;
		for (int j = 0; j < M; j++) {
			if (dist[a[j]] != inf && dist[b[j]] > dist[a[j]] - c[j]) {
				dist[b[j]] = dist[a[j]] - c[j];
				if(i >= N) vis[b[j]] = true;
				update = true;
			}
		}
		if (!update) break;
	}

	if (vis[N]) cout << "inf" << endl;
	else cout << -dist[N] << endl;
}

int main() {
#ifdef _DEBUG_
	using std::chrono::system_clock;
	using std::chrono::duration_cast;
	system_clock::time_point  start, end;
	std::ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	for (int i = 0; i < _DEBUG_; i++) {
		cout << "-------------------------- (cnt:" << i << ")" << endl;
		start = system_clock::now();
		run();
		end = system_clock::now();
		int elapsed = duration_cast<std::chrono::milliseconds>(end - start).count();
		cout << "-------------------------- (time:" << elapsed << "ms)" << endl << endl;
	}
#else
	run();
#endif
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	char s[101];
	char t[101];

	scanf("%d", &n);
	scanf("%s", &s);
	scanf("%s", &t);

	char result[201];

	int a, as, at;
	for(a = 0, as = 0, at = 0; a < (n * 2); ++a){
		if(a % 2 == 0){
			result[a] = s[as];
			++as;
		}
		else if(a % 2 == 1){
			result[a] = t[at];
			++at;
		}
	}
	result[a] = '\0';
	printf("%s\n", result);
	return 0;
}

Measured memory_bytes: 128
h,w=map(int,input().split())
s=[input() for _ in range(h)]
d=dict(zip([chr(i+97) for i in range(26)],[0]*26))
for i in range(h):
  for j in range(w):
    d[s[i][j]]+=1
a=[i%4 for i in d.values()]
print(['No','Yes'][a.count(1)+a.count(3)==h%2*w%2 and a.count(2)<=(h//2)*(w%2)+(w//2)*(h%2)])

Measured memory_bytes: 65140
// atcoder/abc168/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);



  int n;
  while (cin >> n) {
    n %= 10;
    if (n == 3) cout << "bon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
  }


  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(void){
    int x,y,z;
    z=0;
    x=0;
    while(1){
        x=x+1;
        while(1){
            z=z+1;
            y=x*z;
            cout<<x<<"x"<<z<<"="<<y<<endl;
            if(z>=9){
                break;
            }
        }
        z=0;
        if(x>=9){
            break;
        }
    }
    
}



Measured memory_bytes: 3052
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

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

    while (n >= 1) {
        if (n % 10 == 7) {
            cout << "Yes";
            return 0;
        }
        else {
            n /= 10;
        }
    }
    cout << "No";

    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

class Dice{
public:

	Dice(){
		number = new int[6];
		work = new int[6];
	};
	~Dice(){
		delete[] number;
		delete[] work;
	};

	void setLabel(int index, int num){
		number[index]=num;
	}

	void roll(char dir){
		for(int i=0; i<6; i++) work[i]=number[i];
		switch(dir){
			case 'E':
				setNumber(work[3], work[1], work[0], work[5], work[4], work[2]);
				break;
			case 'N':
				setNumber(work[1], work[5], work[2], work[3], work[0], work[4]);
				break;
			case 'S':
				setNumber(work[4], work[0], work[2], work[3], work[5], work[1]);
				break;
			case 'W':
				setNumber(work[2], work[1], work[5], work[0], work[4], work[3]);
				break;
		}
	}

	int returnPeak(){
		return number[0];
	}

private:
	void setNumber(int n0, int n1, int n2, int n3, int n4, int n5){
		number[0]=n0;
		number[1]=n1;
		number[2]=n2;
		number[3]=n3;
		number[4]=n4;
		number[5]=n5;
	}

private:
	int *number;
	int *work;

};




int main(){
	Dice dice;
	int label;
	char ch;
	for(int i=0; i<6; i++){
		scanf("%d", &label);
		dice.setLabel(i,label);
	}
	getchar();
	while((ch=getchar())!='\n'){
		dice.roll(ch);
	}
	printf("%d\n", dice.returnPeak());

}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

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

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

    ll comfort = 0, tmp;
    queue<ll> Q;
    Q.push(A[0]);
    for (ll i = 1; i < n; i++)
    {
        tmp = Q.front();
        Q.pop();
        comfort += tmp;
        Q.push(A[i]);
        Q.push(A[i]);
    }
    cout << comfort << endl;
}

Measured memory_bytes: 6344
#include <stdio.h>

int main(void){
	long long int x, y;
	int i = 1;

	scanf("%lld %lld", &x, &y);

	while (x <= y){
		x *= 2;
		if (x > y){
			printf("%d\n", i);
			return 0;
		}
		i++;
	}

	return 0;
}


Measured memory_bytes: 128
n = int(input())
s = input()
t = list()
a = ["A", "B", "C", "D", "E", "F", "G",
     "H", "I", "J", "K", "L", "M", "N",
     "O", "P", "Q", "R", "S", "T", "U",
     "V", "W", "X", "Y", "Z"]
b = 0
for i in range(len(s)):
    for j in range(26):
        if s[i] == a[j]:
            b = (j + n)
            if b >= 26:
                print(a[b - 26], end = "")
            else:
                print(a[b], end = "")
            break
print()


Measured memory_bytes: 4468
#include <sstream>
#include <iostream>
#include <string>
using namespace std;
string nums;

void operation() {
	char c = nums[0];
	int cnt = 1;
	ostringstream next;
	for (int i = 1; i < nums.size(); i++) {
		if (nums[i] == c) cnt++;
		else {
			next << cnt << c;
			c = nums[i];
			cnt = 1;
		}
	}
	next << cnt << c;
	nums = next.str();
}

int main () {
	int n;
	while (cin >> n, n) {
		cin >> nums;
		for (; n; n--) {
			operation();
		}
		cout << nums << endl;
	}
	return 0;
}

Measured memory_bytes: 1380
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int d,n,i,i1,c=0,c1=0;
	cin>>d>>n;
	f(i,1,2000005){
		i1=i;
		c=0;
		while(i1>0){
			if(i1%100){
				break;
			}
			else{
				i1/=100;
				c++;
			}
		}
		if(c==d){
			c1++;
		}
		//cout<<c1<<endl;
		if(c1==n){
			cout<<i<<endl;
			return 0;
		}
	}	
} 
	

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)
s1=s/(4*m)
c=0
for i in a:
    if(i>=s1):
        c+=1
if(c>=m):
    print('Yes')
else:
    print('No')
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

struct UF{
  vector<int>p; //p[i]=$B%N!<%I(Bi$B$N?F(B
  vector<int>r; //rank[i]=$B%N!<%I(Bi$B$N%i%s%/(B
  UF(int sz){
    r.resize(sz,1);
    p.resize(sz);
    for(int i=0;i<sz;i++)p[i]=i;
  }
  void u(int x,int y){ //1
    if(isu(x,y))return;
    x=root(x);
    y=root(y);
    if(r[x]>r[y])p[y]=x,r[x]+=r[y];
    else p[x]=y,r[y]+=r[x];
  }
  int root(int x){
    if(p[x]==x)return x;
    return root(x=p[x]);
  }
  bool isu(int x,int y){ //2
    return root(x)==root(y);
  }
  int size(int x){
    return r[root(x)];
  }
};

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

  int N,M,K;
  cin>>N>>M>>K;
  vector<int>A(M),B(M);
  for(int i=0;i<M;i++)cin>>A[i]>>B[i];
  for(int i=0;i<M;i++)A[i]--,B[i]--;
  vector<int>C(K),D(K);
  for(int i=0;i<K;i++)cin>>C[i]>>D[i];
  for(int i=0;i<K;i++)C[i]--,D[i]--;
  map<int,int>m;
  for(int i=0;i<M;i++)m[A[i]]++,m[B[i]]++;
  UF uf(N);
  for(int i=0;i<M;i++){
    uf.u(A[i],B[i]);
  }
  for(int i=0;i<K;i++)if(uf.isu(C[i],D[i]))m[C[i]]++,m[D[i]]++;
  vector<int>ans(N);
  for(int i=0;i<N;i++){
    cout<<max(uf.size(i)-1-m[i],0)<<" ";
  }
  return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include<stdio.h>
using namespace std;
struct Card{char c;int value;};
void BubbleSort(struct Card A[],int n){
    struct Card t;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(A[j].value<A[j-1].value){
                t = A[j];
                A[j] = A[j-1];
                A[j-1] = t;
            }
        }
    }
}
void SelectionSort(struct Card A[],int n){
    int min;
    struct Card t;
    for(int i=0;i<n;i++){
        min = i;
        for(int j=i;j<n;j++){
            if(A[j].value<A[min].value){
                min = j;
            }
        }
        t = A[i];
        A[i] = A[min];
        A[min] = t; 
    }
}
void isStable(struct Card A[],struct Card B[],int n){
    for(int i=0;i<n;i++){
        if(A[i].c != B[i].c){
            printf("Not stable\n");
            return;
        }
    }
    printf("Stable\n");
}
void print(struct Card A[],int n){
    for(int i=0;i<n;i++){
        if(i>0) cout << " ";
        cout << A[i].c << A[i].value;
    }
    cout << endl;
}
int main(){
    int n;
    cin >> n;
    struct Card c1[n],c2[n];
    for(int i=0;i<n;i++){
        cin >> c1[i].c >> c1[i].value;
    }
    for(int i=0;i<n;i++) c2[i] = c1[i];
    BubbleSort(c1,n);
    SelectionSort(c2,n);
    print(c1,n);
    isStable(c1,c1,n);
    print(c2,n);
    isStable(c1,c2,n);
}


Measured memory_bytes: 3108
class Dice3():

    def __init__(self, v): # v [Top, Front, Right, Left, Back, Bottom ]
        self.view = v
        self.dTFRstr = {}
        for i, j, k in ((ii, (ii++2)%6, (ii+4)%6) for ii in  range(6)):
            self.dTFRstr[self.view[i]]=''.join([self.view[v] for v in (j, k, 5-j, 5-k, j)])


d3, d = Dice3(input().split()), input().split()
if ''.join(d[1:3]) in d3.dTFRstr[d[0]] :
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int N=2e5+5;
int n,m,a[N],b[N],tree[4*N],tree2[4*N],lazy[4*N];
ll ans;
void initseg(int nd,int l,int r)
{
    if(l==r){ tree[nd]=b[l]; tree2[nd]=l; return; }
    int m=(l+r)/2;
    initseg(nd*2,l,m);
    initseg(nd*2+1,m+1,r);
    tree[nd]=b[l];
    tree2[nd]=l;
}
void pushdown(int nd,int l,int r)
{
    if(l!=r){
        lazy[nd*2]+=lazy[nd];
        lazy[nd*2+1]+=lazy[nd];
    }
    tree[nd]+=lazy[nd];
    lazy[nd]=0;
}
P query(int nd,int l,int r,int s,int e)
{
    if(r<s||e<l) return P(2e9,0);
    pushdown(nd,l,r);
    if(s<=l&&r<=e) return P(tree[nd],tree2[nd]);
    int m=(l+r)/2;
    return min(query(nd*2,l,m,s,e),query(nd*2+1,m+1,r,s,e));
}
void update(int nd,int l,int r,int s,int e)
{
    if(r<s||e<l) return;
    pushdown(nd,l,r);
    if(s<=l&&r<=e){
        lazy[nd]++;
        pushdown(nd,l,r);
        return;
    }
    int m=(l+r)/2;
    update(nd*2,l,m,s,e);
    update(nd*2+1,m+1,r,s,e);
    tree[nd]=min(tree[nd*2],tree[nd*2+1]);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){ cin>>a[i]; b[i]=a[i]; }
    sort(b+1,b+1+n);
    m=unique(b+1,b+1+n)-b-1;
    initseg(1,1,m);
    for(int i=1;i<=n;i++){
        int plc=lower_bound(b+1,b+1+m,a[i])-b;
        P tp=query(1,1,m,plc,m);
        ans+=(ll)tp.first-a[i];
        if(tp.second==1) continue;
        update(1,1,m,1,tp.second-1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11264
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	
    int a,b ;    
    cin >> a >> b;
   int ans ;
   if(a+b>a-b){
     if(a+b>a*b){
       ans =a+b ;
     }else{
       ans =a*b ;
     }
   }else{
     if(a-b>a*b){
       ans = a-b ;
     }else{
       ans = a*b ;
     }
   }
  
    cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int ans = 0;
	sort(a, a + 3, greater<int>());
	if ((a[0] - a[1]) % 2) {
		ans = ans + (a[0] - a[1]) / 2 + 1;
		a[2]++;
	}
	else {
		ans = ans + (a[0] - a[1]) / 2;
	}
	if ((a[0] - a[2]) % 2) {
		ans = ans + (a[0] - a[2]) / 2 + 2;
	}
	else {
		ans = ans + (a[0] - a[2]) / 2;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<string,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n; cin >> n;
    map<string, int> mp;
    int mx = 0;
    vector<string> s(n);
    rep(i,n) cin >> s[i];

    rep(i,n) {
        auto itr = mp.find(s[i]);
        if (itr==mp.end()) mp.insert(P(s[i],1));
        else ++mp[s[i]];
        mx = max(mx,mp[s[i]]);
    }
    priority_queue<string, vector<string>, greater<string> > que;
    set<string> done;
    rep(i,n) {
        if (mx == mp[s[i]] && done.find(s[i])==done.end()) que.push(s[i]);
        done.insert(s[i]);
    }
    while(!que.empty()) {
        string si = que.top();
        cout << si << endl;
        que.pop();
    }
    return 0;
}



























Measured memory_bytes: 37744
// finish date: 2018/10/08

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

//素因数分解
map<int, int> p_fact(int n) {
    map<int, int> mp;
    int i = 2;
    while (n >= i * i) {
        while (n % i == 0) mp[i]++, n /= i;
        i++;
    }
    if (n != 1) mp[n]++;
    return mp;
}

map<int, int> mp;
int N, M;
int ans = 1;

void dfs(map<int, int>::iterator itr, int temp = 1) {
    if (itr == mp.end()) {
        if (M % temp == 0 && M / temp >= N) ans = max(ans, temp);
        return;
    }
    rep(i, itr->second + 1) {
        dfs(next(itr), temp * (int) (round(pow(itr->first, i))));
    }
}

int main() {
    cin >> N >> M;
    mp = p_fact(M);
    dfs(mp.begin());
    cout << ans << endl;
    return 0;
}



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

#define NAME "K - Stones"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 1e5;
int arr[maxn];
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    int n,k;
    cin>>n>>k;

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

    vector <bool> dp(k+1);
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++)
            if(i>=arr[j] && !dp[i-arr[j]]) dp[i] = 1;
    }
    
    if(dp[k])
        cout<<"First\n";
    else
        cout<<"Second\n";
}


Measured memory_bytes: 3592
def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret

def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

A, B = map(int, input().split())
N = gcd(A, B)
pf = primeFactor(N)

print(len(pf)+1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define sz(x) (int)x.size()
#define el '\n'
#define M 998244353
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin>>s;
  int n=s.size();
  string tmp1=s;
  int cnt1=0,cnt2=0;
  for(int i=0;i<n;i++){
      if(i%2==0){
          if(s[i]=='1')cnt1++,s[i]='0';
      }
      else{
          if(s[i]=='0')cnt1++,s[i]='1';
      }
  }
  s=tmp1;
   for(int i=0;i<n;i++){
      if(i%2==1){
          if(s[i]=='1')cnt2++,s[i]='0';
      }
      else{
          if(s[i]=='0')cnt2++,s[i]='1';
      }
  }
  cout<<min(cnt1,cnt2)<<el;
  return 0;
}


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

int main()
{
    vector<int> a(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> a.at(i);
        if (a.at(i) == 0)
        {
            cout << i + 1 << endl;
            break;
        }
    }

    return 0;
}

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

using namespace std;

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	//0 J, 1 O, 2 I, 3 JO, 4 OI, 5 JI, 6 JOI
	vector< vector<int> > dp(7, vector<int>(n+1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'J') {
			dp[0][i+1] += (dp[0][i]+dp[3][i]+dp[5][i]+dp[6][i])%10007;
			dp[3][i+1] += (dp[0][i]+dp[1][i]+dp[3][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
			dp[5][i+1] += (dp[0][i]+dp[2][i]+dp[3][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
			dp[6][i+1] += (dp[0][i]+dp[1][i]+dp[2][i]+dp[3][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
		} else if (s[i] == 'O') {
			dp[1][i+1] += (dp[1][i]+dp[3][i]+dp[4][i]+dp[6][i])%10007;
			dp[3][i+1] += (dp[0][i]+dp[1][i]+dp[3][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
			dp[4][i+1] += (dp[1][i]+dp[2][i]+dp[3][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
			dp[6][i+1] += (dp[0][i]+dp[1][i]+dp[2][i]+dp[3][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
		} else {
			dp[2][i+1] += (dp[2][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
			dp[4][i+1] += (dp[1][i]+dp[2][i]+dp[3][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
			dp[5][i+1] += (dp[0][i]+dp[2][i]+dp[3][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
			dp[6][i+1] += (dp[0][i]+dp[1][i]+dp[2][i]+dp[3][i]+dp[4][i]+dp[5][i]+dp[6][i])%10007;
		}
	}
	int cc = 0;
	for (int i = 0; i < 7; i++) {
		cc += dp[i][n];
		cc %= 10007;
	}
	cout << cc << endl;
	return 0;
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    cin >> x >> y;
    cout << max(0, (x-(2*y))) << endl;
}


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

const int N = 1e5 + 5;

int n, m;
int a[N];
map<int,int> cnt;
long long res = 0;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	cnt[0]++;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		a[i] = (a[i] + a[i - 1]) % m;
		res += cnt[a[i]];
		cnt[a[i]]++;
	}
	cout << res << '\n';
}

Measured memory_bytes: 3584
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) throws IOException {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		// ???????????°?????????
		int count = sc.nextInt();

		// ??????????????????????´?
		List<String> list = new ArrayList<String>();
		for (int i = 0; i < count; i++) {
			list.add(sc.next());
		}

		// ???????????????????????\?????????
		Collections.reverse(list);
		
		// ?????????????????§??£???????????????
		System.out.println(String.join(" ", list));
	}
}

Measured memory_bytes: 26196
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
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;
}
long long dp[110000];
 
int main()
{
  int N, K;
  cin >> N >> K;

  vector<ll> h(N);
  REP(i, N) cin >> h[i];
  
  REP(i,110000){
    dp[i] = INF;
  }

  dp[0] = 0;

  FOR(i,0,N){
    FOR(j,1,K+1){
      chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }

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

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int n,k,mi='z';
string s,ns,ans;
void getans(int l,int r){
	int su=(r-l+1);
	for (int i=1;i<k;i++){
		su=min(su*2,n);if (su==n) break;
	}
	string no="";
	for (int i=1;i<=su;i++) no+=mi;
	for (int i=1;i<=n-su;i++)no+=s[r+i];
	if (ans=="") ans=no;else ans=min(ans,no);
}
int main(){
	cin>>n>>k;
	cin>>s;ns=s;reverse(ns.begin(),ns.end());s+=ns;
	ans="";
	for (int i=0;i<n;i++)mi=min(mi,(int)s[i]);
	for (int i=n-1;i>=0;i--){
		if (s[i]==mi){
			int j=i;
			while (j-1>=0&&s[j-1]==s[i]) j--;
			if (i!=n-1)getans(j,i);else getans(j,n*2-j-1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  bool flag = true;
  for(int i=0; i<s.length(); i++){
    // odd
    if(i%2 == 0){
      if(s[i]=='R' || s[i]=='U' || s[i]=='D'){
      } else {
        flag = false;
        break;
      }
    } else {
      if(s[i]=='L' || s[i]=='U' || s[i]=='D'){
      } else {
        flag = false;
        break;
      }
    }
  }
  if(flag) cout << "Yes";
  else cout << "No";
  cout << endl;
  return 0;
}

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

using namespace std;

#define ll long long
#define pii pair<int,int>

int main()
{
	int n;
	cin>>n;
	int a[n];
	ll ans = 0;
	cin>>a[0];
	int nax = a[0];
	for(int i=1;i<n;i++)
	{
		cin>>a[i];
		if(a[i] < nax)
		{
			ans += (nax-a[i]);
		}
		else
		{
			nax = a[i];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4348
#include<iostream>
using namespace std;
const int maxnum = 10010;
int w[maxnum];          //w[i] -- the i-th item's weight
int v[maxnum];          //v[i] -- the i-th item's value
int N; //the total number of items
int W; //the maximum load capacity
int maxvalue[10010]={0};
void knapsack(int N, int W, int maxvalue[], int w[])
{
    for(int counter = 1;counter <= N;counter++)
    {
        for(int j = w[counter]; j <= W; j++)
        {
            maxvalue[j] = max(maxvalue[j],maxvalue[j-w[counter]]+v[counter]);
        }
    }
}
int main()
{
     
    cin>>N>>W;
    for(int i = 1;i <= N;i++)
    {
        cin>>v[i]>>w[i];
    }
    knapsack(N,W,maxvalue,w);
    cout<<maxvalue[W]<<endl;
    return 0;
}

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

int32_t main(){
	int n; cin>>n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	double ans = 0;
	sort(a.begin(), a.end());
	ans = float(a[0] + a[1]) / 2.0;
	for(int i =2; i < n; ++i){
		ans  = (ans + a[i])/ 2.0;
	}
	cout<<fixed<<setprecision(9)<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>
#include<map>

using namespace std;

long long i,j,k,N,M,Q,a[51],b[51],c[51],d[51],ans,A[11],temp;

int main()
{
  cin>>N>>M>>Q;
  
  for(i=1;i<=Q;i++)
  {
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  
  ans=0;
  
  for(A[1]=1;A[1]<=M;A[1]++)
  {
      for(A[2]=A[1];A[2]<=M;A[2]++)
      {
        if(N==2)
        { 
          temp=0;
          for(i=1;i<=Q;i++)
          {
            if(A[b[i]]-A[a[i]]==c[i])temp+=d[i];
          }
          ans=max(ans,temp);
          continue;
        }
        for(A[3]=A[2];A[3]<=M;A[3]++)
        {
                  if(N==3)
        { 
          temp=0;
          for(i=1;i<=Q;i++)
          {
            if(A[b[i]]-A[a[i]]==c[i])temp+=d[i];
          }
          ans=max(ans,temp);
          continue;
        }
          for(A[4]=A[3];A[4]<=M;A[4]++)
          {
        if(N==4)
        { 
          temp=0;
          for(i=1;i<=Q;i++)
          {
            if(A[b[i]]-A[a[i]]==c[i])temp+=d[i];
          }
          ans=max(ans,temp);
          continue;
        }
            for(A[5]=A[4];A[5]<=M;A[5]++)
            {
        if(N==5)
        { 
          temp=0;
          for(i=1;i<=Q;i++)
          {
            if(A[b[i]]-A[a[i]]==c[i])temp+=d[i];
          }
          ans=max(ans,temp);
          continue;
        }
              for(A[6]=A[5];A[6]<=M;A[6]++)
              {
        if(N==6)
        { 
          temp=0;
          for(i=1;i<=Q;i++)
          {
            if(A[b[i]]-A[a[i]]==c[i])temp+=d[i];
          }
          ans=max(ans,temp);
          continue;
        }
                for(A[7]=A[6];A[7]<=M;A[7]++)
                {       
        if(N==7)
        { 
          temp=0;
          for(i=1;i<=Q;i++)
          {
            if(A[b[i]]-A[a[i]]==c[i])temp+=d[i];
          }
          ans=max(ans,temp);
          continue;
        }
                  for(A[8]=A[7];A[8]<=M;A[8]++)
                  {
        if(N==8)
        { 
          temp=0;
          for(i=1;i<=Q;i++)
          {
            if(A[b[i]]-A[a[i]]==c[i])temp+=d[i];
          }
          ans=max(ans,temp);
          continue;
        }
                    for(A[9]=A[8];A[9]<=M;A[9]++)
                    {
        if(N==9)
        { 
          temp=0;
          for(i=1;i<=Q;i++)
          {
            if(A[b[i]]-A[a[i]]==c[i])temp+=d[i];
          }
          ans=max(ans,temp);
          continue;
        }
                      for(A[10]=A[9];A[10]<=M;A[10]++)
                      {
                                if(N==10)
        { 
          temp=0;
          for(i=1;i<=Q;i++)
          {
            if(A[b[i]]-A[a[i]]==c[i])temp+=d[i];
          }
          ans=max(ans,temp);
          continue;
        }
                      }
                    }
                  }
                }
              }
            }
                
          }
        }
        
        
      }

    
  }
  
  cout <<ans;

  
  
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		double L = (double) Integer.parseInt(W.split(" ")[0]);

		System.out.println(Math.pow(L/3,3));

	}

}


Measured memory_bytes: 21076
(function(input) {
  var p = input.replace(/\n$/, '').split('\n');
  var a, b;
  var hit, blow;
  while ((a = p.shift()) && (b = p.shift())) {
    a = a.split(' ').map(Number);
    b = b.split(' ').map(Number);
    hit = blow = 0;
    for (var i = 0; i < b.length; i++) {
      if (a[i] === b[i]) {
        hit++;
      } else if (a.indexOf(b[i]) >= 0) {
        blow++;
      }
    }
    console.log('%d %d', hit, blow);
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7640
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


constexpr int N = 1000;
constexpr int mod = 1e9 + 7;
std::array<std::array<lli, N + 1>, N + 1> A;
std::array<lli, N+1> F, invF;

struct faster{
    lli Power[N+1], invP[N+1];
    constexpr faster(): Power(), invP(){
        Power[0] = 1;
        for(int i = 1; i <= N; ++i) Power[i] = (Power[i-1] * i) % mod;
        invP[N] = inverse(Power[N]);
        for(int i = N; i > 0; --i) invP[i-1] = (invP[i] * i) % mod;
    }
    constexpr void swap(lli &a, lli &b) const {
        a ^= b; b ^= a; a ^= b;
    }
    constexpr lli inverse(lli a) const noexcept{
        lli b = mod, u = 1, v = 0;
        while (b != 0) { 
            lli t = a / b; a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= mod; if (u < 0) u += mod;
        return u;
    }
};

// 累乗の余りを求める関数
inline lli power(lli a, int n, lli mod_number___ = mod){
    lli res = 1, waiting = a;
    while(n){ if(n & 1){ 
        (res *= waiting) %= mod_number___;}
        (waiting *= waiting) %= mod_number___; 
        n >>= 1;
    }
    return res;
}

/* n人でp人グループを k 個作る分け方は
    nCpk * pkCp * (k-1)pCp * ... * pCp / k!
    = {n!/(n-pk)!pk!} * {pk!/(k-1)p!p!} * {(p-1)k!/(k-2)p!p!} * ... * pCp / k!
    = {n!/(n-pk)!pk!} * pk! / (p!)^k / k!
    = n! / { (n - pk)! * (p!)^k * k! }
*/

constexpr faster Init;

int main(void){
    int n, a, b, c, d; scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);

    int bMa = b - a;
    A[0][0] = 1;
    for(int i = 0; i <= bMa; ++i){
        int p = a + i;
        for(int j = 0; j <= n; ++j){
            (A[i+1][j] += A[i][j]) %= mod;
            lli C = power(Init.invP[p], c) * Init.invP[j] % mod;
            for(int k = c; k <= d and j + k * p <= n; ++k){
                lli c = (Init.Power[j + k * p] * Init.invP[k] % mod) * C % mod;
                (A[i + 1][j + k * p] += c * A[i][j]) %= mod;
                (C *= Init.invP[p]) %= mod;
            }
        }
    }

    printf("%lld\n", A[bMa+1][n]);
    

    





    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    vector<ll> v(n,0);
    rep(i,n) cin>>v[i];
    rep(i,n) v[i]-=i+1;
    sort(v.begin(),v.end());
        ll b = v[n/2];
        ll sum=0;
        rep(i,n) sum+=abs(v[i]-b);
        //cout<<b<<endl;
        cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
  long long int n;
  long long int syou;
  int a[1000];
  int i,amari,count = 0,j;

  scanf("%lld",&n);
  while(n > 0)
  {
    n--;
    syou = n / 26;
    amari = n % 26;
    count++;
    a[count] = amari+97;
    n = n / 26;
    
  }
  for(i=count;i>0;i--)
  {
    printf("%c",a[i]);
  }
  return 0;
}

Measured memory_bytes: 1628
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		for(int i = 0; i < n; i++) {
			if(i != 0) System.out.print(" ");
			System.out.print(a[n - i - 1]);
		}
		System.out.println();
	}
}



Measured memory_bytes: 26196