akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
int max(int a,int b){
  if(a<b)return b;
  else return a;
}
int lcs(char *x,char *y){

  int i,j;
  int xlen,ylen;
  int dp[1001][1001];
  
  xlen=strlen(x);
  ylen=strlen(y);
  for(i=0;i<=xlen;i++)dp[i][0]=0;
  for(j=0;j<=ylen;j++)dp[0][j]=0;
  for(i=0;i<xlen;i++){
    for(j=0;j<ylen;j++){
      if(x[i]==y[j]) dp[i+1][j+1]=dp[i][j]+1;
      else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
    }
  }
  return dp[xlen][ylen];
}
int main(){
  int q;
  char x[1001];
  char y[1001];
  int leng;
  scanf("%d",&q);
  while(q>0){
    scanf("%s",x);
    scanf("%s",y);

    printf("%d\n",lcs(x,y));
    q--;
  }
  return 0;
}

Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int a[105][105];

int main(){
  int m,n;
  cin>>m>>n;
  char x;
  lp(i,m+1){
    if(i==0) continue;
    lp(j,n+1){
      if(j==0) continue;
      cin>>x;
      if(i==1)a[i][j]=1;
      if(x=='o'){
	a[i][j-1]=1;
	a[i][j]=1;
	a[i][j+1]=1;
      }
      if(x=='x'){
	a[i][j]=1;
	a[i-1][j-1]=1;
	a[i-1][j]=1;
	a[i-1][j+1]=1;
	a[i][j-1]=1;
	a[i][j+1]=1;
	a[i+1][j-1]=1;
	a[i+1][j]=1;
	a[i+1][j+1]=1;
      }
    }
  }
  int count=0;
  lp(i,m+1){
    if(i==0) continue;
    lp(j,n+1){
      if(j==0) continue;
      if(a[i][j]==0) count++;
    }
  }
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 w, h, x, y;
int main() {
  cin >> w >> h >> x >> y;

  cout << double(h * w) / 2 << ' ';
  i64 k = 0;
  if (x * 2 == w && y * 2 == h) k = 1;
  cout << k << '\n';
  return 0;
}



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

int main(int argc, char const *argv[]) {
    long long n, p;
    cin >> n >> p;
    if(n==1){
        cout << p << endl;
    }else{
        for(int i=(int)floor(sqrt(p)); i > 0; i--){
            if(p%(long long)(pow(i,n))==0){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 640
N = int(input().strip())
a = list(map(int, input().strip().split()))
cl = [0 for _ in range(9)]

for _a in a:
  cl[min(_a//400, 8)] += 1

f = cl[-1]
minc = sum([1 for c in cl[:8] if c!=0])
print(max(minc, 1), minc + f)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int H, W;
vector<string> S;
vector<vector<bool>> FLAG;

int main(){

	int N;
	cin >> N;
	vector<ll> A(N), B(N);
	vector<pll> V;
	ll a, b;
	for(int i = 0; i < N; i ++){
		cin >> a >> b;
		V.pm(b, a);
	}
	sort(all(V));
	ll now = 0;
	bool flag = true;
	for(int i = 0; flag && i < N; i ++){
		if(now > V[i].first - V[i].second)flag = false;
		now += V[i].second;
	}
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 9456
#include <stdio.h>
#include <vector>
#include <algorithm>
typedef struct{ int to; int rev; int f;} edge;
int x, y;
std::vector<edge> vec[250];
bool flag[250];

int dfs(int a) {
  int i;
  if(a == x + y + 1) return 1;
  flag[a] = false;
  for(i = 0; i < vec[a].size(); ++i) if(flag[vec[a][i].to] && vec[a][i].f) {
    edge *e = &vec[a][i];
    int d;
    d = dfs((*e).to);
    if(d) {
      (*e).f--;
      vec[(*e).to][(*e).rev].f++;
      return 1;
    }
  }
  return 0;
}

int main(void) {
  int i, j, k, e, a, b, c, ans = 0;
  scanf("%d%d%d", &x, &y, &e);
  for(i = 0; i < x + y + 2; ++i) flag[i] = true;
  flag[0] = false;
  bool ff[250];
  for(i = 0; i < x + y; ++i) ff[i] = true;
  for(i = 0; i < e; ++i) {
    scanf("%d%d", &a, &b);
    b += x;
    edge ta, tb;
    ta.to = b, ta.f = 1, ta.rev = vec[b].size();
    tb.to = a, tb.f = 0, tb.rev = vec[a].size();
    vec[a].push_back(ta);
    vec[b].push_back(tb);
    ta.to = x + y, ta.f = 0, ta.rev = vec[x + y].size();
    tb.to = a, tb.f = 1, tb.rev = vec[a].size();
    if(ff[a]) {
      vec[x + y].push_back(tb);
      vec[a].push_back(ta);
    }
    ta.to = x + y + 1, ta.f = 1, ta.rev = vec[x + y + 1].size();
    tb.to = b, tb.f = 0, tb.rev = vec[b].size();
    if(ff[b]) {
      vec[x + y + 1].push_back(tb);
      vec[b].push_back(ta);
    }
    ff[a] = false, ff[b] = false;
  }
  while( 1 ) {
     for(i = 0; i < x + y + 2; ++i) flag[i] = true;
     a = dfs(x + y);
     if(a) ans++;
     else break;
  }
  //for(i = 0; i < x + y + 2; ++i) for(j = 0; j < vec[i].size(); ++j) printf("%d:%d %d\n", i, vec[i][j].to, vec[i][j].f);
  printf("%d\n", ans);
  return 0;
} 


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

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 1000001;

int vis[N];

int main() {
  int k;
  S(k);
  int r = 0;
  rep(i,1,111111111) {
    r = (r * 10 + 7) % k;
    if(r == 0) {
      P(i);
      return 0;
    }
    if(vis[r]) {
      P(-1);
      return 0;
    }
    vis[r] = 1;
  }
  return 0;
}


Measured memory_bytes: 7608
#include <bits/stdc++.h>
using namespace std;
const long long m=26;


int main(){
    long long n; cin>>n;
    long long a=n;
    int b=0;
    string s;
    while(a>0){
        b=(a-1)%m;
        a=(a-1)/m;
        char x='a'+b;
        s+=x;
    }
    for(int i=s.size()-1;i>=0;i--){
        cout<<s[i];
    }
    cout<<endl;
}



Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, K, A[212345];

int main() {

	cin >> N >> K;
	rep(i, N) cin >> A[i];

	vector<ll> before, after(N);
	rep(i, N) after[i] = A[i];

	rep(k, K) {
		before = move(after);

		after = vector<ll>(N, 0);
		priority_queue<ll, vector<ll>, greater<>> pq;
		rep(i, N) {
			while (!pq.empty() && pq.top() < i) pq.pop();
			after[i] += pq.size();
			if (before[i]) pq.push(i + before[i]);
		}
		while (!pq.empty()) pq.pop();

		rep(i, N) {
			while (!pq.empty() && pq.top() < i) pq.pop();
			after[N - 1 - i] += pq.size();
			if (before[N - 1 - i]) pq.push(i + before[N - 1 - i]);
		}

		rep(i, N) after[i]++;

		bool f = true;
		rep(i, N) if (after[i] != N) f = false;

		if (f) {
			break;
		}
	}

	rep(i, N) cout << after[i] << " ";
	cout << endl;


	return 0;
}


Measured memory_bytes: 11584
#include<iostream>
using namespace std;
int s, n, a[25], dp[10000][25];
int solve(int r, int s) {
	if (r == 0) { dp[r][s] = 0; return 0; }
	if (dp[r][s] >= 0)return dp[r][s];
	int flag = 0;
	for (int i = 1; i <= a[s]; i++) {
		if (r - i < 0)continue;
		if (solve(r - i, (s + 1) % n) == false)flag = 1;
	}
	dp[r][s] = flag;
	return flag;
}
int main() {
	while (true) {
		for (int i = 0; i < 10000; i++) { for (int j = 0; j < 25; j++)dp[i][j] = -1; }
		cin >> n; if (n == 0)break; cin >> s; s--; n *= 2; for (int i = 0; i < n; i++)cin >> a[i];
		cout << solve(s, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 4408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vi A(N);
    REP(i, N) cin >> A[i];

    int neg_cnt = 0;
    ll total = 0LL;
    int smallest = 1e9 + 7;
    REP(i, N) {
        if (A[i] < 0) neg_cnt++;
        total += abs(A[i]);
        smallest = min(smallest, abs(A[i]));
    }

    if (neg_cnt % 2 > 0) {
        total -= 2 * smallest;
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func stringsToInts(s, sep string) []int {
	ss := strings.Split(s, sep)
	ints := make([]int, 0)
	for _, c := range ss {
		i, err := strconv.Atoi(c)
		if err != nil {
			continue
		}
		ints = append(ints, i)
	}
	return ints
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		ints := stringsToInts(line, " ")
		a, b, c := ints[0], ints[1], ints[2]
		switch {
		case a < b && b < c:
			fmt.Println("Yes")
		default:
			fmt.Println("No")
		}
	}

	if err := scanner.Err(); err != nil {
		// log.Println(err)
		return
	}
}



Measured memory_bytes: 1104
def solve():
    N, K, *a_l = map(int, open(0).read().split())
    MOD = 10**9+7
    count_a, count_b = 0, 0
    inversion = 0

    for i in range(N):
        for j in range(N):
            if a_l[i] > a_l[j]:
                if i < j:
                    count_a += 1
                count_b += 1

    inversion = count_a * K + count_b * (K * (K - 1)) // 2
    print(inversion%MOD)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
// C - Sentou

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll t[200000];

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

	for (int i=0; i<N; i++) {
		cin >> t[i];
	}

	ll ans = 0;
	for (int i=0; i<N-1; i++) {
		if (t[i+1] - t[i] < T) {
			ans += (t[i+1] - t[i]);
		} else {
			ans += T;
		}
	}

	ans += T;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 1e5 + 10;
int dp[N];
int nums[N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> nums[i];
	dp[1] = 0;
	dp[2] = abs(nums[1] - nums[2]);
	for(int i = 3; i <= n; i++) {
		dp[i] = min(dp[i-1] + abs(nums[i] - nums[i-1]), dp[i-2] + abs(nums[i] - nums[i-2]));
	}
	cout << dp[n] << "\n";
	
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> a(3, 0);
	string s;
	cin >> s;
	rep(i,s.size()){
		++a[(s[i]-'a')];
	}
	sort(a.begin(), a.end());
	if(a[2] - a[0] <= 1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3708
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

class state{
public:
	int p[30];
	bool check(){
		for(int i=0;i<9;++i) if(p[0]!=p[i]) return false;
		for(int i=9;i<12;++i) if(p[9]!=p[i]) return false;
		for(int i=12;i<15;++i) if(p[12]!=p[i]) return false;
		for(int i=15;i<18;++i) if(p[15]!=p[i]) return false;
		for(int i=18;i<21;++i) if(p[18]!=p[i]) return false;
		for(int i=21;i<30;++i) if(p[21]!=p[i]) return false;
		return true;
	}
	void up(int i){
		swap(p[0+i],p[23-i]);
		swap(p[3+i],p[26-i]);
		swap(p[6+i],p[29-i]);
		swap(p[9+i],p[20-i]);
		if(i==0) swap(p[15],p[17]);
		if(i==2) swap(p[12],p[14]);
	}
	void right(int i){
		swap(p[0+3*i],p[27-3*i]);
		swap(p[1+3*i],p[28-3*i]);
		swap(p[2+3*i],p[29-3*i]);
		swap(p[14-i],p[15+i]);
		if(i==0) swap(p[18],p[20]);
		if(i==2) swap(p[9],p[11]);
	}
};

int dfs(int depth,state arg){
	if(depth==8) return depth;
	if(arg.check()) return depth;
	int ret=8;
	for(int i=0;i<3;i+=2){
		state cur=arg;
		cur.up(i);
		ret=min(ret,dfs(depth+1,cur));
	}
	for(int i=0;i<3;i+=2){
		state cur=arg;
		cur.right(i);
		ret=min(ret,dfs(depth+1,cur));
	}
	return ret;
}

int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;++i){
		state init;
		for(int j=0;j<30;++j) cin >> init.p[j];
		cout << dfs(0,init) << endl;
	}
	return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b)
    {
        for(int i=1;i<=b;i++)
            cout<<a;
        cout<<endl;
    }
    else
    {
        for(int i=1;i<=a;i++)
            cout<<b;
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS=1e-10;
const double PI=acos(-1.0);

int main(){
	int N,Q;
	while(cin>>N>>Q,N&&Q){
		int M;
		vi date(100);
		int day=0;
		REP(i,100)	date[i]=0;
		REP(i,N){
			cin>>M;
			REP(i,M){
				cin>>day;
				date[day]++;
			}
		}
		int maxDate=0;
		int mm=-1;
		REP(i,100){
			if(maxDate<date[i]){
				mm=i;
			}
			maxDate=max(maxDate,date[i]);
		}
		if(maxDate>=Q)	cout<<mm<<endl;
		else	cout<<0<<endl;
	}
}

Measured memory_bytes: 0
// #pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 9;
const int infint = 1e9 + 7;
const int MAXN = 1e5 + 7;
const double eps = 1e-9;
const long double pi = 3.1415926535897932384626433832795;
const long double e = 2.71828182845904523536028747135266;
inline ll read()
{
    ll kr = 1, xs = 0;
    char ls;
    ls = getchar();
    while (!isdigit(ls))
    {
        if (!(ls ^ 45))
            kr = -1;
        ls = getchar();
    }
    while (isdigit(ls))
    {
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);
        ls = getchar();
    }
    return xs * kr;
}
// inline __int128 read128()
// {
//     __int128 kr=1,xs=0;char ls;ls=getchar();
//     while(!isdigit(ls)){
//         if(!(ls^45)) kr=-1;ls=getchar();
//     }
//     while(isdigit(ls)){
//         xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
//     }
//     return xs*kr;
// }
inline ull readull()
{
    ull xs = 0;
    char ls;
    ls = getchar();
    while (!isdigit(ls))
        ls = getchar();
    while (isdigit(ls))
    {
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);
        ls = getchar();
    }
    return xs;
}
inline void writeull(ull x)
{
    if (x < 0)
    {
        x *= -1;
        putchar('-');
    }
    if (x >= 10)
        writeull(x / 10);
    putchar('0' + x % 10);
}
inline void write(ll x)
{
    if (x < 0)
    {
        x *= -1;
        putchar('-');
    }
    if (x >= 10)
        write(x / 10);
    putchar('0' + x % 10);
}
// inline void write(__int128 x){
//     if(x<0){x*=-1;putchar('-');}
//     if(x>=10) write(x/10);
//     putchar('0'+x%10);
// }
///////////////////////////////////////////////////////////////////////////////////////
int a[MAXN];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // t = read();
    while (t--)
    {
        int n=read(),x=read(),T=read();
        n=n/x+(n%x?1:0);
        n*=T;
        printf("%d\n",n);
    }
    return 0;
}



Measured memory_bytes: 3672
"""
B - Chocolate
"""

n = int(input())

days, offset = map(int, input().split())

a_list = []
for part in range(n):
    a_list.append(int(input()))

choco_sum = offset

for day in range(days):
    for a in a_list:
        if day % a == 0:
            choco_sum += 1

print(choco_sum)

Measured memory_bytes: 3060
A = int(input())
B = int(input())
C = int(input())
X = int(input())
answer = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500 * i + 100 * j + 50 * k == X:
                answer += 1

print(answer)

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

using namespace std;

int main()
{
	string s;
	cin >> s;

	vector<vector<long long>> dp(s.length(), vector<long long>(13));
	if (s[0] == '?') {
		for (int j = 0; j < 10; j++) {
			dp[0][j] = 1;
		}
	} else {
		dp[0][s[0] - '0'] = 1;
	}

	int mod = 1000000007;
	for (int i = 1; i < s.length(); i++) {
		if (s[i] == '?') {
			for (int j = 0; j < 13; j++) {
				for (int k = 0; k < 10; k++) {
					dp[i][(j * 10 + k) % 13] += dp[i - 1][j];
					dp[i][(j * 10 + k) % 13] %= mod;
				}
			}
		} else {
			for (int j = 0; j < 13; j++) {
				dp[i][(j * 10 + (s[i] - '0')) % 13] += dp[i - 1][j];
				dp[i][(j * 10 + (s[i] - '0')) % 13] %= mod;
			}
		}
	}
	cout << dp[s.length() - 1][5] << endl;

	return 0;
}

Measured memory_bytes: 13696
#include<algorithm>
#include<iostream>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define ll long long
using namespace std;
//{{{ read()
inline int read(){
	register int x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	x=x*10+(ch^48);
	return x*f;
}
//}}}
const int N=1e6+5;
int n,a[N],b[N];
int C(int n,int m){
	if((n&m)==m)	return 1;
	return 0;
}
int work(){
	int res=0;
	for(int i=1;i<n;i++)
		if(b[i]&&C(n-2,i-1))	res^=1;
	return res;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	a[i]=read();
	for(int i=1;i<n;i++)	b[i]=(abs(a[i]-a[i+1]));
	int flag=0;
	for(int i=1;i<n;i++)
		if(b[i]==1)	flag=1;
	if(flag){
		for(int i=1;i<=n;i++)
			if(b[i]==2)	b[i]=0;
	}
	else{
		for(int i=1;i<=n;i++)
			if(b[i]==2)	b[i]=1;
	}
	int d=work();
	if(flag){
		if(d)	puts("1");
		else	puts("0");
	}
	else{
		if(d)	puts("2");
		else	puts("0");
	}
	return 0;
}


Measured memory_bytes: 8064
X= int(input())


if(X + 7) % 7 == 0:
     print('thu')
elif(X + 8) % 7 == 0:
    print('wed')
elif(X + 9) % 7 == 0:
    print('tue')
elif(X + 10) % 7 == 0:
    print('mon')
elif(X + 11) % 7 == 0:
    print('sun')
elif(X + 12) % 7 == 0:
    print('sat')
elif(X + 13) % 7 == 0:
    print('fri')   



Measured memory_bytes: 5592
b,c,s;main(a){for(;~scanf("%s",&s);s-'A,B'&&s-'B,A'?s-'B,C'&&s-'C,B'?(s=a,a=c,c=s):(s=b,b=c,c=s):(s=a,a=b,b=s));s=65+b+c*2;exit(!puts(&s));}

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

//D - Islands War
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] d = new int[m][2];
        for (int i = 0; i < m; i++) {
            d[i][0] = sc.nextInt();
            d[i][1] = sc.nextInt();
        }
        Arrays.sort(d, (a, b) -> a[1] - b[1]);
        int ans = 1;
        int end = d[0][1];
        for (int i = 1; i < d.length; i++)
            if (d[i][0] >= end) {
                ans++;
                end = d[i][1];
            }
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 93408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int L; cin >> L;
  long double l = L / 3.0;
  long double V = l*l*l;
  cout << setprecision(20) << V << endl;
  return 0;
}


Measured memory_bytes: 256
(* O(√p) *)
let n, p = Scanf.scanf " %d %d" @@ fun a b -> a, b
let factorize_primes n =
  let rec f acc c d m =
    if d > m || d * d > n then
      List.rev @@ if c > 0 then (d, c) :: acc else if m > 1 then (m, 1) :: acc else acc
    else
      if m mod d = 0 then f acc (c + 1) d @@ m / d
      else f (if c > 0 then (d, c) :: acc else acc) 0 (d + 1) m in
  f [] 0 2 n
let rec pow b n = if n <= 0 then 1 else b * pow b (n - 1)
let ps = factorize_primes p
let _ = List.fold_left (fun acc (b, c) -> acc * pow b (c / n)) 1 ps |> Printf.printf "%d\n"

Measured memory_bytes: 2432
S=input()
x=0
if S[0]=='R':
  if S[1]=='R':
    if S[2]=='R':
      x=3
    else:
      x=2
  else:
    x=1
else:
  if S[1]=='R':
    if S[2]=='R':
      x=2
    else:
      x=1
  else:
    if S[2]=='R':
      x=1
print(x)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
const int maxn=300+10;
const int mod=1e9+7;
int n,m,f[maxn][maxn][maxn],ans;

struct Limit{
	int l,x;
};

vector<Limit> v[maxn];

int check(int a,int b,int c){
	int r=max(a,max(b,c)),cnt;Limit p;
	for(int i=0;i<v[r].size();i++){
		p=v[r][i];
		cnt=(p.l<=a)+(p.l<=b)+(p.l<=c);
		if(cnt!=p.x) return 0;
	}
	return 1;
}

int main()
{
	scanf("%d%d",&n,&m);
	int l,r,x;
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&l,&r,&x);
		v[r].push_back((Limit){l,x});
	}
	f[0][0][0]=1;
	int p;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n;k++){
				if(!f[i][j][k]) continue;
				p=max(i,max(j,k));
				if(!check(i,j,k)){
					f[i][j][k]=0;
					continue;
				}
				if(p==n) ans=(ans+f[i][j][k])%mod;
				f[p+1][j][k]=(f[p+1][j][k]+f[i][j][k])%mod;
				f[i][p+1][k]=(f[i][p+1][k]+f[i][j][k])%mod;
				f[i][j][p+1]=(f[i][j][p+1]+f[i][j][k])%mod;
			}
	/*for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n;k++)
				printf("dp[%d][%d][%d]=%d\n",i,j,k,f[i][j][k]);*/
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 114944
#include<bits/stdc++.h>
#define avjo ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    avjo;
    float r;
    cin>>r;
    printf("%.20f",2*3.14159*r);
    return 0;
}


Measured memory_bytes: 3764
N=int(input())
S=list(input())
S.append(S[0])
S.append(S[1])

L1=["S","S"]
L2=["S","W"]
L3=["W","S"]
L4=["W","W"]

flag=0

for i in range(1,len(S)-1):
    if L1[i]=="S":
        if S[i]=="o" and L1[i-1]=="S":
            L1.append("S")
        elif S[i]=="o" and L1[i-1]=="W":
            L1.append("W")
        elif S[i]=="x" and L1[i-1]=="S":
            L1.append("W")
        elif S[i]=="x" and L1[i-1]=="W":
            L1.append("S")
    else:
        if S[i]=="o" and L1[i-1]=="S":
            L1.append("W")
        elif S[i]=="o" and L1[i-1]=="W":
            L1.append("S")
        elif S[i]=="x" and L1[i-1]=="S":
            L1.append("S")
        elif S[i]=="x" and L1[i-1]=="W":
            L1.append("W")
if L1[0]==L1[len(L1)-2] and L1[1]==L1[len(L1)-1]:
    L1=L1[:N]
    print("".join(L1))
    exit()
    
for i in range(1,len(S)-1):
    if L2[i]=="S":
        if S[i]=="o" and L2[i-1]=="S":
            L2.append("S")
        elif S[i]=="o" and L2[i-1]=="W":
            L2.append("W")
        elif S[i]=="x" and L2[i-1]=="S":
            L2.append("W")
        elif S[i]=="x" and L2[i-1]=="W":
            L2.append("S")
    else:
        if S[i]=="o" and L2[i-1]=="S":
            L2.append("W")
        elif S[i]=="o" and L2[i-1]=="W":
            L2.append("S")
        elif S[i]=="x" and L2[i-1]=="S":
            L2.append("S")
        elif S[i]=="x" and L2[i-1]=="W":
            L2.append("W")
if L2[0]==L2[len(L2)-2] and L2[1]==L2[len(L2)-1]:
    L2=L2[:N]
    print("".join(L2))
    exit()
    
for i in range(1,len(S)-1):
    if L3[i]=="S":
        if S[i]=="o" and L3[i-1]=="S":
            L3.append("S")
        elif S[i]=="o" and L3[i-1]=="W":
            L3.append("W")
        elif S[i]=="x" and L3[i-1]=="S":
            L3.append("W")
        elif S[i]=="x" and L3[i-1]=="W":
            L3.append("S")
    else:
        if S[i]=="o" and L3[i-1]=="S":
            L3.append("W")
        elif S[i]=="o" and L3[i-1]=="W":
            L3.append("S")
        elif S[i]=="x" and L3[i-1]=="S":
            L3.append("S")
        elif S[i]=="x" and L3[i-1]=="W":
            L3.append("W")
if L3[0]==L3[len(L3)-2] and L3[1]==L3[len(L3)-1]:
    L3=L3[:N]
    print("".join(L3))
    exit()
    
for i in range(1,len(S)-1):
    if L4[i]=="S":
        if S[i]=="o" and L4[i-1]=="S":
            L4.append("S")
        elif S[i]=="o" and L4[i-1]=="W":
            L4.append("W")
        elif S[i]=="x" and L4[i-1]=="S":
            L4.append("W")
        elif S[i]=="x" and L4[i-1]=="W":
            L4.append("S")
    else:
        if S[i]=="o" and L4[i-1]=="S":
            L4.append("W")
        elif S[i]=="o" and L4[i-1]=="W":
            L4.append("S")
        elif S[i]=="x" and L4[i-1]=="S":
            L4.append("S")
        elif S[i]=="x" and L4[i-1]=="W":
            L4.append("W")
if L4[0]==L4[len(L4)-2] and L4[1]==L4[len(L4)-1]:
    L4=L4[:N]
    print("".join(L4))
    exit()

print(-1)

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
/*
Node treeMinimum(Node x){


}
*/

Node treeSearch(Node u, int k){
  if( u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  }  
  else
    return treeSearch(u->right,k);     

  while(u != NIL && k != u->key){
    if(k < u->key){
      u = u->left;
    }
    else if(k > u->key){
      u = u->right;
    }
  }
  return u;
  
}

/*
Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
     if(z->key <  x->key){
       x = x->left;
     }
     else
       x = x->right;
  }
   z->parent = y;
   if(y == NIL){
     root = z;
   }
   else if(z->key <  y->key){
     y->left = z;
   }
   else
     y->right = z;


  }

void inorder(Node u){
if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
 }
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL){
     preorder(u->left);
  }
  if(u->right != NIL){
     preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
	scanf("%d", &x);
	treeDelete(treeSearch(root, x));
	}*/
  }

  return 0;
}

 

Measured memory_bytes: 19360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	ll n, k; cin >> n >> k;
	int v[200001];
	rep(i, n) cin >> v[i];
	sort(v, v + n);
	ll ans = 0;
	rep(i, max((ll)0, n - k)) ans += v[i];
	cout << ans << endl;
}

Measured memory_bytes: 1024
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  REP(i, n) cin >> h[i];
  sort(ALL(h));

  ll ans = 0;
  REPR(i, n - 1) {
    if (k > 0) {
      --k;
    } else {
      ans += h[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

/*  選択ソート(0オリジン) */
int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
struct t{
	string s;
	ll p;
	ll i;
	bool operator<(const t&q)const{
		if(s!=q.s)return s<q.s;
		return p>q.p;
	}
	bool operator>(const t&q)const{
		if(s!=q.s)return s>q.s;
		return p<q.p;
	}
};
int n;
t x[1005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
		cin>>x[i].s>>x[i].p;
		x[i].i=i+1;
	}
	sort(x,x+n);
	for(int i=0;i<n;i++)cout<<x[i].i<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, C: int, B: "List[int]", A: "List[List[int]]"):
    ans = 0
    for i in range(N):
        tmp = 0
        for j in range(M):
            tmp += A[i][j]*B[j]
        tmp += C
        if tmp>0:
            ans += 1
    print(ans)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    B = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    A = [ [ int(next(tokens)) for _ in range(M) ] for _ in range(N) ]  # type: "List[List[int]]"
    solve(N, M, C, B, A)

if __name__ == '__main__':
    main()


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

int n;
vector<vector<int>> adj;

vector<pair<int, int>> DP;
const int inf = (int)1e9 + 7;

// dfs for tree, no need for visit array 
void dfs(int i, int p) //bottom up approach, you need to visit a child before process for current node
{
	//visit i
	 //cout << " visit " << i << endl;
	long long  prod1 = 1, prod2=1;
	for (auto x : adj[i])
	{
		if (x == p)
			continue;
		dfs(x, i);
		// color i after visiting all its children
		// if any of i's child is black, i has to white
		// if all i's child is white, then i can be black or white
		// if one of the child is black, i has to be white
		prod2 = (prod2 * ((DP[x].first + DP[x].second) % inf)) % inf;
		prod1 = (prod1 * DP[x].second) % inf;
	}
	DP[i].second = prod2;
	DP[i].first = prod1;

}

int main()
{
	cin >> n;
	adj.resize(n);
	int t1, t2;
	// tree n vertex, n-1 edges, no direction
	for (int i = 0; i < n-1; i++)
	{
		cin >> t1>> t2;
		t1--; t2--;
		adj[t1].push_back(t2);
		adj[t2].push_back(t1);
	}

	// set value for DP array during tree traverse
	// DP[i] should contain two values: first is number of ways to color subtree of i if i is black
	// 2nd is the number of ways to color if i is white

	DP.resize(n);
	dfs(0, -1);
	cout << (DP[0].first + DP[0].second)%inf << endl;
}

Measured memory_bytes: 16316
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm

//#include "BIT.h"

#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}

ll f(ll x) {
	if(x == 1) return 1;
	else {
		return 1+2*f(x >> 1);
	}
}

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

  ll h;
	cin >> h;

	//vector<vector<int>> work(m, vector<int>());

	cout << f(h) << endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <stack>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	cin >> n;
	
	rep(i, n)
	{
		queue<int> a;

		rep(i, 10)
		{
			int in;
			cin >> in;
			a.push(in);
		}


		stack<int> b, c;
		b.push(0);
		c.push(0);

		while(!a.empty())
		{
			// ツ湘ュツづ可つつづ個陛サツつェツ妥・ツつォツつ「
			if(b.top() < c.top()) swap(c, b);

			if(b.top() < a.front())
			{
				b.push(a.front());
				a.pop();
			}
			else if(c.top() < a.front())
			{
				c.push(a.front());
				a.pop();
			}
			else break;
		}

		cout << (a.empty() ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 0
#include <tuple>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
    int N;
    cin >> N;
    
    vector<tuple<string, int, int>> tp;
    for (int i = 1; i <= N; i++) {
        string S;
        int P;
        cin >> S >> P;
        P = -P;
        tp.emplace_back(S, P, i);
    }
    sort(tp.begin(), tp.end());
    
    for (int i = 0; i < N; i++) {
        cout << get<2>(tp[i]) << endl;
    }
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]

C = Counter(S)

print("AC x {}".format(C["AC"]))
print("WA x {}".format(C["WA"]))
print("TLE x {}".format(C["TLE"]))
print("RE x {}".format(C["RE"]))

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

int main(void)
{
    int a, b, c, x, y;

    while(cin >> a >> b >> c >> x >> y && a!=0)
    {
        int sum = 0;
        if(c*2 < a+b)
        {
            if(x > y)
            {
                sum = y*2*c;
               // cout << "y*2=" << y*2<<endl;
                x -= y;
              //  cout << "x=" << x<<endl;
                if(c*2 < a)
                {
                    sum += (x*2*c);
                }
                else
                    sum += (x*a);
            }
            else
            {
                sum = x*2*c;
               // cout << "x*2=" << x*2<<endl;
                y -= x;
              //  cout << "y=" << y<<endl;
                if(c*2 < b)
                {
                    sum += (y*2*c);
                }
                else
                    sum += (y*b);
            }
            cout << sum << endl;
        }
        else
        {
            sum = x*a+b*y;
            cout << sum << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split("\\s+");
		int[] a = new int[n];
		
		for (int i = 0; i < n; i++) a[i] = Integer.parseInt(str[i]);
		
		int i = a.length;
		do {
			sb.append(a[i - 1]);
			i--;
			if ( i == 0) break;
			sb.append(" ");
		} while (true);
		
		System.out.println(sb);
	}
}

Measured memory_bytes: 24464
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
using namespace std;

int main()
{
  ll n,d,count=0;
  cin>>n>>d;
   
 while(n--)
 {  
     double x,y,x2,y2,ans;
    
     cin>>x>>y;
     x2=x*x;
     y2=y*y;
     ans=sqrt(x2+y2);
    
     if(ans<=d)
     {count++;}
     

 } 
    cout<<count;
 
  return 0;
}


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

int main(void) {
    int a,b,c,k;
    int64_t target;
    int64_t remains;
    cin >> a >> b >> c >> k;
    target = max(a,max(b,c)); 
    remains = a + b + c - target;
    target = target * pow(2,k);
    cout << target + remains << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/ruby
def in_(i,j)
	0<=i&&i<H && 0<=j&&j<W
end

H,W=gets.split.map(&:to_i)
a=$<.map{|e|e.chomp.chars}
H.times{|i|
	W.times{|j|
		if a[i][j]=='x'
			(-1..1).each{|i0|(-1..1).each{|j0|
				if in_(i+i0,j+j0)&&a[i+i0][j+j0]=='-'
					a[i+i0][j+j0]='.'
				end
			}}
		elsif a[i][j]=='o'
			(-1..1).each{|j0|
				if in_(i,j+j0)&&a[i][j+j0]=='-'
					a[i][j+j0]='.'
				end
			}
		end
	}
}
p a[1..-1].map{|e|e.count('-')}.reduce(0,:+)

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

int main(){
	while (1) {
		int steps, count=0;
		cin >> steps;
		string leg1, leg2;
		if (steps == 0){ break; }
		int loops;
		if (steps % 2 == 1) { loops = (steps + 1) / 2; }
		else { loops = steps / 2; }
		for (int i = 0; i < loops; i++)
		{
			if (loops - i == 1) {
				if (steps % 2 == 1) {
					cin >> leg1;
					break;
				}
			}
				cin >> leg1 >> leg2;
			if (leg1=="lu"&&leg2=="ru")
			{	count = count + 1;}
			if (leg1 == "ru"&&leg2 == "lu")
			{count = count + 1;}
			if (leg1 == "ld"&&leg2 == "rd")
			{count = count + 1;}
			if (leg1 == "rd"&&leg2 == "ld")
			{count = count + 1;}
		}
		cout << count<<endl;
	};
	return 0;}

Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

void solve()
{
	ll a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
	string ans;
	if (e-a <= k) ans = "Yay!";
	else          ans = ":(";
	cout << ans << '\n';
}

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


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

int main(){
    int n,store=-1;
    cin>>n;
    long long k,sum=0;

    while (n>0){
        n=n-1;
        cin>>k;
        if (k>store){store=k;}

        sum+=store-k;
    }

    cout<<sum;
    return 0;
}

    

        

Measured memory_bytes: 3612
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 200005

struct Info{
	bool operator<(const struct Info &arg) const{

		return X < arg.X;
	}
	ll X,H;
};

ll uniformity[4*NUM],partial[4*NUM];
ll N = 1;
ll D,A;
Info info[NUM];


void init(ll first_N){
	while(N < first_N)N *= 2;
}

void add(ll left,ll right,ll value,ll node_id,ll node_left,ll node_right){

	if(right <= node_left || left >= node_right)return;
	else if(left <= node_left && right >= node_right){
		uniformity[node_id] += value;
	}else{
		partial[node_id] += (min(right,node_right)-max(left,node_left))*value;
		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2,node_right);
	}
}

ll getSum(ll left,ll right,ll node_id,ll node_left,ll node_right){
	if(right <= node_left || left >= node_right)return 0;
	else if(left <= node_left && right >= node_right){
		return (node_right-node_left)*uniformity[node_id]+partial[node_id];

	}else{
		ll sum = (min(right,node_right)-max(left,node_left))*uniformity[node_id];

		sum += getSum(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		sum += getSum(left,right,2*node_id+2,(node_left+node_right)/2,node_right);
		return sum;
	}
}


int main(){

	ll first_N;
	scanf("%lld %lld %lld",&first_N,&D,&A);

	init(first_N);

	for(ll i = 0; i <= 2*N-2; i++){
		uniformity[i] = 0;
		partial[i] = 0;
	}

	for(int i = 0; i < first_N; i++){

		scanf("%lld %lld",&info[i].X,&info[i].H);
	}
	sort(info,info+first_N);

	for(int i = 0; i < first_N; i++){

		add(i,i+1,info[i].H,0,0,N); //半開区間
	}

	int L = 0;
	ll ans = 0,ADD;

	int left,right,mid;
	int R;

	while(true){

		ll left_HP = getSum(L,L+1,0,0,N);

		//printf("L:%d left_HP:%lld\n",L,left_HP);

		if(left_HP%A == 0){

			ADD = left_HP/A;
		}else{

			ADD = left_HP/A+1;
		}

		ans += ADD;

		left = L,right = first_N-1,mid = (left+right)/2;
		R = L;

		while(left <= right){
			if(info[mid].X <= info[L].X+2*D){

				R = mid;
				left = mid+1;
			}else{

				right = mid-1;
			}
			mid = (left+right)/2;
		}

		add(L,R+1,-A*ADD,0,0,N);

		L++;
		while(L < first_N){
			if(getSum(L,L+1,0,0,N) > 0){

				break;
			}
			L++;
		}
		if(L == first_N)break;
	}

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

	return 0;
}


Measured memory_bytes: 14592
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main(){
    int n;
    string s,ans;
    cin>>n>>s;
    ans = s.at(0);
    for(int i=1;i<n;i++){
        if(s.at(i)!=s.at(i-1)){
            ans += s.at(i);
        }
    }
    cout<<ans.size()<<endl;

    return 0;
}

Measured memory_bytes: 512
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    s: Chars
  };

  let p = 2019;
  let mut ten_factor = 1;
  let mut cur = 0;
  let mut counts = vec![0; p];
  counts[0] = 1;
  for i in 0..s.len() {
    let n = s[s.len() - i - 1].to_digit(10).unwrap() as usize;
    let m = (n * ten_factor) % p;
    cur = (cur + m) % p;
    counts[cur] += 1;
    ten_factor = (ten_factor * 10) % p;
  }
  let mut res = 0_u64;
  for c in counts {
    if c < 2 {
      continue;
    }
    res += (c * (c - 1)) / 2;
  }
  println!("{}", res);
}


Measured memory_bytes: 3072
//JOI2010-2011本選問４歩くサンタクロース(Walking Santa)
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

	long long sum = 0LL, osum = 0LL;
	long long f1, f2, f3, w, h, L, HL, temp, oxy[2][2], *LXY[2], ox, oy, max = 0, dx, dy;
	vector<long long> XY[2];
	scanf("%lld %lld",&w, &h);
	scanf("%lld",&L);
	for(f1 = 0; f1 < 2; f1++)
		LXY[f1] = new long long [L];
	//100k
	for(f1 = 0; f1 < L; f1++){
		scanf("%lld %lld",&LXY[0][f1], &LXY[1][f1]);
		XY[0].push_back(LXY[0][f1]);
		XY[1].push_back(LXY[1][f1]);
	}
	//1m
	stable_sort( XY[0].begin(), XY[0].end() );
	stable_sort( XY[1].begin(), XY[1].end() );
	HL = (L + 1) / 2;
	//x軸での最小値の点、y軸での最小値の点を探す
	//200k
	if(L == 1){
		printf("0\n");
		printf("%lld %lld\n",LXY[0][0],LXY[1][0]);
	}
	else{
		for(f1 = 0; f1 < 2; f1++){
			oxy[0][f1] = XY[f1][HL-1];
			oxy[1][f1] = XY[f1][HL];
		}
		dx = (oxy[0][0] == oxy[1][0]) ? 1 : 2;
		dy = (oxy[0][1] == oxy[1][1]) ? 1 : 2;
		//400k
		for(f2 = 0; f2 < dx; f2++){
			for(f3 = 0; f3 < dy; f3++){
				sum = 0LL;
				max = 0LL;
				for(f1 = 0; f1 < L; f1++){
					temp = (long long)abs(LXY[0][f1] - oxy[f2][0]) + abs(LXY[1][f1] - oxy[f3][1]);
					sum += temp;
					if(max < temp)
						max = temp;
				}
				sum *= 2;
				sum -= max;
				if(osum == 0 || osum > sum){
					osum = sum;
					ox = oxy[f2][0];
					oy = oxy[f3][1];
				}
			}
		}
		printf("%lld\n", osum);
		printf("%lld %lld\n", ox, oy);
	}
	return 0;
}

Measured memory_bytes: 4752
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    char a, b; cin >> a >> b;
    if (a > b) swap(a, b);
    cout << string(b - '0', a) << endl; 
    return 0;
}

Measured memory_bytes: 256
public class Hello{
    public static void Main(){
        int N = int.Parse(System.Console.ReadLine());
        int count = 0;
        int ans = 0;
        
        for(int i=1; i<=N; i+=2){
            //if(i%2 != 0){
            //System.Console.WriteLine(i);
            for(int j=1; j<=i; j++){
                if(i%j==0){
                    count++;
                }
            }
            if(count==8){
                ans++;
            }
            count = 0;
            //}
        }
        System.Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17556