akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (n); i++)
typedef pair<int, int> P;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){

    ll n, q;
    string s;
    cin >> n >> q;
    cin >> s;

    vector<P> Q(q+5);
    rep(i,q){
        cin >> Q[i].first >> Q[i].second;
        Q[i].first--;
    }

    ll max = 100005;

    vector<ll> L(max+5,0);
    for(ll i = 1; i < n; i++){
        if(s[i-1]=='A'&&s[i]=='C'){
            L[i+1] = L[i]+1;
        }else{
            L[i+1] = L[i];
        }
    }
    // rep(i,n+1){
    //     cout << L[i] << endl;
    // }


    ll l, r;
    rep(i,q){
        ll ans = L[Q[i].second] - L[Q[i].first];
        if(s[Q[i].first]=='C'&&s[Q[i].first-1]=='A')ans--;
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, b) for(int i = 0; i < b; i++)
#define repr(i, b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main(){
    int x; cin >> x;
    if(x >= 400  && x <= 599 ) {
        cout << 8;
    }
    if(x >= 600  && x <= 799 ) {
cout << 7;
    }
    if(x >= 800 && x <= 999 ) {
cout << 6;
    }
    if(x >= 1000 && x <= 1199 ) {
cout << 5;
    }

    if(x >= 1200  && x <= 1399 ) {
cout << 4;
    }
    if(x >= 1400  && x <= 1599) {
cout <<3;
    }
    if(x >= 1600  && x <= 1799) {
cout <<2;
    }
    if(x >= 1800  && x <= 1999) {
cout <<1;
    }
    return 0;
}

Measured memory_bytes: 3632
def D_11(x):
    n = x[0]  # 整数の数
    a = x[1:]  # 数列
    M = 10**9 + 7  # 求めた解の剰余をこれで取る

    s = set()
    result = [x for x in a if x in s or s.add(x)]
    # for x in a:
    # if x in s:
    #     result.append(x)
    # s.add(x) と同じ書き方
    index = [i for i, x in enumerate(a) if x == result[0]]
    l = index[0] + 1
    r = index[1] + 1

    # フェルマーの小定理を用いてコンビネーションを効率よく計算
    factrial = [1] * (n + 2)
    for k in range(1, n + 2):
        factrial[k] = (factrial[k - 1] * k) % M
    fact_inv = [1] * (n + 2)
    fact_inv[n + 1] = pow(factrial[n + 1], M - 2, M)
    for k in range(n, -1, -1):
        fact_inv[k] = (fact_inv[k + 1] * (k + 1)) % M

    def nCr(n, r, M):
        if n < 0 or r < 0 or n < r:
            return 0
        else:
            return (factrial[n] * fact_inv[r] * fact_inv[n - r]) % M

    for k in range(1, n + 2):
        print((nCr(n + 1, k, M) - nCr((l - 1) + (n + 1 - r), k - 1, M)) % M)

n = int(input())
l = [int(i) for i in input().split()]
x = [n] + l
D_11(x)

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

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int last_digit = -1;
	int ctr = 0;
	while (n > 0) {
		int d = n % 10;
		if (d == last_digit) ++ctr;
		else {
			last_digit = d;
			ctr = 1;
		}
		if (ctr >= 3) {
			cout << "Yes\n";
			return 0;
		}
		n /= 10;
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;

map<ll,ll> primes(ll n){
    map<ll, ll> r;
    for(ll i=2; i*i<=n; i++){ 
        while(n % i ==0){
            r[i]++;
            n /= i;
        }
    }

    if(n != 1) r[n] = 1;
    r[1]=0;
    return r;
}

int main(){FIN
    
  ll n,k=0;;cin>>n;
  ll i;
  map<ll,ll> v;
  v = primes(n);
  for( i=2;i*i<=n;i++){
  	//cout<<i<<" ";
  	if(n%i==0){
     	k=0;
     	while(n%i==0){
          n/=i;
		k++;
      	//cout<<i<<" "<<n<<"\n";
		}
	v[i]=k;
    }
  }
  //cout<<endl<<i<<endl;
  ll ans=0;
  for(auto i:v){
	  ll p=sqrt(1+8*i.second)-1;
	  p/=2;
	  ans+=p;
  }
  cout<<ans;
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int res;
 
int main()
{
    long long  a=0,i,j,n,t,b,c;
    string s,s1,s2;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
       a+=s[i]-'0';
    }
   // cout<<a;
    if(a%9==0)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
 
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
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; }

const long long INF = 1LL << 60;


int N;
long long h[100010];

// DP テーブル
long long dp[100010];
signed main() {
    int N;
    cin>>N;

    for(int i=0;i<100010;i++){
        cin>>h[i];
    }
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
LL L=-1;
LL R=100000;

int main(){
	cin>>N>>M;
	REP(i,M){
		LL a,b;
		cin>>a>>b;
		L=max(L,a);
		R=min(R,b);
	}
	if(R<L){
		cout<<0<<endl;
	}else{
		cout<<R-L+1<<endl;
	}
}

Measured memory_bytes: 256
abcd = list(map(int, input()))
a = abcd[0]
b = abcd[1]
c = abcd[2]
d = abcd[3]


if a+b+c+d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d == 7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b+c+d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b-c+d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b+c-d == 7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c-d == 7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d == 7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')


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

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)
	cin>>a[i];
	int dp[n+1];
	for(int i=1;i<=n;i++)
	dp[i] = 1e9;
	dp[1] = 0;
	dp[2] = abs(a[2]-a[1]);
	
	for(int i=3;i<=n;i++)
	{
		for(int j=i-1;j>=i-k && j>=1;j--)
		{
			dp[i] = min(dp[i],dp[j] + abs(a[i]-a[j]));
		}
	}
	cout<<dp[n]<<endl;
	
	
	return 0;
}

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

char h[1000][1000];
int s[1000],ans1[1000],ans2[1000];

int main(){
	int n,flag = 0;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%s",h[i]);
		s[i] = strlen(h[i]);
	}
	for(int i = 49;i <=74;i++){
		ans2[i] = 10000000;
	}
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < s[i];j++){
	    	ans1[h[i][j] - '0']++;
		}
		for(int k = 49;k <= 74;k++){
			ans2[k] = min(ans1[k],ans2[k]);
		}
		memset(ans1,0,sizeof(ans1));
	}
	char p;
	for(int i = 49;i <= 74;i++){
		if(ans2[i] != 0){
			for(int j = 1;j <= ans2[i];j++){
				flag = 1;
				printf("%c",i + '0');
			}
		}
	}
	if(flag == 0) printf("\n");
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  char c;
  cin >> c;
  if (0) ;
  else if (c == 'A') cout << "T\n";
  else if (c == 'C') cout << "G\n";
  else if (c == 'G') cout << "C\n";
  else if (c == 'T') cout << "A\n";
}


Measured memory_bytes: 256
from collections import Counter
from math import factorial

def comb(n,r):
    return factorial(n)//factorial(r)//factorial(n-r)

N,A,B = map(int,input().split())
V=list(map(int,input().split()))

V_C=Counter(V)

max_val=max(V)
CC=V_C[max_val]
if A<=CC:
    ans=0
    for v in range(A,min(B,CC)+1):
        ans+=comb(CC,v)
    print(max_val)
    print(ans)
    exit()

tmp_sum=0
tmp_num=0

for key in sorted(V_C.keys(),reverse=True):
    val = V_C[key]
    assert tmp_num<A
    #追加しても大丈夫なら加える(加えないとAに行かないから加えないといけない)
    #ぎりAに届くように追加するのが良い
    if A<=tmp_num+val:
        rest=A-tmp_num

        tmp_num+=rest
        tmp_sum+=key*rest
        assert tmp_num==A
        assert rest<=val
        assert rest!=0
        print(tmp_sum/tmp_num)
        print(comb(val,rest))
        exit()
    else:
        tmp_num+=val
        tmp_sum+=key*val
        assert tmp_num<A

assert 1==2


Measured memory_bytes: 67300
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int main(int argc, char const *argv[])
{
	char c;
	scanf("%c", &c);
	printf("%c\n", c + 1);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

template<long long mod>
struct modint{
    long long num;

    constexpr modint(long long x = 0) : num((x + mod) % mod) {}

    constexpr modint &operator += (const modint& rhs){
        num = (num + rhs.num) % mod;
        return *this;
    }
    constexpr modint &operator -= (const modint& rhs){
        num  -= rhs.num;
        while(num < 0) num += mod;
        num %= mod;
        return *this;
    }
    constexpr modint &operator *= (const modint& rhs){
        num = num * rhs.num % mod;
        return *this;
    }
    constexpr modint &operator /= (modint rhs){
        int exp = mod - 2;
        while(exp > 0){
            if(exp % 2){
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }

    constexpr modint operator ++ (){
        ++num;
        return *this;
    }
    constexpr modint operator ++ (int n){
        modint tmp = *this;
        ++(*this);
        return tmp;
    }
    constexpr modint operator -- (){
        --num;
        return *this;
    }
    constexpr modint operator -- (int n){
        const modint tmp = *this;
        --(*this);
        return tmp;
    }

    void modpow(ll y){
        modint tmp = (*this);
        (*this) = 1;
        while(y > 0){
            if(y % 2){
                (*this) *= tmp;
            }
            tmp *= tmp;
            y /= 2;
        }
    }

    constexpr modint operator + (const modint& rhs) const {
        return modint(*this) += rhs;
    }
    constexpr modint operator - (const modint& rhs) const {
        return modint(*this) -= rhs;
    }
    constexpr modint operator * (const modint& rhs) const {
        return modint(*this) *= rhs;
    }
    constexpr modint operator / (const modint& rhs) const {
        return modint(*this) /= rhs;
    }

    
    friend ostream &operator << (ostream& lhs, const modint& rhs){
        return lhs << rhs.num;
    }

    friend istream &operator >> (istream& lhs, modint& rhs){
        long long tmp;
        lhs >> rhs.num;
        return lhs;
    }
};

#define mint modint<1000000007>

int N;
mint A[100010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    mint frc = 1;
    for(int i = 1; i <= N; ++i){
        frc *= i;
        cin >> A[i];
    }
    mint sum(0);
    for(int i = 2; i <= N; ++i){
        sum += frc / i;
    }
    mint ans(0);
    for(int i = 1; i <= N; ++i){
        sum += frc / i;
        ans += A[i] * sum;
        sum -= frc / (N - i + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import bisect

n,m = map(int,input().split())

x,y,z = [],[],[]

for _ in range(n):
    i,j,k = map(int,input().split())
    x.append(i)
    y.append(j)
    z.append(k)

ans = 0

for i in [-1,1]:
    for j in [-1,1]:
        for k in [-1,1]:
            li = []
            for l in range(n):
                li.append(x[l]*i+y[l]*j+z[l]*k)
            li.sort(reverse=True)
            ans = max(ans,sum(li[:m]))

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    char c;
    cin >> c;

    cout << char(c + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] count = new int[26];
        for (int i = 0; i < 26; i++)
            count[i] = 0;

        while(sc.hasNext()){
            String input = sc.nextLine();
            String lowed = input.toLowerCase();
            for (int i = 0; i < lowed.length(); i++) {
                if (lowed.charAt(i) >= 'a' && lowed.charAt(i) <= 'z')
                    count[lowed.charAt(i) - 'a']++;
            }
        }

        for (int i = 0; i < 26; i++)
            System.out.println((char) ('a' + i) + " : " + count[i]);
    }
}


Measured memory_bytes: 26100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, r, d, x);
    Rep(10){
      x = r*x - d;
      Cout(x);
    }
}

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

double get_num(double x){
	x = x * 1000;
	if(x >= 0){
		x = (int)(x + 0.5);
		return ((double)x / 1000);
	} else {
		x = (int)(x - 0.5);
		return ((double)x / 1000);
	}
};

double sqrt(double x){
	double a = 0.0;
	double b = x;
	double p = 0.00001;
	while(b - a > p){
		double c = (a + b) / 2;
		if(c * c > x){
			b = c;
		} else {
			a = c;
		}
	}
	return a;
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		double x1, y1;
		double x2, y2;
		double x3, y3;
		double m12x, m12y;
		double m13x, m13y;
		double dx12, dy12;
		double dx13, dy13;
		double c12, c13;
		double xp, yp;
		double r;
		cin >> x1 >> y1 >> x2
			>> y2 >> x3 >> y3;
		m12x = (x1 + x2) / 2;
		m12y = (y1 + y2) / 2;
		m13x = (x1 + x3) / 2;
		m13y = (y1 + y3) / 2;
		dx12 = x2 - x1;
		dy12 = y2 - y1;
		dx13 = x3 - x1;
		dy13 = y3 - y1;
		c12 = m12x * dx12 + m12y * dy12;
		c13 = m13x * dx13 + m13y * dy13;
		yp = (c12 * dx13 - c13 * dx12) / (dy12 * dx13 - dy13 * dx12);
		if(dx12 == 0){
			xp = (c13 - (dy13 * yp)) / dx13;
		}else{
			xp = (c12 - (dy12 * yp)) / dx12;
		}
		r = sqrt((xp - x1) * (xp - x1) + ((yp - y1) * (yp - y1)));
		xp = get_num(xp);
		yp = get_num(yp);
		r = get_num(r);
		cout << fixed << setprecision(3) << xp << " " << yp << " " << r << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main()
{
    int n;
    cin >> n;
    int ct = 1000;
    while (ct < n)
    {
        ct += 1000;
    }
    cout << ct - n << endl;
}


Measured memory_bytes: 3632
import std.stdio, std.conv, std.string, std.random, std.range, std.typecons, std.math;
import std.algorithm.comparison, std.algorithm.iteration;
import std.algorithm.mutation, std.algorithm.searching, std.algorithm.sorting;

void main()
{
    auto input = readln().strip.split.to!(int[]);
    auto A = input[0];
    auto B = input[1];
    auto K = input[2];
    int count;
    foreach_reverse(i; 0..101)
    {
        count += A%i == 0 && B%i==0 ? 1 : 0;
        if(count==K)
        {
            writeln(i);
            return;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;


int main() {
    ll r;
    cin >> r;
    cout << 3 * r * r;

    return 0;
}





Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define N 200010
typedef long long LL;
using namespace std;
int n;
int a[N];
LL cnt = 0;
void merge(int a[], int left, int mid, int right){
    int i = left;
    int j = mid+1;
    int k = 0;
    int t[n];
    while(i <= mid && j <= right){
        if(a[i] <= a[j]) t[k++] = a[i++];
        else{
            cnt += mid - i + 1;
            t[k++] = a[j++];
        }
    }
    while(i <= mid) t[k++] = a[i++];
    while(j <= right) t[k++] = a[j++];

    for(int p = 0; p < k; p++){
        a[left + p] = t[p];
    }
}
void mergeSort(int a[], int left, int right){
    if(left < right){
        int mid = (left + right) / 2;
        mergeSort(a, left, mid);
        mergeSort(a, mid+1, right);
        merge(a, left, mid, right);
    }
}
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    mergeSort(a, 0, n-1);
    printf("%lld\n", cnt);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s[n];
    for (int i = 0; i < n; i++)
        cin >> s[i];
    int m;
    cin >> m;
    string t[m];
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }

    map<string, int> mp;
    for (int i = 0; i < n; i++)
        mp[s[i]]++;
    for (int i = 0; i < m; i++)
        mp[t[i]]--;
    int ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans = max(ans, itr->second);
    }
    cout << ans << endl;
    return 0;
}

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < n; i++) {
    ans = (double)(ans + (double)v[i]) / 2.0;
  }
  cout << ans << endl;
  return 0;
}


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

signed main(void)
{
	int n, k, x, y;
	int ans;
	cin >> n >> k >> x >> y;
	ans = 0;
	if (n < k)
		ans += n * x;
	else
	{
		ans += k * x;
		n -= k;
		ans += n * y;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
s=list(input())
x=[{ord(c)-ord('a')} for c in s]


def segfunc(x, y):
    return x | y

def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])

def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element
ide_ele = set()

# num: n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num

x=init(x)
q=int(input())

for i in range(q):
    t,l,r=input().split()

    if t=='1':
        update(int(l)-1,{ord(r)-ord('a')})
    
    else:
        print(len(query(int(l)-1,int(r))))

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

typedef pair<long long, long long> ii;


long long mod = 1000000007;
int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, t;
	cin >> n >> t;
	t--;
	ii arr[n];
	long long best = 0;
	long long bi = 0;
	for(int i = 0;i < n;i++){
		cin >> arr[i].first >> arr[i].second;

	}
	sort(arr,arr+n);
	long long dp[6006];
	fill(dp,dp+6006,0);
	dp[0] = 0;
	
	long long ans = 0;
	for(int i = 0;i < n;i++){

		for(int j = 6005;j >= 0;j--){
			if(j - arr[i].first >= 0 && j - arr[i].first <= t){
				dp[j] = max(dp[j], arr[i].second + dp[j-arr[i].first]);
			}
			ans = max(ans,dp[j]);
		}
	}

	cout << ans;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;i <= 0; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x); i++)
#define rreps(i,x) for(ll i = (ll)(x)-1; i <= 1; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;


template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
int main(){
    ll n; cin >> n;
    map<string, ll> mp;
    rep(i,n){
        string s; cin >> s;
        mp[s]++;
    }
    ll max_ = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        chmax(max_, (*itr).second);
    }

    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(max_ == (*itr).second)cout << (*itr).first << "\n";
    }

}

Measured memory_bytes: 25216
n = int(input())
a = list(map(int, input().split()))

suma = 0
for i in a:
  suma += i

diff = float('INF')
part = 0
for i in a:
  part += i
  if abs(part * 2 - suma) < diff:
    diff = abs(part * 2 - suma)

print (diff)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 097 D / Link: http://abc097.contest.atcoder.jp/tasks/abc097_d  ----- */


struct UnionFind {
	vector<int> data;
	UnionFind(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};

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

	LL N, M; cin >> N >> M;
		vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		a[i]--;
	}
	vector<LL> x(M), y(M);
	for (int i = 0; i < M; ++i) {
		cin >> x[i] >> y[i];
		x[i]--, y[i]--;
	}
	UnionFind uf(N);
	FOR(i, 0, M) {
		uf.unionSet(x[i], y[i]);
	}

	LL ans = 0LL;
	FOR(i, 0, N) {
		if (uf.same(a[i], i))ans++;
	}
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  int n[100000] = {};

  double coin = 0;
  for(int i = 0; i < N; i++){
    double tmp = i+1;
    tmp = (double)K/(i+1);
    //    cout << tmp << endl;
    while(true){
      if(tmp <= 1) break;
      tmp /= 2;
      n[i]++;
    }
    coin += pow(1./2., n[i]);
    //    cout << coin << endl;
  }

  double ans;
  ans = (double)1/N*coin;

  cout << fixed
       << setprecision(12)
       << ans << "\n";

  return 0;
}


Measured memory_bytes: 640
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    string a, b, c;
    cin >> a >>b >>c;
    if (a[a.size()-1] == b[0] && b[b.size()-1]==c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    //cout << ans << endl;
}

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

int main() {
	string str1, str2;
	int i,n,j,k,count_up = 0;
	while (1) {
		cin >> str1;
		if (str1 == "-") { break; }
		cin >> n;
		for (i = 0; i < n; i++) {
			cin >> k;
			for (j=k; j < str1.length(); j++) {
				str2 += str1[j];
			}
			for (j = 0; j < k; j++) {
				str2 += str1[j];
			}
			str1 = str2;
			if(i != (n-1))str2 = "";
		}
		cout << str2 << endl;
		str1 = "";
		str2 = "";
	}
	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
#include <algorithm>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(to); x++) // for簡略表記
#define DUMP(ar) for(int i=0; i<ar.size(); i++) cout << "[" << i << "]:" << ar[i] << endl // 配列一覧表示
#define DUMPL(ar) for(unsigned int i=0; i<ar.size(); i++) { cout << ar[i]; if(i<ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示"
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// goto ANSWER; で最後へ飛ぶ
// getline(cin, [変数]); で空白など(ホワイトスペース)を含む入力
// cin >> ws; でそこまでに入力ストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n;
    vector<int> x(n);
    FOR(i, n) cin >> x[i];
    cin >> m;
    vector<int> a(m);
    FOR(i, m) cin >> a[i];
    
    for(int i=0; i<m; i++){
        int place = x[a[i]-1] + 1;
        if(place >= 2020) continue;
        bool flag = true;
        for(int i=0; i<n; i++){
            if(x[i] == place){
                flag = false;
                break;
            }
        }
        if(flag) x[a[i]-1] += 1;
    }

    for(int i=0; i<n; i++){
        cout << x[i] << endl;
    }

    return 0;
}



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


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

  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int l = 0, r = 1e9;
  while (r-l > 1)
  {
    int x = (l+r) / 2;
    auto f = [&](int x) {
      ll now = 0;
      rep(i,n) now += (a[i]-1) / x;
      return now <= k;
    };
    if (f(x)) r = x;
    else l = x;
  }
  cout << r << endl;
  
  return 0;
}

Measured memory_bytes: 3968
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
    int n; cin>>n;
    map<int,int>ans;
    repa(i,1,n)
        ans[i]=0;
    int ar[n+1];
    repa(i,2,n)
        cin>>ar[i];
    repa(i,2,n)
        ans[ar[i]]++;
    for (auto it:ans)
        cout<<it.ss<<endl;   
    
}

Measured memory_bytes: 17716
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String a = sc.next();
        // final String b = sc.next();

        final int a = sc.nextInt();
        // final int b = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        System.out.println(a * 800 - ( a / 15 ) * 200);

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 21844
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n = inp()
    print(n//2+n%2)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 39848
#include <iostream>

using namespace std;

int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        for (int j = 0; j < h; j++) {
            for (int i = 0; i < w; i++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

int main() {
    int n, x, c = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &x);
        if (x % 2)
            c++; }
    if (c % 2 == 0)
        printf("YES");
    else
        printf("NO");
    return 0; }


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
  int n, balls[10], cup[10], last, i;
  scanf("%d", &n);
  while(n--){
    memset(cup, 0, sizeof(cup));
    last = 0;
    for(i = 0;i < 10;i++){
      scanf("%d", balls + i);
      if(balls[i] > last){
	cup[i] = 1;
	last = balls[i];
      }
    }
    last = 0;
    for(i = 0;i < 10;i++){
      if(cup[i] == 0){
	if(last < balls[i])
	  last = balls[i];
	else
	  last = 20;
      }
    }
    if(last == 20){
      puts("NO");
    }
    else
      puts("YES");
  }
  return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int x=tx-sx;
    int y=ty-sy;

    string s;
    REP(i,y) s+='U';
    REP(i,x) s+='R';
    
    REP(i,y) s+='D';
    REP(i,x) s+='L';

    s+='L';
    REP(i,y+1) s+='U';
    REP(i,x+1) s+='R';
    s+='D';

    s+='R';
    REP(i,y+1) s+='D';
    REP(i,x+1) s+='L';
    s+='U';

    cout<<s<<endl;
}


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

using namespace std;

int main() {
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i]; 
	}
	
	sort(s.begin(), s.end());

	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
		cout << endl;

		return 0;
}

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


int Q;
long long f_b = 0;
multiset<pair<long long, int>> as;
pair<long long, int> mid = make_pair(0, -1);
long long dist_sum = 0;


void insert(long long a){
    auto target_itr = as.lower_bound(make_pair(a + 1, 0));
    int idx = 0;
    if(prev(target_itr)->first == a){
        idx = prev(target_itr) -> second + 1;
    }
    as.insert(make_pair(a, idx));
}


void query1(long long a, long long b){
    f_b += b;
    if(mid.second == -1){
        as.insert(make_pair(a, 0));
        mid = make_pair(a, 0);
        return;
    }
    insert(a);
    if(as.size() % 2){
        if(a < mid.first){
            dist_sum += mid.first - a;
        }else{
            mid = *next(as.find(mid));
            dist_sum += (a - mid.first);
        }
    }else{
        if(a < mid.first){
            auto new_mid = *prev(as.find(mid));
            dist_sum += mid.first - a;
            mid = new_mid;
        }else{
            dist_sum += a - mid.first;
        }
    }

}

void query2(){
    cout << mid.first << " " << dist_sum + f_b << endl;
}

int main(){
    cin >> Q;
    for(int q = 0; q < Q; q++){
        int query;
        cin >> query;
        if(query == 1){
            long long a, b;
            cin >> a >> b;
            query1(a, b);
        }else{
            query2();
        }
    }
}


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

int main(){
  long N;
  cin>>N;
  int x=pow(N,0.5);
  for(int i=x;i>0;i--){
  	if(N%i==0){
      cout<<i+(N/i)-2<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func asub(x, y int) int {
	if x > y {
		return x - y
	}
	return y - x
}

func main() {
	sc.Split(bufio.ScanWords)

	X, Y := getInt(), getInt()

	if asub(X, Y) <= 1 {
		out("Brown")
	} else {
		out("Alice")
	}

}


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


using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');

int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    long long int n;
    cin>>n;
    string s,t;
    char c;
    while(n>0){
        if(n%26!=0)
        {c=(n%26)-1+'a';
        n=n/26;
        }
        else
        {
            c='z';
            n=n/26-1;
        }
        //cout<<c<<endl;
        s.pb(c);
        
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    /*out<<s<<endl;
    cout<<s.size()<<endl;
    cout<<s[0]<<endl;
    rep(i,s.size()-1,0){
       cout<<s[i]<<endl;
        t.pb(s[i]);
    }
    cout<<t<<endl;*/
}

Measured memory_bytes: 3652
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let A = scan.list::<i64>(N);

    let mut desc = A
        .iter()
        .enumerate()
        .map(|(i, &a)| (a, i))
        .collect::<Vec<_>>();
    desc.sort_by_key(|&(a, i)| (std::cmp::Reverse(a), i));

    let mut dp = vec![vec![0; N + 2]; N + 2];
    // i: すでに配置した人数
    for i in 0..N {
        // x: 左端に配置した人数
        for x in 0..i + 1 {
            let (a, p) = desc[i];

            // 右端に配置するときの位置
            let y = N - (i - x) - 1;

            // なるべく左端に置く
            dp[i + 1][x + 1] = dp[i + 1][x + 1].max(dp[i][x] + a * (p as i64 - x as i64).abs());

            // なるべく右端に置く
            dp[i + 1][x] = dp[i + 1][x].max(dp[i][x] + a * (p as i64 - y as i64).abs());
        }
    }

    let m = (0..N + 1).map(|x| dp[N][x]).max().unwrap();

    println!("{}", m);
}


Measured memory_bytes: 33484
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
int dp[3002][3002];
int main(){
    string a;
    string b;
    string res;
    while (cin>>a>>b)
    {
        memset(dp,0,sizeof(dp));
        for(int i=1;i<=a.length();i++){
            for(int j=1;j<=b.length();j++){
                if(a[i-1]==b[j-1]) dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }                                              
        }
        // cout<<dp[a.length()][b.length()]<<endl;
        int m=a.length();
        int n=b.length();
        res.clear();
        while(1){
            if(m==0||n==0) break;
            if(a[m-1]==b[n-1]){
                res.push_back(a[m-1]);
                m-=1;
                n-=1;
            }else{
                if(dp[m][n]==dp[m][n-1]){
                    n=n-1;
                }else{
                    m=m-1;
                }
            }
        }
        reverse(res.begin(),res.end());
        cout<<res<<endl;
    }
    

}

Measured memory_bytes: 35456
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    cout<<n+(n*n)+(n*n*n)<<endl;
}


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

using namespace std;

int main()
{
  vector <int> A(3);
  cin >> A[0] >> A[1] >> A[2];

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

  cout << abs(A[2]-A[1])+abs(A[1]-A[0]) << endl;

  
}


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


int main()
{
	int n, l; cin >> n >> l;
	string S[n];
	rep(i, n) cin >> S[i];
	sort(S, S+n);
	rep(i, n) cout << S[i];
	cout << endl;
}



Measured memory_bytes: 3588
#include<stdio.h>

int main(){
  int a = 0;
  int b = 0;
  
  scanf("%d %d", &a, &b);
  
  if((a+b) % 2 != 0) {
    puts("IMPOSSIBLE");
  }
  else {
    printf("%d", (a+b)/2);
  }
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 998244353;
const int N = 1e4 + 5, M = 1e5 + 5;
const ll INF = 1e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi acos(-1)

int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}

int main()
{
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			int x = gcd(i, j);
			for(int k = 1; k <= n; k++)
				sum += gcd(x, k);
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 1) {
            if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') continue;
            else {
                cout << "No" << "\n";
                return 0;
            }
        } else {
            if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') continue;
            else {
                cout << "No" << "\n";
                return 0;
            }
        }
    }
    cout << "Yes" << "\n";
    
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        
        String str1 = sc.next();
      String str2 = sc.next();
      String str3 = str1 + str2;
      int count = 0;
      for (int i = 0; i < str1.length(); i++) {
        if (str3.substring(i, i+1).equals(str3.substring(str1.length()+i, str1.length()+i+1))) {
          count++;
        }
      }
      pw.println(count);
        
      sc.close();
        pw.close();
    }
    static class FastScanner {
    	private InputStream stream;
    	private byte[] buf = new byte[1024];
    	private int curChar;
    	private int numChars;
    	private FastScanner.SpaceCharFilter filter;
    	
    	public FastScanner(InputStream stream) {
    		this.stream = stream;
    	}
    	
    	public int read() {
    		if (numChars == -1) {
    			throw new InputMismatchException();
    		}
    		if (curChar >= numChars) {
    			curChar = 0;
    			try {
    				numChars = stream.read(buf);
    			} catch (IOException e) {
    				throw new InputMismatchException();
    			}
    			if (numChars <= 0) {
    				return -1;
    			}
    		}
    	return buf[curChar++];
    	}
    	
    	public int nextInt() {
    		int c = read();
    		while (isSpaceChar(c)) {
    			c = read();
    		}
    		int sgn = 1;
    		if (c == '-') {
    			sgn = -1;
    			c = read();
    		}
    		int res = 0;
    		do {
    			if (c < '0' || c > '9') {
    				throw new InputMismatchException();
    			}
    			res *= 10;
    			res += c - '0';
    			c = read();
    		} while (!isSpaceChar(c));
    		return res * sgn;
    	}
    	
    	public String nextString() {
    		int c = read();
    		while (isSpaceChar(c)) {
    			c = read();
    		}
    		StringBuilder res = new StringBuilder();
    		do {
    			if (Character.isValidCodePoint(c)) {
    				res.appendCodePoint(c);
    			}
    			c = read();
    		} while (!isSpaceChar(c));
    			return res.toString();
    	}
    	
    	public boolean isSpaceChar(int c) {
    		if (filter != null) {
    			return filter.isSpaceChar(c);
    		}
    		return isWhitespace(c);
    	}
    	
    	public static boolean isWhitespace(int c) {
    		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    	}
    	
    	public int[] nextIntArray(int n) {
    		int[] array = new int[n];
    		for (int i = 0; i < n; ++i) array[i] = nextInt();
    		return array;
    	}
    	
    	public interface SpaceCharFilter {
    	public boolean isSpaceChar(int ch);
    	
    	}
    }
}

Measured memory_bytes: 21204