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

#define debug(a) cerr << #a << " = " << (a) << endl;
#define get(t, i) get<(i)>((t))
#define fst first
#define snd second
#define all(X) begin(X), end(X)

template<typename T> ostream& operator<<(ostream& o, const vector<T>& v) {
  o << '['; int b = 0; for (const auto& a : v) o << (b++ ? ", " : "") << a; o << ']'; return o;
}

template<typename T, typename U> ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << '(' << p.fst << ", " << p.snd << ')'; return o;
}

template<typename T> ostream& operator<<(ostream& o, const set<T>& s) {
  o << '{'; int b = 0; for (auto& e : s) o << (b++ ? ", " : "") << e; o << '}'; return o;
}

typedef long long ll;
ll mod = 1000000007;
ll n, m;
char A[1010][1010];
ll dp[1010][1010];

ll f(int i, int j) {
  if (i == n-1 and j == m-1) return 1;
  if (i == n or j == m) return 0;
  if (A[i][j] == '#') return 0;

  ll& x = dp[i][j];
  if (x != -1) return x;
  return x = (f(i+1, j) + f(i, j+1)) % mod;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    cin >> A[i];
    for (int j = 0; j <= m; j++) dp[i][j] = -1;
  }

  cout << f(0, 0) << endl;
}



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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a;
	multiset<int> st;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		st.insert(a);
	}
	int ans=0,now=-1;
	auto i=st.upper_bound(now);
	while (i!=st.end())
	{
		now=*i;
		if (st.count(now)>=now)
		{
			ans+=st.count(now)-now;
		}
		else
		{
			ans+=st.count(now);
		}
		i=st.upper_bound(now);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int main()
{
    string s;ll m;
    cin>>s;
    cin>>m;

    for(int i=0;i<s.length();i++)
    {
        if(s[i]!='1')
        {

            printf("%d\n",s[i]-'0');
            return 0;
        }
        if(i+1==m)
        {
            printf("%d\n",s[i]-'0');
            return 0;
        }
    }
    printf("1\n");
    return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, c;
    cin >> a >> b >> c;

    bool f = false;
    if (a >= c)
        f = true;
    else if (b >= c)
        f = true;
    else if (a + b >= c)
        f = true;

    if (f)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll nCr(ll n, ll r) {
  if (r > n) {
    return 0;
  }
  if (r == 0 || n == r) {
    return 1;
  }
  if (r * 2 > n) {
    r = n - r;
  }

  ll result = n;
  for (ll i = 2; i <= r; i++) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}

const int n_max = 200001;

ll N;
vector<ll> A;
vector<ll> cnt;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  cnt.resize(n_max);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[i] = a;
    cnt[A[i]]++;
  }

  ll sum = 0;
  for (int i = 0; i < n_max; i++) {
    sum += nCr(cnt[i], 2);
  }

  for (int i = 0; i < N; i++) {
    ll ans = sum - nCr(cnt[A[i]], 2) + nCr(cnt[A[i]] - 1, 2);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d,cnt=0,mx,prd;
  cin>>a>>b>>c>>d;
  mx=a*c;
  long long arr[3]={a*d,b*c,b*d};
  	for(int k=0;k<3;k++){
    	if(arr[k]>mx) mx=arr[k];
      }
  cout<<mx;
	return 0;  
}

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

int main () {
  string s;
  cin >>s;
  bool A =false;
  bool B =false;

  if(s.at(2) =='0' && s.at(3) !='0')A =true;
  if(s.at(2) =='1' && s.at(3) =='1')A =true;
  if(s.at(2) =='1' && s.at(3) =='2')A =true;
  if(s.at(0) =='0' && s.at(1) !='0')B =true;
  if(s.at(0) =='1' && s.at(1) =='1')B =true;
  if(s.at(0) =='1' && s.at(1) =='2')B =true;

  if(A == false && B==false)cout<<"NA"<<endl;
  if(A == true && B==false)cout<<"YYMM"<<endl;
  if(A == false && B==true)cout<<"MMYY"<<endl;
  if(A == true && B==true)cout<<"AMBIGUOUS"<<endl;
return 0;
}


Measured memory_bytes: 256
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))

#%%
N = int(input())
for _ in range(N):
    b = int(input())
    for i in range(3):
        if r1[i] == b:
            r1[i] = 0
        if r2[i] == b:
            r2[i] = 0
        if r3[i] == b:
            r3[i] = 0

#%%
flag = False
if sum(r1) == 0:
    flag = True
if sum(r2) == 0:
    flag = True
if sum(r3) == 0:
    flag = True
for i in range(3):
    if sum([r1[i], r2[i], r3[i]]) == 0:
        flag = True
if sum([r1[0], r2[1], r3[2]]) == 0:
    flag = True
if sum([r1[2], r2[1], r3[0]]) == 0:
    flag = True

if flag == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38420
/*
*******************
2018-10-28 Sun
*******************
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
const int INF = 1<<29;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int LL;

ll n;
ll A[100005];

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(NULL);
    cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

    cin >> n;
    FOR(i,0,n)
        cin >> A[i];
    sort(A,A+n);

    vector<ll> b(n),c(n);
    int l=0,r=n-1;
    for(int i=1;i<n;i+=2)
        b[i]=A[l++],c[i]=A[r--];

    l=0,r=n-1;
    for(int i=2;i<n;i+=2)
        b[i]=A[r--],c[i]=A[l++];

    b[0]=A[r],c[0]=A[l];
    ll p=0,q=0;

    FOR(i,1,(int)b.size())
        p+=abs(b[i]-b[i-1]);
    FOR(i,1,(int)c.size())
        q+=abs(c[i]-c[i-1]);

    cout << max(p,q) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main(){
    
    ll n,a,b;
    cin >> n >> a >> b;
    vector <ll> v;
    for (ll i=0;i<n;i++){
        ll p;
        cin >> p;
        v.push_back(p);
    }
    ll ans = 0;
    for (ll i=0;i<n-1;i++){
        if((v[i+1] - v[i])*a <= b){
            ans += (v[i+1] - v[i])*a;
        }else{
            ans += b;
        }
    }
    cout << ans << endl;

}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;

    int cnt = 0;
    int maxrep = A + B + C; // ここでTLEになる。

    // 計算式求めればいいだけ。
    if((A + B + 1) > C) {
        cout << B + C << endl;
    } else {
        cout << A + 2 * B + 1 << endl;
    }
}

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[] a = new int[n+1];
        int[] b = new int[n+1];
        int[] c = new int[n];
        int ret = 0;
        for(int i = 1; i <= n ;i++){
            a[i] = sc.nextInt();
        }
        for(int x = 1; x <= n ;x++){
            b[x] = sc.nextInt();
        }
        for(int y = 1; y <= n-1 ;y++){
            c[y] = sc.nextInt();
        }
        for(int z = 1; z <= n;z++ ){
            if(z != n && a[z] + 1 == a[z+1]){
                ret += c[a[z]];
            }
            ret += b[a[z]];
            
        }

        System.out.println(ret);
        sc.close();
    }
}


Measured memory_bytes: 21844
n,k=map(int,input().split())
s=input()
a=[]
for i in range(n):
    if(s[i]=="L"):
        a.append(-1)
    else:
        a.append(1)
gen=0
for i in range(n):
    num=i+a[i]
    if(num>=0 and num <=n-1):
        if(a[i]*a[num]==1):
            gen+=1

ans=gen+k*2
if(ans>=n):
    ans=n-1
print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a-1);
  vector<int> c(a);
  rep(i,a-1)
    cin>>b[i];
  rep(i,a-1){
  c[b[i]-1]++;
  }
  rep(i,a)
    cout<<c[i]<<endl;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define pb push_back
#define int long long
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define fill(x, v) memset(x, v, sizeof(x))
const ll mod = 1000000007;
const double pi = 3.14159265359; // PI
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
    auto start = high_resolution_clock::now();
    // Call the function, here
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << "Time taken by function: "<< duration.count() << " milliseconds" << endl;
*/
map<int, int> mp;
void primeFactors(int n)
{

    while (n % 2 == 0)
    {
        mp[2]++;
        n = n / 2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {

        while (n % i == 0)
        {
            mp[i]++;
            n = n / i;
        }
    }

    if (n > 2)
        mp[n]++;
}

int32_t main()
{

    int n;
    cin >> n;
    primeFactors(n);
    int c = 0;
    for (auto i : mp)
    {
        int sq = sqrt(8 * i.ss + 1) - 1;
        sq /= 2;
        c += sq;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3688
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int64_t> ps(n + 1);
    for (int i = 0; i < n; ++i) {
        ps[i + 1] = ps[i] + a[i];
    }

    vector<int64_t> sums;
    for (int le = 0; le < n; ++le) {
        for (int ri = le + 1; ri <= n; ++ri) {
            int64_t sum = ps[ri] - ps[le];
            sums.push_back(sum);
        }
    }

    sort(sums.begin(), sums.end());

    int64_t result = 0;

    for (int bit = 63; bit >= 0; --bit) {
        int ncontain_bit = 0;
        for (int64_t s : sums) {
            if ((s >> bit) & 1) {
                ncontain_bit += 1;
            }
        }
        if (ncontain_bit >= k) {
            result |= 1LL << bit;
            vector<int64_t> nsums;
            for (int64_t s : sums) {
                if ((s >> bit) & 1) {
                    nsums.push_back(s);
                }
            }
            sums.swap(nsums);
        }
    }

    cout << result << endl;
}


Measured memory_bytes: 6388
#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;



int main(){

	ll N;
	scanf("%lld",&N);

	ll num = 1;

	for(ll i = 2; i <= N; i++){

		num *= i;
		num %= MOD;
	}

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

	return 0;
}


Measured memory_bytes: 256
N=int(input())
money_list=[1,6,36,216,1296,7776,46656,9,81,729,6561,59049]
dp=[0]
for i in range(1,N+1):
    dp.append(100000)

for i in range(N):
    for money in money_list:
        if i+money <= N:
            dp[i+money]=min(dp[i+money],dp[i]+1)
print(dp[N])

Measured memory_bytes: 3860
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, cnt = 0;
	cin >> n;
	REP(i, n)cnt+=i;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3112
# -*- coding: utf-8 -*-

n,m=map(int,input().split())
l={}
r={}
for i in range(m):
    l[i],r[i]=map(int,input().split())
min_=max(l.values())
max_=min(r.values())
ans=max_-min_+1
if ans>0:
    print(max_-min_+1)
else:
    print(0)


Measured memory_bytes: 26900
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

g = "RUD".split("")
k = "LUD".split("")
s = gets.chomp
s.each_char.with_index do |c,i|
  if((i+1).odd?)
    unless(g.include?(c))
      puts "No"
      exit
    end
  else
    unless(k.include?(c))
      puts "No"
      exit
    end
  end
end
puts "Yes"

Measured memory_bytes: 1788
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    string s;
    cin >> s;

    cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

ll Ile(vector<ll>& a, ll dl)
{
    ll wyn = 0;
    for (int i = 0; i < a.size(); ++i)
    {
        if (a[i] % dl == 0)
            wyn += a[i] / dl - 1;
        else
            wyn += a[i] / dl;
    }
    return wyn;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll maks = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        maks = max(maks, a[i]);
    }
    ll l = 1, p = maks, s, r = -1;
    while (l <= p)
    {
        s = (l + p) / 2;
        if (Ile(a, s) <= k)
        {
            r = s;
            p = s - 1;
        }
        else
            l = s + 1;
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 4848
import java.util.Scanner;
class Main {
	int [][] cards = new int [5][15];
	private  static String[] cards2 = {"0","S","H","C","D"};
	int n,j,i,k,cards4,Nu;
	String cards3;
	public void ca() {
		Scanner sc = new Scanner(System.in);
		for(j = 1;j <= 4;j++) {
			for(i = 1 ; i <= 13; i++) {
				k = i;
				cards[j][i] = k;
			}
		}
		n = sc.nextInt();
		for(k = 0 ; k < n ; k++) {
			cards3 = sc.next();
			cards4 = sc.nextInt();
			if(cards3.equals( "S" )) {
				Nu = 1;
			} else if(cards3.equals( "H" )) {
				Nu = 2;
			} else if(cards3.equals( "C" )) {
				Nu = 3;
			} else if(cards3.equals( "D" )) {
				Nu = 4;
			}
			switch(Nu) {
				case 1:
					for(j = 1;j <= 13 ; j++) {
						if(cards4 == cards[1][j]) {
							cards[1][j] -= cards4;
						}
					}
					break;
				case 2:
					for(j = 1;j <= 13 ; j++) {
						if(cards4 == cards[2][j]) {
							cards[2][j] -= cards4;
						}
					}
					break;
				case 3:
					for(j = 1;j <= 13 ; j++) {
						if(cards4 == cards[3][j]) {
							cards[3][j] -= cards4;
						}
					}
					break;
				case 4:
					for(j = 1;j <= 13 ; j++) {
						if(cards4 == cards[4][j]) {
							cards[4][j] -= cards4;
						}
					}
					break;
				default:
					break;
			}
		}
		for(j = 1;j <= 4;j++) {
			for(i = 1;i <= 13;i++) {
				if(cards[j][i] != 0) {
					System.out.printf("%S %d\n",cards2[j],cards[j][i]);
				}
			}
		}
	}
	public static void main(String[] agrs) {
		new Main().ca();
	}
}

Measured memory_bytes: 18188
#include<stdio.h>
int main()
{
     long long s,w;
    while(scanf("%lld %lld",&s,&w)!=EOF)
    {
        if(w>=s)
        {
            printf("unsafe\n");
            }
        else
        {
            printf("safe\n");
            }
        }
    return 0;
    }

Measured memory_bytes: 1644
#include <iostream>

int main(int argc, char *argv[]) {
	int x, y, t;
	while (std::cin >> x >> y) {
		if (x == 0 && y == 0) break;
		if (x > y) {
			t = x;
			x = y;
			y = t;
		}
		std::cout << x << " " << y << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws Exception {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		ArrayList<Integer> result = new ArrayList<Integer>();

		while (true) {
			String str = br.readLine();
			if ("+".equals(SubStringMid(str))) {
				result.add(Integer.parseInt(SubStringStart(str)) + Integer.parseInt(SubStringEnd(str)));
			} else if ("-".equals(SubStringMid(str))) {
				result.add(Integer.parseInt(SubStringStart(str)) - Integer.parseInt(SubStringEnd(str)));
			} else if ("*".equals(SubStringMid(str))) {
				result.add(Integer.parseInt(SubStringStart(str)) * Integer.parseInt(SubStringEnd(str)));
			} else if ("/".equals(SubStringMid(str))) {
				result.add(Integer.parseInt(SubStringStart(str)) / Integer.parseInt(SubStringEnd(str)));
			} else if ("?".equals(SubStringMid(str))) {
				for (int i = 0; i < result.size(); i++) {
					System.out.println(result.get(i));
				}
				break;
			}
		}
	}

	//?¬¬????????°???????????????????????????
	public static String SubStringStart(String str) {
		int index = str.indexOf(" ");
		return (str.substring(0, index));
	}

	//	?¬¬????????°???????????????????????????
	public static String SubStringMid(String str) {
		int index1 = str.indexOf(" ");
		int index2 = str.lastIndexOf(" ");
		return (str.substring(index1 + 1, index2));
	}

	//	?¬¬????????°???????????????????????????
	public static String SubStringEnd(String str) {
		int index = str.lastIndexOf(" ");
		return (str.substring(index + 1));
	}
}

Measured memory_bytes: 24292
sx, sy, tx, ty = map(int, input().split())

# イルカの初めの位置を原点に移動，目標地点は第一象限固定
a = tx - sx
b = ty - sy

ans = "L" + "U" * (b+1) + "R" * (a+1) + "D" * (b+1) + "L" * a + "U" * b + "R" * (a+1) + "D" * (b+1) + "L" * (a+1) + "U"
print(ans)

Measured memory_bytes: 3060
N = int(input())
H = list(map(int, input().split()))
H = list(reversed(H))

ans = [None]*N
for i in range(N):
    if i==0:
        ans[i] = 0
    else:
        if H[i]>=H[i-1]:
            ans[i] = ans[i-1]+1
        else:
            ans[i]=0
print(max(ans))

Measured memory_bytes: 14224
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll x; cin>>x;
    ll cnt=0;
    ll sum=0;
    for(int i=1;sum<x;i++){
        sum+=i;
        cnt++;
    }
    //cout<<cnt<<" "<<sum<<endl;
    cout<<cnt<<endl;
}








Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s,t;
    map<ll,ll> mp;
    vector<ll> v[30];
    cin>>s>>t;
    ll n=s.size(),m=t.size(),index=0,now=0;
    rep(i,n){
        mp[s[i]-'a']++;
        v[s[i]-'a'].pb(i);
    }
    rep(i,30){
        sort(all(v[i]));
    }
    rep(i,m){
        if(mp[t[i]-'a']==0){
            cout<<-1<<endl;
            return 0;
        }
    }
    rep(i,m){
        ll c=t[i]-'a';
        if(lower_bound(all(v[c]),now)==v[c].end()){
            index++;
            now=0;
        }
        now=*lower_bound(all(v[c]),now);
        now++;
    }
    cout<<index*n+now<<endl;
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define rep(i, n) for(ll i=0; i<n; i++)
#define repq(i, k, n) for(ll i=k; i<n; i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, k;
P s[MAX_N];
vector<P> p, q; // 取ったダブリ寿司, 取っていない新規寿司
set<ll> t; // 取った寿司の種類を記録

signed main(){
    cin >> n >> k;
    rep(i, n){
        ll t, d;
        cin >> t >> d;
        s[i] = P(d, t);
    }
    sort(s, s+n, greater<P>());
    ll ts = 0;
    rep(i, k){
        ts += s[i].first;
        if(t.find(s[i].second) != t.end()) p.pb(s[i]);
        t.insert(s[i].second);
    }
    reverse(p.begin(), p.end());
    ll x = t.size();
    repq(i, k, n){
        if(t.find(s[i].second) != t.end()) continue;
        t.insert(s[i].second);
        q.pb(s[i]);

    }
    ll ret = ts;
    rep(i, min(p.size(), q.size())){
        ret = max(ret, ts + x * x);
        ts += q[i].first - p[i].first;
        x++;
    }
    ret = max(ret, ts + x * x);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 7284
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;


int main() {
	char s[4];
	cin >>s;int a=0;
	rep0(i,4)rep0(j,i)if(s[i]==s[j])a++;
	if(a==2)cout<<"Yes";
	else cout <<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[55];
bool cmp(int a,int b){
	return a>b;
}
int main()
{
	std::ios::sync_with_stdio(false);
	long long sum=0;
	int m,n;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=m;i++)
	sum+=a[i];
	cout<<sum<<endl;
	return 0;
}


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

using namespace std;

const long long NMAX = 100000;

long long v[NMAX+2];
long long N, low, high;

int main()
{
    cin >> N;
    long long last = 0, ind = 0;
    for( long long i = 1;  i <= N;  ++i ) {
        cin >> v[i];
    }
    if( v[N] != 2 ) {
        cout << "-1\n";
        return 0;
    }
    long long a = 2, b = 2;
    for( long long i = N;  i >= 1;  --i ) {
        long long x = (a + v[i] - 1) / v[i] * v[i];
        long long y = b / v[i] * v[i];
        if( x > b ) {
            cout << "-1\n";
            return 0;
        }
        a = x;
        b = y + v[i] - 1;
    }
    cout << a << ' ' << b << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0,b,c,d;
  string s;
  cin >>s;
  sort(s.begin(),s.end(),greater<char>());
  if(s=="cba") cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
 
#define int long long int
#define endl "\n"
#define mod 100000000
 
using namespace std;
 
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
bool findix(string s,string t)
{
    int j=0;
    for(int i=0;i<s.length();++i)
    {
        if(j==t.length()) return false;
        while(s[i]!=t[j])
        {
            if(j==t.length()-1) return false; 
            ++j;
        }
    }
    return true;
}
 
int maxim(string s)
{
    int maxi=INT_MIN;
    for(int i=0;i<s.length();++i) maxi=max(maxi,1LL*(s[i]-'0'));
    return maxi;
}
 
int minim(string s)
{
    int mini=INT_MAX;
    for(int i=0;i<s.length();++i) mini=min(mini,1LL*(s[i]-'0'));
    return mini;
}
 
signed main()
{
    fastio();
    string s; cin>>s; int arr[26]={0};
    for(int i=0;i<s.length();++i) {++arr[s[i]-'a'];}
    for(int i=0;i<26;++i) 
    {
        if(arr[i]>1) {cout<<"no"; return 0;}
    }
    cout<<"yes"; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) ((x) & -(x))
#define MOD 1000000007
using namespace std;

const long long NMAX = 100010;

inline void add(long long & a, long long b)
{
    a += b;
    if (a >= MOD)
        a -= MOD;
}
class Aib
{
    vector <long long> pozitii;
    vector <long long> aib;
public:
    Aib() {
        aib = vector <long long> (NMAX + 5);
    }
    void update(long long val, long long poz)
    {
        poz++;
        while (poz <= NMAX) {
            if (aib[poz] == 0)
                pozitii.push_back(poz);
            add(aib[poz], val);
            poz += lsb(poz);
        }
    }
    long long query(long long poz)
    {
        poz++;
        long long ans(0);
        while (poz) {
            add(ans, aib[poz]);
            poz -= lsb(poz);
        }
        return ans;
    }
    void clear()
    {
        for (auto i : pozitii)
            aib[i] = 0;
        pozitii.clear();
    }
};

Aib aib[2];

long long s[100010];
long long dif[2];

long long pozmax(long long x, long long dif)
{ /// poztia maxima a.i. s[x] - s[max] >= dif
    long long p(0), q(1 << 20);
    while (q >>= 1)
        if (p + q < x && s[x] - s[p + q] >= dif)
            p += q;
    return p;
}

void tranz(long long x)
{
    long long updates[2];
    for (long long i(0); i <= 1; i++) {
        updates[1 - i] = aib[i].query(pozmax(x + 1,  dif[1 - i]));
        if (s[x + 1] - s[x] < dif[i])
            aib[i].clear();
    }
    for (long long i(0); i <= 1; i++)
        aib[i].update(updates[i], x);
}

//long long dp[2][10][10];


int main()
{
    long long n;
    cin >> n >> dif[0] >> dif[1];

    for (long long i(1); i <= n; i++)
        cin >> s[i];

    aib[0].update(1, 0);
    aib[1].update(1, 0);

    /*for (long long q(0); q <= 1; q++) {
        for (long long j(0); j <= n; j++) {
            dp[q][1][j] = aib[q].query(j) - aib[q].query(j - 1);
        }
    }*/

    for (long long i(1); i < n; i++) {
        tranz(i);
        /*for (long long q(0); q <= 1; q++) {
            for (long long j(0); j <= n; j++) {
                dp[q][i + 1][j] = aib[q].query(j) - aib[q].query(j - 1);
            }
        }
    }

    for (long long q(0); q <= 1; q++) {
        for (long long i(1); i <= n; i++) {
            for (long long j(0); j <= n; j++) {
                cout << dp[q][i][j] << " \n"[j == n];
            }
        }
        cout << '\n';*/
    }

    cout << (aib[0].query(n) + aib[1].query(n)) % MOD;
    return 0;
}


Measured memory_bytes: 7408
import numpy as np

k, n = map(int, input().split())
a = list(map(int, input().split())) 

dist = []
dist.append(a[1]-a[0])

for num in range(1, len(a)):
  if num == len(a) - 1:
    dist.append(k-a[num]+a[0])
  else:
    dist.append(a[num+1]-a[num])
#print(dist)
dist = np.array(dist)

#min_index = np.where(dist == dist.min())[0]
s = np.sum(dist)
result = []
for start_index in range(0, len(dist)):
  if start_index == 0:
    result.append(s - dist[len(dist)-1])
    result.append(s - dist[start_index+1])
  elif start_index == len(dist)-1:
    result.append(s - dist[start_index-1])
    result.append(s - dist[0])
  else:
    result.append(s - dist[start_index-1])
    result.append(s - dist[start_index+1])
print(min(result))


Measured memory_bytes: 37700
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] l = new int[n][n];
        for (int i=0;i<n;i++) {
            int a = sc.nextInt() - 1;
            int m = sc.nextInt();
            while(m-->0) {
                l[a][sc.nextInt() - 1]++;
            }
        }
        for(int[] i:l) {
            for(int j=0;j<n;j++) {
                System.out.print(i[j]+(j==n-1?"\n":" "));
            }
        }
    }
}



Measured memory_bytes: 33476
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
vi a;
vi dp(MX);
void SieveOfEratosthenes(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          a.pb(p); 
} 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	SieveOfEratosthenes(1000000);
	int n;
	cin>>n;
	int val=a[lb(all(a),n)-a.begin()];
	cout<<val;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 5276
B = raw_input()
A = int(B)

if A < 105:
  print 0
  
elif 104 < A < 135:
  print 1

elif 134 < A < 165:
  print 2

elif 164 < A < 189:
  print 3

elif 188 < A < 195:
  print 4
  
elif 194 < A:
  print 5



Measured memory_bytes: 2568
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
const int N=310;
int n,k,dp[N][N][N];
char s[N];
//
int go(int l,int r,int x){
	if(l>r)return 0;
	if(l==r)return 1;
	if(dp[l][r][x]!=-1)return dp[l][r][x];
	int ans=max(go(l+1,r,x),go(l,r-1,x));
	if(s[l]==s[r])ans=max(ans,go(l+1,r-1,x)+2);
	if(x>0)ans=max(ans,go(l+1,r-1,x-1)+2);
	return dp[l][r][x]=ans;
}
int main(){
	memset(dp,-1,sizeof(dp));
	scanf("%s",s);
	n=strlen(s);
	scanf("%d",&k);
	printf("%d\n",go(0,n-1,k));
	return 0;
}

Measured memory_bytes: 116608
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	int checkpoint;
	int answer = 0;

	sort(l.begin(), l.end(),greater<int>());


	/*for (int i = 0; i < n; i++) {
		cout << l[i] << " ";
	}

	cout << endl;*/

	for (int i = 0; i < n; i++) {
		checkpoint = n - 1;
		for (int j = i + 1; j < n; j++) {
			int need = l[i] - l[j];
			for (int k = n - 1; k > j; k--) {
				if (l[k] > need) {
					checkpoint = k;
					answer += checkpoint - j;
					//cout << l[i] << " " << l[j] << " " << l[k] << endl;
					//cout << checkpoint - j << endl;
					break;
				}
			}
		}
	}

	cout << answer << endl;
	return 0;
}

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

using namespace std;

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

    int count = 0;
    int current = 0;

    for (int i = 0; i < s.size(); i++)
    {
        if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T')
        {
            current++;
            count = max(count, current);
        }
        else
        {
            current = 0;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n,q=input2()
B=str(input())
LR=[input_array() for _ in range(q)]

# E=["A","C","G","T"]
T=[0]*(n+1) #1文字目〜n文字目までに出現する"AC"数の累積和

for i in range(n):
	if B[i:i+2] == "AC":	
		T[i+1] = T[i]+1
	else:
		T[i+1]=T[i]
for lr in LR:
	st=lr[0]-1
	fi=lr[1]-1
	print(T[fi]-T[st])

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

int main(){
    int n;
    while( cin >> n, n ){
        int pm, pe, pj;
        while( n-- > 0 ){
            cin >> pm >> pe >> pj; 
            if( pm == 100 || pe == 100 || pj == 100 ||
                (pm+pe)/2 >= 90 || (pm+pe+pj)/3 >= 80 ){
                cout << 'A' << endl;
            }else if( (pm+pe+pj)/3 >= 70 || ((pm+pe+pj)/3 >= 50 && (pm >= 80 ||pe >=80))){
                cout << 'B' << endl;
            }else{
                cout << 'C' << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a,c1=0,c2=0,c4=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a;
    if(a%4==0) {
      c4++;
    }
    else if(a%2==0) {
      c2++;
    }
    else {
      c1++;
    }
  }
  if(c2>0) {
    c1++;
  }
  if(c1<=c4+1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;
#define MOD 1000000007

int main(){
    
    int N,M; cin>>N>>M;
    vector<string> A(N),B(M);
    REP(i,N)cin>>A[i];
    REP(i,M)cin>>B[i];
    
    for(int i=0;i<=N-M;i++){
        for(int j=0;j<=N-M;j++){
            bool flag=true;
            for(int k=i;k<i+M;k++){
                for(int l=j;l<j+M;l++){
                    if(A[k][l]!=B[k-i][l-j])flag=false;
                }
            }
            if(flag){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    
    cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    long n, m;
    long x, y, c;
    vector<long> xs, ys;
    cin >> n >> m;
    cin >> c;
    REP(i,n-1) {
        cin >> x;
        xs.push_back(x-c);
        c = x;
    }
    cin >> c;
    REP(i,m-1) {
        cin >> y;
        ys.push_back(y-c);
        c = y;
    }
    
    x = 0;
    y = 0;
    vector<long> ks;
    long t = n - 1;
    ks.push_back(t);
    REP(i,(t-1)/2) {
        ks.push_back(ks.back() + t - 2 - 2 * i);
    }
    REP(i,t/2) {
        ks.push_back(ks[t/2 - i - 1]);
    }
    REP(i,t) {
        x += ks[i] * xs[i];
        x %= MOD;
    }
    
    vector<long> ks2;
    t = m - 1;
    ks2.push_back(t);
    REP(i,(t-1)/2) {
        ks2.push_back(ks2.back() + t - 2 - 2 * i);
    }
    REP(i,t/2) {
        ks2.push_back(ks2[t/2 - i - 1]);
    }
    REP(i,t) {
        y += ks2[i] * ys[i];
        y %= MOD;
    }
    
    cout << x * y % MOD << endl;
}



Measured memory_bytes: 4084
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;


int main() {

    while (true) {

        double sum = 0;
        double ave;

        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int s[n];
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            sum += s[i];
        }

        ave = sum / n;
        sum = 0;

        for (int i = 0; i < n; i++) {
            sum += (s[i] - ave) * (s[i] - ave);
        }

        double a = sum / n;

        cout << fixed << setprecision(8) << sqrt(a) << "\n";
    }


}

Measured memory_bytes: 3232
# -*- coding: utf-8 -*-
S = list(input())
uppercase_cnt = 0
for s in S:
    if s.isupper():
        uppercase_cnt += 1 
if S[0] != 'A':
    print('WA')
elif S[2:-1].count('C') != 1:
    print('WA')
elif uppercase_cnt != 2:
    print('WA')
else:
    print('AC')


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

int main()
{
  int a,b,c;
  char op;
  while(1)
    {
      cin >> a >> op >> b;
      if(op=='?') break;
      if(op=='+') cout << a+b <<endl;
      if(op=='-') cout << a-b <<endl;
      if(op=='*') cout << a*b <<endl;
      if(op=='/') cout << a/b <<endl;
    }
  return 0;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const ll INF = 1ll << 60;

int main() {
  int N, K;
  while (cin >> N >> K) {
    vector<ll> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];
    vector<ll> dp(N, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 1; j <= K; j++) {
        if (i + j < N) {
          dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
      }
    }
    cout << dp[N - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
import java.util.Arrays;

import java.util.Comparator;
import java.util.Scanner;

class Problem {
    private int N;
    private int M;
    private Integer[] A;
    private final int[] nums = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    Problem() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();

        A = new Integer[M];
        for (int i = 0; i < M; i++) {
            A[i] = sc.nextInt();
        }
    }

    String solve() {
        int[] dp = new int[N + 1];

        for (int i = 1; i <= N; i++) {
            dp[i] = -1;

            for (int j = 0; j < M; j++) {
                int index = i - nums[A[j]];
                if (index >= 0 && dp[index] >= 0) {
                    dp[i] = Math.max(dp[i], dp[index] + 1);
                }
            }
        }

        int ndigits = dp[N];
        StringBuilder builder = new StringBuilder();

        Arrays.sort(A, Comparator.reverseOrder());

        int rest = N;
        for (int i = ndigits; i > 0; i--) {
            for (int m = 0; m < M; m++) {
                if (rest - nums[A[m]] >= 0 && dp[rest - nums[A[m]]] == (i - 1)) {
                    rest -= nums[A[m]];
                    builder.append(A[m]);
                    break;
                }
            }
        }

        return builder.toString();
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 23892
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI as(n);
  int sum = 0;
  FOR(a,as) {
    cin >> a;
    sum += a;
  }
  int idx = 0;
  REP(i,0,n) {
    if(abs(as[i] * n - sum) < abs(as[idx] * n - sum)) {
      idx = i;
    }
  }
  cout << idx << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
bool is(string s, int n) {
  string ABC = "ABC";
  REP(i, 0, ABC.size()) {
    if (n + i >= s.length()) return 0;
    if (s[n + i] != ABC[i]) {
      return 0;
    }
  }
  return 1;
}

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cnt = 0;
  REP(i, 0, N) {
    if (is(S, i)) cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 using Graph = vector<vector<int>>;
 #define rep(i,n) for(int i=0;i<n;++i)
 #define all(v) v.begin(), v.end()
 typedef long long int ll;
 typedef unsigned long long ull;
 template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
 template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
 typedef pair<ll,ll> P;
 const long long MOD = 1e9+7;
 const ll INF = 1LL << 60;

 int main(){
     int a;
     cin >> a;
     cout << a+a*a+a*a*a;
 }


Measured memory_bytes: 3580
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int A = sc.nextInt();
        final int B = sc.nextInt();
        final int C = sc.nextInt();
        final int X = sc.nextInt();
        int count = 0;

        for( int a = 0; a <= A; a++ ){
            for( int b = 0; b <= B; b++ ){
                for( int c = 0; c <= C; c++ ){
                    int sum = 500*a + 100*b + 50*c;
                    if( sum == X ){
                        count++;
                    }
                }       
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844