akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int n,k;
    cin>>n>>k;
    if(k>(n-1)*(n-2)/2)
    {
        cout<<-1<<endl;
    }
    else
    {
        int m = n*(n-1)/2-k;
        cout<<m<<endl;
        vector<pii> v;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j < i; j++)
            {
                v.push_back(make_pair(j,i));                
            }
        }
        sort(all(v));
        for(int i = 0; i < m; i++)
        {
            cout<<v[i].first<<" "<<v[i].second<<endl;
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	long N=sc.nextLong();
		System.out.println(num(N));

	}
static long num(long N) {
	if(N==0||N==1||N%2==1) {
		return 0;
	}else {
		long ans=0;
		N/=2;
		while(N>=5) {
			ans+=N/5;
			N/=5;
		}
return ans;
	}
}
}

Measured memory_bytes: 23764
num = int(input())
res = num
for i in range(num+1):
    cc = 0
    t = i
    while(t > 0):
        cc += t%6
        t //=6
    t = num-i
    while(t > 0):
        cc += t%9
        t //=9
    if res > cc:
        res = cc

print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

signed main(){
	int k, s, ans = 0;
	scanf("%lld%lld", &k, &s);
	rep(i,k+1)rep(j,k+1){
		int d = s-(i+j);
		if(d < 0 || d > s || d > k)continue;
		ans++;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iomanip>

using namespace std;

int h[30];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k=0,n;
	cin>>n;
	for(i=1;i<=n;i++)cin>>h[i];
	for(i=1;i<=n;i++){
		int f = 1;
		for(j=1;j<=i;j++){
			if(h[j]>h[i])f = 0;
		}
		if(f == 1)++k;
	}
	cout<<k<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
t=l[0][0]
a=l[0][1]
for j in range(1,n):
  z=max((t+l[j][0]-1)//l[j][0],(a+l[j][1]-1)//l[j][1])
  t=l[j][0]*z
  a=l[j][1]*z
print(t+a)

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

# from numba import njit

import itertools
from bisect import bisect_right,bisect_left

INF = 10**10

# @njit
def solve(n,m,x):
  if n >= m:
    return 0
  else:
    d = list(sorted(x[i+1] - x[i] for i in range(m-1)))[::-1]
    res = x[-1] - x[0]
    for i in range(min(m-1,n-1)):
        res -= d[i]
    return res

def main():
  N,M = map(int,input().split())
  x = sorted(list(map(int,input().split())))
  print(solve(N,M,x))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 20432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N;
  cin>>N;
  ll a=0;
  vector<char>vec(N);
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(ll i=0;i<N-2;i++){
    if(vec.at(i)=='A'&&vec.at(i+1)=='B'&&vec.at(i+2)=='C'){
      a+=1;
    }
  }
  cout<<a<<endl;
  
}


Measured memory_bytes: 3624
A,B = map(int,input().split())
x = 0
up = int(min(12.5*(A+1),10*(B+1)))
down = int(max(12.5*A,10*B))
if up - down  >=1 :
  if max(12.5*A,10*B) == down:
    print(down)
  else:
    print(down+1)
else:
  print(-1)

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

using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N, Q;
pair <ll, pair <ll, ll>> vv[MAXN];

map <ll, ll> mleft;
map <ll, ll> mres;

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> N >> Q;
    for (int i = 0; i < N; i++)
    {
        cin >> vv[i].second.first >> vv[i].second.second >> vv[i].first;
    }

    sort (vv, vv + N);

    mleft[1e12] = -1e12;
    for (int i = 0; i < N; i++)
    {
        ll s = vv[i].second.first, t = vv[i].second.second;
        ll d = vv[i].first;

        s -= d;
        t -= d;

        auto it = mleft.upper_bound(s);
        while (it->first <= t)
        {
            if (it->second < s)
            {
                mleft[s] = it->second;
            }
            mres[it->first] = d;

            it = mleft.erase(it);
        }
        if (it->second < t)
        {
            if (it->second < s)
                mleft[s] = it->second;
            it->second = t;
            mres[t] = d;
        }
    }

    for (int i = 0; i < Q; i++)
    {
        int D; cin >> D;
        auto it = mleft.upper_bound(D);
        auto dit = mres.upper_bound(D);
        if (it->second <= D)
            cout << "-1\n";
        else
            cout << dit->second << "\n";
    }
}

Measured memory_bytes: 29312
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

long long int h[100007];
int main()
{
    int N;
    scanf("%d\n",&N);
    for(int i=0; i<N; i++){ scanf("%lld ",&h[i]); }

    long long int maxh=0;
    for(int i=0; i<N; i++)
    {
        maxh=max(maxh, h[i]);
        //printf("%lld %lld\n",maxh, h[i]);
        if(maxh-h[i]>1){ printf("No\n"); return 0; }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
 
int main(void)
{
  int n,k,c=0;
  
  scanf("%d%d",&n,&k);
  int h[n];
  for(int i=0;i<n;i++){scanf("%d",&h[i]);}
  for(int i=0;i<n;i++){
      if(h[i]>=k){c++;}
  }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 512
d, g = gets.split.map(&:to_i)
ps, cs = [], []
1.upto(d) do
  p, c = gets.split.map(&:to_i)
  ps << p; cs << c
end

min_num_probs = 100 * 10 + 1
[true, false].repeated_permutation(d).each do |bs|
  num_probs, score = 0, 0
  (0..(d-1)).each do |i|
    if bs[i]
      score += (i+1) * 100 * ps[i] + cs[i]
      num_probs += ps[i]
    end
  end

  if score >= g
    min_num_probs = [min_num_probs, num_probs].min
    next
  end

  maxi = bs.rindex(false)
  next if maxi.nil?

  diff = g - score
  num_probs_i = (diff / ((maxi + 1) * 100).to_f).ceil
  next if num_probs_i >= ps[maxi]

  min_num_probs = [min_num_probs, num_probs + num_probs_i].min
end

puts min_num_probs

Measured memory_bytes: 1916
from itertools import combinations_with_replacement, combinations

N = int(input())

alphabets = [chr(i) for i in range(97, 97+26)]

def dfs(S, i):
    if len(S) == N:
        yield ''.join(S)
        return

    for j in range(i):
        for w in dfs(S + [alphabets[j]], i): # S.append(hoge)は不可。Sを破壊してしまうため
            yield w

    for w in dfs(S + [alphabets[i]], i + 1):
        yield w

for w in dfs([], 0):
    print(w)


Measured memory_bytes: 4428
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int s[55];
int main(){
	cin>>a>>b; 
	for(int i=1;i<a+1;i++){
		scanf("%d",&s[i]);
	}
	sort(s+1,s+a+1);
	for(int i=a;i>0;i--){
		if(b==0)break;
		c+=s[i],b--;
	}
	printf("%d",c);
	return 0;
}


Measured memory_bytes: 256
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SORT(v) sort(all(v))
#define TROS(v) sort(all(v), std::greater<Type>());
#pragma endregion

int main() {
    // template
    int a,b,x;cin>>a>>b>>x;
    if(a <= x && x <= a+b) cout<<"YES";
    else cout<<"NO";
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

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

  ll ans = 0;
  ll bc = 0;
  int state = 0;
  for (int i = s.size() - 1; i >= 0; i--)
  {
    switch (state)
    {
    case 0:
      bc = 0;
      if (s[i] == 'C')
      {
        state++;
      }
      break;
    case 1:
      if (s[i] == 'B')
      {
        state++;
        bc++;
      }
      else if (s[i] == 'A')
      {
        state = 0;
      }
      else
      {
        bc = 0;
      }
      break;
    case 2:
      if (s[i] == 'A')
      {
        ans += bc;
      }
      else if (s[i] == 'B')
      {
        state = 0;
      }
      else
      {
        state = 1;
      }
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        int x,t=1;
        Scanner sc = new Scanner(System.in);
        while(true){
            x=sc.nextInt();
            if(x == 0) break;
            System.out.println("Case "+ t++ +": "+x);
        }
    }
}

Measured memory_bytes: 31364
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int x;
	cin >> x;
	if (x < 4)
	{
		cout << 1;
		return 0;
	}
	for (int i = x; i >= 1; --i)
	{
		for (int j = 2
			; j <= i; ++j)
		{
			if (i%j == 0)
			{
				int pw = j;
				while (pw < i)
				{
					pw *= j;
				}
				if (pw != j && pw == i)
				{
					cout << i;
					return 0;
				}
			}
		}
	}
	sp;
}

Measured memory_bytes: 256
K = int(input())
Lun_count = 0
if K<=9:
    print(K)
else:
    N=10
    Lun_count = 9
    while(1):
        strN = list(str(N))
        lenN = len(strN)
        for i in range(1,lenN):
            if int(strN[i-1])-int(strN[i]) > 1:
                strN[i]= str(int(strN[i-1])-1)
                N = int(''.join(strN))
                break
            elif int(strN[i-1])-int(strN[i]) < -1:
                strN[i-1] = str(int(strN[i-1])+1)
                strN[i] = '0'
                N = int(''.join(strN))
                break
        else:
            Lun_count +=1
            if Lun_count == K:
                break
            N +=1
    print(N)

Measured memory_bytes: 3188
import itertools as ite
import math
import random

INF = 10 ** 18
MOD = 10 ** 9 + 7

def func(diff, cnt9, cnt0):
    if cnt9 <= 0:
        return (diff == 0)
    num = int("9" * cnt9 + "0" * cnt0)
    ret = 0
    for i in range(-9, 10):
        if abs(diff + i * num) < num:
            MUL = 9 - abs(i) + 1
            MUL -= (cnt0 == 0)
            ret += func(diff + i * num, cnt9 - 2, cnt0 + 1) * MUL
    return ret

D = input()

ans = 0
for d in range(1, 21):
    MUL = 1 if d % 2 == 1 else 10
    ans += func(D, d, 0) * MUL
print ans


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


int main() {
int n;
cin >> n;
map<string,int> m;
rep(i,n) {
  string a;
  cin >> a;
  sort(a.begin(),a.end());
  m[a]++;
}
ll ans = 0;
for (auto p: m) {
  ll s = p.second;
  ans += s * (s-1) /2;
}

cout << ans << endl;

return 0;
}



Measured memory_bytes: 11384
#include <iostream>
#include <cmath>
#include <iomanip>
#define sqr(x) ((x) * (x))
using namespace std;

void equation(double a, double b, double c, double d, double e, double f, double *x, double *y)
{
  *x = (c * e - b * f) / (a * e - b * d);
  *y = (a * f - c * d) / (a * e - b * d);   
}


int main()
{
  int n;
  double x1, y1, x2, y2, x3, y3, x, y;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    x = y = 0;
    equation((2 * (x2 - x1)), (2 * (y2 - y1)), (sqr(x2) + sqr(y2) - sqr(x1) - sqr(y1)), (2 * (x3 - x2)), (2 * (y3 - y2)), (sqr(x3) + sqr(y3) - sqr(x2) - sqr(y2)), &x, &y);
    cout << fixed << setprecision(3) << x << ' ' << y << ' ' << sqrt(sqr(x1 - x) + sqr(y1 - y)) << endl;
  }
}

Measured memory_bytes: 1288
n = int(input())
c = n
def digitsum(n):
  s = 0
  while n>0:
    s += n % 10
    n //= 10
  return s
for i in range(1, n//2+1):
  a = digitsum(i)
  b = digitsum(n-i)
  if c > a + b:
    c = a + b
print(c)

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 998244353;

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

    vector<vector<ll>> board(8, vector<ll>(8, 1));
    for(ll i=0; i<8; i+=2) for(ll j=1; j<8; j+=2) board[i][j] = 0;

    ll q;
    cin >> q;
    REP(i, q) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        ll ret = 0;
        FOR(y, a, c+1) FOR(x, b, d+1) {
            ret += board[y][x];
        }
        cout << ret << endl;
    }

    return 0;
}



Measured memory_bytes: 3196
#include <stdio.h>
#include <string.h>
#define MN 200000
int n,cnt=0;
bool e[MN+5];
int d[MN+5],hd[MN+5],to[MN+5],nxt[MN+5],rn=0;
struct STACK{
	int tp,m[MN+5];
	STACK(){tp=0;}
	bool empty(){return tp==0;}
	int top(){return m[tp];}
	void push(int x){m[++tp]=x;}
	void pop(){--tp;}
}s;
inline void add(int u,int v){
	++rn; d[u]++;
	nxt[rn]=hd[u],hd[u]=rn;
	to[rn]=v;
}
int main(){
	memset(hd,0xff,sizeof(hd));
	memset(d,0,sizeof(d));
	memset(e,true,sizeof(e));
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;i++){
		if(d[i]==1)s.push(i);
	}
	while(!s.empty()){
		int u=s.top(); s.pop();
//		printf("d %d %d\n",u,d[u]);
		if((!e[u])||(d[u]<=0))continue;
//		printf("del %d\n",u);
		e[u]=false; cnt++;
		for(int i=hd[u];i!=-1;i=nxt[i]){
			if((!e[to[i]])||(d[to[i]]<=0))continue;
//			printf("del %d-%d\n",u,to[i]);
			e[to[i]]=false; cnt++;
			for(int j=hd[to[i]];j!=-1;j=nxt[j]){
//				printf("spread %d-%d\n",to[i],to[j]);
				d[to[j]]--;
				if(d[to[j]]==1)s.push(to[j]);
			}
		}
	}
	puts(cnt==n?"Second":"First");
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
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; }
using namespace std;

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

    int n,m; cin>>n>>m;
    vector<int> ab(n*m,0);
    rep(i,n){int t; cin>>t; ab[t-1]++;}
    rep(i,m){int t; cin>>t; ab[t-1]+=2;}

    int ans=1,vert=0,side=0;
    for(int i=n*m-1; i>=0; i--){
        if(ab[i]==3){
            vert++; side++;
        }else if(ab[i]==2){
            if(vert==0){
                cout<<0<<endl; return 0;
            }
            ans=ans*vert%mod; side++;
        }else if(ab[i]==1){
            if(side==0){
                cout<<0<<endl; return 0;
            }
            ans=ans*side%mod; vert++;
        }else{
            int tmp=vert*side-(n*m-1-i);
            if(tmp<=0){
                cout<<0<<endl; return 0;
            }
            ans=ans*tmp%mod;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    ll a, b, c, d; cin >> a >> b >> c >> d;
    auto calc = [&](ll x) {
        if (x == 0) {
            return 0ll;
        }
        ll same = c * d / __gcd(c, d);
        ll times = x - x / c - x / d + x / same;
        return times;
    };
    cout << calc(b) - calc(a - 1);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main()
{

    int M, D;
    cin >> M >> D;

    int ans = 0;
    REP(m,M+1) REP(d,D+1) {
        int d10 = d/10;
        int d1 = max(0,d-d10*10);
        if (d1 <= 1 or d10 <= 1) continue;

        if (d1*d10 == m) {
            ans++;
            //cout << m << "/" << d << endl;
        }
    }

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


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

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int a, b;
	cin >> a >> b;
	cout << (a * 3 + b) / 2 << "\n";
}


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


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

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

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    string t = s;
    reverse(all(t));
    REP(i,n){
        if(t[i]=='b'){
            t[i] = 'd';
        }else if(t[i]=='d'){
            t[i] = 'b';
        }else if(t[i]=='p'){
            t[i] = 'q';
        }else{
            t[i] = 'p';
        }
    }
    if(s==t){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int h,w;
	cin>>h>>w;
	char a[h][w];
	rep(i,h)rep(j,w)cin>>a[i][j];

	bool h_flag[h],w_flag[w];
	rep(i,h)h_flag[i]=true;
	rep(i,w)w_flag[i]=true;
	rep(i,h){
		rep(j,w){
			if(a[i][j]=='#'){
				h_flag[i]=false;
				w_flag[j]=false;
			}
		}
	}

	rep(i,h){
		rep(j,w){
			if((!h_flag[i]) && (!w_flag[j]))cout<<a[i][j];
		}
		if(!h_flag[i])cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int i = sc.nextInt();
		
		System.out.println(N - i + 1);
	}

}

Measured memory_bytes: 23380
import java.io.*;
import java.util.*;
  
public class Main {
  
    public static void main(String[] args)
            throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
 int sum=100000;
 
             for(int n=scan.nextInt();n>0;n--){
sum *=1.05;
int m= up3(sum);
if(m!=0)
sum+=1000-m;
}
System.out.println(sum);
}
public static int up3(int n){
return n%1000;
 
        }
}

Measured memory_bytes: 11000
#include<iostream>
using namespace std;
int n, m, a, b, c, i, sum=0, Max=0;
int main(){
    cin >> n >> m;
    for( i = 1; i <= m; i++ ){
        cin >> a >> b;
        c = n - a;
        if( c > 0 ){
            sum += c;
        }
        if( c > Max ){
            Max = c;
        }
    }
    cout << sum - Max << endl;
    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <map>
#include <cstdio>
using namespace std;

int main(){
	int n;scanf("%d", &n);
	char s[7], str[13];
	map<string, bool> m;
	for(int i = 0;i < n;i++){
		scanf("%s %s", s, str);
		if(s[0] == 'i')m[str] = true;
		else puts(m[str] ? "yes" : "no");
	}
	return 0;
}
//1.78
//0.87

Measured memory_bytes: 47584
#include <bits/stdc++.h>
 
using namespace std;
 
#define ALL(x) x.begin(), x.end()
 
typedef long long int lld;
typedef pair<int, int> pii;
 
const int maxn = 1e5 + 5;
bool dp[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;
 
	int n, a, b;
	cin >> n >> a >> b;

	cout << min(n * a, b) << '\n';
 
 
	return 0;
}

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

using namespace std;

int main() {
    
    int n, q;
    cin >> n >> q;
    vector<long long> a(n);
    
    vector<long long> a_o(n);
    vector<long long> a_e(n);
    vector<long long> a_s(n);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if ((i + 1) % 2)
        {
            a_o[i] += a[i];
        }
        else
        {
            a_e[i] += a[i];
        }
        a_s[i] += a[i];
        
        if (i > 0)
        {
            a_o[i] += a_o[i - 1];
            a_e[i] += a_e[i - 1];
            a_s[i] += a_s[i - 1];
        }
    }
    
    for (int query = 0; query < q; ++query)
    {
        long long x;
        cin >> x;
        
        auto itr = lower_bound(a.begin(), a.end(), x);
        if (*itr != x && itr != a.begin())
        {
            itr--;
        }
        
        int startpos = itr - a.begin();
        int endpos = n - 1;
        while (endpos - startpos > 1)
        {
            int mid = (startpos + endpos) / 2;
            auto itr = lower_bound(a.begin(), a.end(), (2 * x - a[mid]));
            int pos = itr - a.begin();
            if (mid - pos + 1 > n - 1 - mid)
            {
                endpos = mid;
            }
            else if (mid - pos + 1 < n - 1 - mid)
            {
                startpos = mid;
            }
            else
            {
                startpos = mid;
                break;
            }
            
        }
        
        long long right = 0;
        long long left = 0;
        
        right = a_s[n - 1] - a_s[startpos];
        
        int num = n - 1 - startpos;
        if (startpos - num > -1)
        {
            if (n % 2)
            {
                left = a_o[startpos - num];
            }
            else
            {
                left = a_e[startpos - num];
            }
        }
        
        long long ret = left + right;
        
        
        cout << ret << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4864
using System;

namespace PrintRectangle
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			while (true) {
				string[] tmp = Console.ReadLine ().Split (" ".ToCharArray ());
				int height, Wide;

				height = int.Parse (tmp [0]);
				Wide = int.Parse (tmp [1]);
				if (height == 0 && Wide == 0)
					break;

				for (int i = 0; i < height; i++) {
					for (int j = 0; j < Wide; j++) {
						Console.Write ("#");
					}
					Console.Write ("\n");
				}
				Console.Write ("\n");
			}
		}
	}
}

Measured memory_bytes: 5288
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t; cin >> s >> t;
	int ans = 0;
	rep(i, 3) {
		if (s.at(i) == t.at(i)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W,D;
  cin >> H >> W >> D;
  vector<vector<int>> A(H,vector<int>(W));
  map<int,pair<int,int>> m;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin >> A[i][j];
      m[A[i][j]]=make_pair(i,j);
    }
  }
  vector<int> cost(H*W,0);
  for (int i=D+1;i<=H*W;i++){
    cost[i]=cost[i-D]+abs(m[i].first-m[i-D].first)+abs(m[i].second-m[i-D].second);
  }
  int Q;
  cin >> Q;
  for (int i=0;i<Q;i++){
    int L,R;
    cin >> L >> R;
    cout << cost[R]-cost[L] << endl;
  }
}

Measured memory_bytes: 7808
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    VI a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));
    REP(i, n) {
        if(x - a[i] < 0) {
            cout << i << endl;
            return 0;
        }
        x -= a[i];
    }
    
    if(x == 0) cout << n << endl;
    else cout << n - 1 << endl;
    return 0;
}


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

int main()
{

	int N;
	cin >> N;

	int count = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if ((i + 1) % 2 == 1 && a % 2 == 1) {
			count++;
		}
	}

	cout << count << endl;
}






Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in); 
		int a = Integer.parseInt(scanner.next());
		if(a<=3){
			System.out.println("1");
			return;
		}
		
		int maxBeki=0;
		int i =0;
		int j =0;
		for(i=2;;i++){
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		}
		System.out.println(maxBeki);		
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	long long a[n], b[n];
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
		a[i]+=b[i]*1000000000;
	}
	sort(a, a+n);
	sort(b, b+n);
	long long Time=0;
	for(int i=0; i<n; i++){
		a[i]-=b[i]*1000000000;
		if(Time+a[i]<=b[i]) Time+=a[i];
		else{
			cout << "No";
			return 0;
		} 
	}
	cout << "Yes";
}

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

int main() {
  int k,n,ans=1e9;
  cin >> k >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  ans = min(ans,a[n-1]-a[0]);
  for(int i=0;i<n-1;i++){
    ans = min(ans,k+a[i]-a[i+1]);
  }
  cout << ans << endl;
}


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

int n,m;
int k[100],s[100][100],p[100];

int req(int i,bool f[]){
  if(i == n){
    for(int j = 0; j < m; ++j){
      int count = 0;
      for(int l = 0; l < k[j]; ++l){
	if(f[s[j][l]])count++;
      }
      if(count % 2 != p[j])return 0;
    }
    return 1;
  }
  f[i] = true;
  int a = req(i+1,f);
  f[i] = false;
  int b = req(i+1,f);
  return a+b;
}



int main(){
  cin>>n>>m;
  for(int i = 0; i < m; ++i){
    cin>>k[i];
    for(int j = 0; j < k[i]; ++j){
      cin>>s[i][j];
      s[i][j]--;
    }
  }
  for(int i = 0; i < m; ++i){
    cin>>p[i];
  }

  bool f[10];
  cout<<req(0,f)<<endl;

  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  readLine.split(" ").map(_.toLong) match {
    case Array(1, 1) => println(1)
    case Array(1, m) => println(m - 2)
    case Array(n, 1) => println(n - 2)
    case Array(n, m) => println((n - 2) * (m - 2))
  }
}


Measured memory_bytes: 25424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int D, G;
int p[10], c[10];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> D >> G;
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
  }
  int ans = 1 << 30;
  for (int i = 0; i < 1 << D; i++) {
    int sum = 0, cnt = 0;
    for (int j = 0; j < D; j++) {
      if (i >> j & 1) {
        cnt += p[j];
        sum += (j+1)*100*p[j] + c[j];
      }
    }
    int rem = G - sum;
    if (rem > 0) {
      for (int j = D-1; j >= 0; j--) {
        if (i >> j & 1) continue;
        int pt = (j+1)*100;
        if (rem - pt*(p[j]-1) > 0) {
          cnt += p[j]-1;
          rem -= pt*(p[j]-1);
        } else {
          int tmp = (rem+pt-1)/pt;
          cnt += tmp;
          rem -= tmp*pt;
          break;
        }
      }
    }
    if (rem <= 0) ans = min(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
lst=list(map(int,input().split()))
if len(set(lst))==1:
    print(n//2)
    exit()
a=sorted(lst[::2])
b=sorted(lst[1::2])

import collections
a=collections.Counter(a)
b=collections.Counter(b)
a=a.most_common()
b=b.most_common()
if a[0][0]!=b[0][0]:
    print(n//2-a[0][1]+n//2-b[0][1])
else:
    print(min(n//2-a[0][1]+n//2-b[1][1],n//2-a[1][1]+n//2-b[0][1]))

Measured memory_bytes: 107204
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
  int n;
  double score[1000], S, avg;

  scanf("%d", &n);
  while(n != 0){
    avg = 0; S = 0;
    for(int i=0; i<n; i++){
      scanf("%lf", &score[i]);
      avg += score[i];
    }
    avg /= (double)n;
    for(int i=0; i<n; i++){
      S += (score[i]-avg) * (score[i]-avg);
    }
    S = sqrt(S/(double)n);
    printf("%.8f\n", S);
    scanf("%d", &n);
  }
  return 0;
}



Measured memory_bytes: 3204
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn main() {
    let s = read_line();

    if s.len() == 26 {
        let mut cs: Vec<u8> = s.as_bytes().to_owned();
        let mut cand = vec![];
        while let Some(last) = cs.pop() {
            cand.push(last);
            cand.sort();

            for c in cand.iter() {
                let t = format!("{}{}", String::from_utf8(cs.clone()).unwrap(), *c as char);
                // eprintln!("* {}", t);

                if t > s {
                    println!("{}", t);
                    return;
                }
            }
        }

        println!("-1");
    } else {
        for i in 0..26 {
            let c = ('a' as u8 + i) as char;
            if !s.contains(c) {
                println!("{}{}", s, c);
                return;
            }
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i,n) for(int i=0; i<n; i++)
#define FOR2(i, z, n) for(int i=z; i<n; i++)

int find_index(vector<int> &subsequence, int length, int start, int value) {
  while(length - start > 1) {
    int medium = start + (length - start) / 2;
    if (subsequence[medium] >= value)
      length = medium;
    else
      start = medium;
  }
  return length;
}

int main() {
  int nbr;
  cin >> nbr;
  vector<int> sequence(nbr);
  vector<int> subsequence(nbr, 0);
  int length = 1;

  FOR(i, nbr) {
    int val;
    cin >> val;
    sequence[i] = val;
  }

  subsequence[0] = sequence[0];

  FOR2(i, 1, sequence.size()) {
    if (sequence[i] < subsequence[0])
      subsequence[0] = sequence[i];
    else if (sequence[i] > subsequence[length - 1])
      subsequence[length++] = sequence[i];
    else {
      subsequence[find_index(subsequence, length - 1, -1, sequence[i])] = sequence[i];
    }
  }

  cout << length << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
int main()
{
    int K;
    string S;
    cin >>K>>S;
    int slength=S.size();
    if(slength<=K){
        cout<<S<<endl;
    }else{
        cout<<S.substr(0,K)<<"..."<<endl;
    }
}

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

typedef long long LL;
#define SZ(a) int((a).size())
#define FOR(var,a,b) for(int var=(a);var<(b);var++)
#define REP(var,n) FOR(var,0,n)
#define INT(n) int n;scanf("%d",&n);

int main(){
  INT(n);
  int ans = n;
  FOR(i, 2, 100000){
    if (n < i * i){break;}
    if (n % i == 0){
      ans = ans / i * (i - 1);
    }
    while (n % i == 0){n /= i;}
  }
  if (1 < n){
    ans = ans / n * (n - 1);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	if(c=='-')f=-1,c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
map<string,ll>m;
ll n;
int main(){
	n=d;
	while(n--){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
	return 0;
}


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

int main() {

    int r, D, x;
    cin >> r >> D >> x;
    rep(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){

  int N,k[10000],count1,count2;

  while(1){
  
    cin >>N;
  
    if( N == 0 )break;
    
    count1=0;
    count2=0;
    
    for(int i=0 ; i < N ; i++){
      cin >>k[i];
      if(k[i] > 0)count1++;
      if(k[i] > 1)count2++;
    }

    if(count2 == 0){
      cout <<"NA"<<endl;
    }else{
      cout <<count1+1<<endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 1200
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

int main() {
    int N, x;
    cin >> N >> x;
    int a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] > x) {
            ans += a[i] - x;
            a[i] = x;
        }
        if (i && a[i]+a[i-1] > x) {
            ans += a[i] + a[i-1] - x;
            a[i] -= a[i] + a[i-1] - x;
        }
    }

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


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
#define watch(x) cout << (#x)<<" = "<<x<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	file();
	fast();
	int a; cin >> a;
	cout << a + a * a + a * a * a;
	
	return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int num[500005],s2[500005];
int now[15];

int getsum(int k) {
  int s=0,cnt=0;
  while (k) {
  	now[++cnt]=k%10;
  	s+=now[cnt];
  	k/=10;
  }
  int g=0;
  for(int i=1;i<=cnt;i++) {
  	g=(num[i]+now[i]+g)/10;
  	s-=9*g;
  }
  if (g) s-=9*s2[cnt+1];
  return s;
}

int calc(int n) {
  int s=0;
  for(int i=1;i<=n;i++) s+=num[i];
  int t=0;
  for(int i=n;i>0;i--) {
  	if (num[i]==9) t++; else t=0;
  	s2[i]=t;
  }
  for(int ans=1;;ans++)
    if (s+getsum(ans)<=ans) return ans;
}

char str[500005];

void mul(int &n) {
  for(int i=1;i<=n;i++) num[i]=str[n-i+1]-'0';
  int g=0;
  for(int i=1;i<=n;i++) {
  	num[i]=num[i]*9+g;
  	g=num[i]/10;num[i]%=10;
  }
  if (g) num[++n]=g;
}

int main() {
  scanf("%s",str+1);
  int n=strlen(str+1);
  mul(n);
  printf("%d\n",(calc(n)+8)/9);
  return 0;
} 

Measured memory_bytes: 4608
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
)

var outCnt int
var out bytes.Buffer

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	H := nextInt()
	W := nextInt()
	var f Filed
	f.mas = make([][]int, H)
	for i := 0; i < H; i++ {
		f.mas[i] = nextInts(W)
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W-1; j++ {
			if f.mas[i][j]%2 == 1 {
				f.Move(i, j, i, j+1)
			}
		}
	}
	for i := 0; i < H-1; i++ {
		j := W - 1
		if f.mas[i][j]%2 == 1 {
			f.Move(i, j, i+1, j)
		}
	}
	fmt.Println(outCnt)
	fmt.Print(out.String())
	// out.WriteTo(os.Stdin)
	// log.Print("\n", f.String())
}

type Filed struct {
	mas [][]int
}

func (f *Filed) Move(a, b, c, d int) {
	out.WriteString(fmt.Sprintf("%d %d %d %d\n", a+1, b+1, c+1, d+1))
	outCnt++
	if f.mas[a][b] <= 0 {
		panic("error")
	}
	f.mas[a][b]--
	f.mas[c][d]++
}

func (f Filed) String() string {
	var out bytes.Buffer
	for i := 0; i < len(f.mas); i++ {
		out.WriteString(fmt.Sprintln(f.mas[i]))
	}
	return out.String()
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


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

int main(){
  string s;
  cin >> s;
  bool ok = 1;
  int n = s.size();
  rep(i,n/2){
    if(s[i]!=s[n-1-i])ok = 0;
  }
  rep(i,(n-1)/4){
    if(s[i]!=s[(n-1)/2-1-i])ok = 0;
  }
  for(int i = (n+3)/2-1;i<n;i++){
    if(s[i]!=s[(n+3)/2-1+n-1-i])ok = 0;
  }
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
 
 
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    
    
    public static void main(String args[] ) throws Exception {
        StringBuffer str = new StringBuffer();
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
        }
        long[] dp = new long[n];
        for(int i=1;i<n;i++){
            long min = Integer.MAX_VALUE;
            int in = Math.max(0,i-k);
            for(int j=i-1;(j>=in);j--){
                if(min>dp[j]+Math.abs(a[i]-a[j]))
                    min=dp[j]+Math.abs(a[i]-a[j]);
            }
            dp[i] = min;
        }
        
        str.append(dp[n-1]);
        
        pw.println(str.toString());
        
        pw.close();
    }
     
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String next(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
	    
	}
   
}

Measured memory_bytes: 45016