akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
ans = []
if len(a) == n:
    for i in a:
        if i % 2 == 0:
            if i % 3 == 0 or i % 5 == 0:
                ans.append(1)
            else:
                ans.append(2)
    print("DENIED") if 2 in ans else print("APPROVED")

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = int64_t;
#define MAX_N 1010
#define MAX_M 100010
const long long mod = pow(10,9)+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
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; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 10010
#define PI 3.141592653589793
#define vecP vector<P>
 //cout << setprecision(15) << std::fixed;

int main() {
    string s;
    cin >> s;
    map<char, int> m;
    for (int i = 0;i < 3;i++) {
        m[s[i]]++;
    }
    if (m['A'] > 0 && m['B'] > 0) {
        print("Yes");
    }
    else {
        print("No");
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int K;
	cin >> K;
	if (K % 2 == 1)print((K - 1)*(K + 1) / 4);
	else print(K*K / 4);


	return 0;
}

Measured memory_bytes: 256
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define N_MAX (300)
#define INF   (10000000000000000)


DWORD  N, M, L;
vector<vector<QWORD>> aqwTime(N_MAX + 1, vector<QWORD>(N_MAX + 1));

void initArraytoInf(vector<vector<QWORD>>& vec, QWORD length0, QWORD length1)
{
  REP(i, 0, length0) {
    REP(j, 0, length1) {
      vec[i][j] = INF;
    }
  }
}

void wharshallfroyd(vector<vector<QWORD>>& vec, QWORD qwNodeNum)
{
  REP(i, 1, qwNodeNum + 1) {
    REP(j, 1, qwNodeNum + 1) {
      REP(k, 1, qwNodeNum + 1) {
        vec[j][k] = min(vec[j][k], vec[j][i] + vec[i][k]);
      }
    }
  }
}

void solve_main()
{
  QWORD qwAns = 0;
  DWORD Q;
  vector<QWORD> vecMaxDistance;
  cin >> N >> M >> L;

  initArraytoInf(aqwTime, N_MAX + 1, N_MAX + 1);

  REP(i, 0, M) {
    DWORD tmpA, tmpB, tmpTime;
    cin >> tmpA >> tmpB >> tmpTime;

    if (tmpTime <= L) {
      aqwTime[tmpA][tmpB] = tmpTime;
      aqwTime[tmpB][tmpA] = tmpTime;
    }
  }


  REP(i, 0, N_MAX + 1) {
    REP(j, 0, N_MAX + 1) {
      if (i == j) {
        aqwTime[i][j] = 0;
      }
    }
  }

  wharshallfroyd(aqwTime, N);

  /* L以下で行けるところを1でEdge張り直し */
  REP(i, 1, N + 1) {
    REP(j, 1, N + 1) {
      if (aqwTime[i][j] <= L) {
        aqwTime[i][j] = 1;
      } else {
        aqwTime[i][j] = INF;
      }
    }
  }

  wharshallfroyd(aqwTime, N);

  cin >> Q;

  REP(i, 0, Q) {
    DWORD  start, goal;

    cin >> start >> goal;

    if (aqwTime[start][goal] != INF) {
      cout << aqwTime[start][goal] - 1 << endl;
    } else {
      cout << -1 << endl;
    }
  }
}

int main()
{
#ifdef FOR_IDE
  ifstream in("input.txt");
  std::cin.rdbuf(in.rdbuf());
#endif

  solve_main();
  return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int n;
int a[100005][4];
int dp[100005][4];

int solve(int day, int task_performed)
{

	if (day == n)
		return 0;

	if (dp[day][task_performed] != -1)
		return dp[day][task_performed];

	int maxi = 0;
	if (task_performed == 0)
	{
		maxi = max(maxi, a[day][1] + solve(day + 1, 1));
		maxi = max(maxi, a[day][2] + solve(day + 1, 2));
		maxi = max(maxi, a[day][3] + solve(day + 1, 3));
	}
	else if (task_performed == 1)
	{
		maxi = max(maxi, a[day][2] + solve(day + 1, 2));
		maxi = max(maxi, a[day][3] + solve(day + 1, 3));
	}
	else if (task_performed == 2)
	{
		maxi = max(maxi, a[day][1] + solve(day + 1, 1));
		maxi = max(maxi, a[day][3] + solve(day + 1, 3));
	}
	else if (task_performed == 3)
	{
		maxi = max(maxi, a[day][1] + solve(day + 1, 1));
		maxi = max(maxi, a[day][2] + solve(day + 1, 2));
	}
	return dp[day][task_performed] = maxi;
}

int32_t main()
{
	FIO();
	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		for (int j = 1; j <= 3; ++j)
		{
			cin >> a[i][j];
		}
	}

	memset(dp, -1, sizeof(dp));

	cout << solve(0, 0) << '\n';

	return 0;
}

Measured memory_bytes: 17700
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

max_A = max(A)
semimax_A = max_A if A.count(max_A) > 1 else list(sorted(list(set(A))))[-2]
for i in range(N):
    if A[i] == max_A:
        print(semimax_A)
    else:
        print(max_A)


Measured memory_bytes: 17188
#include <cstdio>
#include <cstring>
#define rep(i,n)for(int i=0;i<n;i++)
#define min(a,b)((a)<=(b)?(a):(b))
int n,m;
int a,b,c,d;
int x1,x2,y1,y2;
int cost[20][20];
int main() {
	memset(cost,0x10,sizeof(cost));
	scanf("%d",&n);
	scanf("%d",&m);
	rep(i,m) {
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		a--;b--;
		cost[a][b]=c;
		cost[b][a]=d;
	}
	scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
	x1--;x2--;
	rep(k,n)rep(i,n)rep(j,n) {
		cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
	}
	printf("%d\n",y1-(cost[x1][x2]+cost[x2][x1]+y2));
}

Measured memory_bytes: 1028
package main

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

func solve() {
	s := next()
	// phrases := []string{"dream", "dreamer", "erase", "eraser"}
	r := regexp.MustCompile(`^(dream(er)?|eraser?)*$`)

	if r.MatchString(s) {
		println("YES")
	} else {
		println("NO")
	}
	return
}

func main() {
	defer out.Flush()
	in.Buffer(make([]byte, scBufSize), scBufSize)
	in.Split(bufio.ScanWords)

	solve()
}

// --- template ---

const scBufSize = 1e6

var (
	in  = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func println(a ...interface{}) {
	fmt.Fprintln(out, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(out, format, a...)
}

func next() string {
	in.Scan()
	return in.Text()
}

func nextInt() int {
	s := next()
	i, e := strconv.Atoi(s)
	if e != nil {
		fmt.Println(e)
	}
	return i
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = nextInt()
	}
	return res
}

func unique(list []int) []int {
	m := make(map[int]bool)
	uniq := make([]int, 0)
	for _, e := range list {
		if !m[e] {
			m[e] = true
			uniq = append(uniq, e)
		}
	}
	return uniq
}


Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int n,k;
  int a[100],dp[100][9];
  scanf("%d %d",&n,&k);
  fill(a,a+n,4);
  for(int i=0;i<k;i++){
    int x,y;
    scanf("%d %d",&x,&y);
    x--;
    y--;
    a[x] = y;
  }
  for(int i=0;i<9;i++){
    dp[1][i] = 1;
    if((a[0]!=4&&a[0]!=i%3)||(a[1]!=4&&a[1]!=i/3)) dp[1][i] = 0;
  }
  for(int i=2;i<n;i++){
    for(int j=0;j<9;j++){
      dp[i][j] = 0;
      for(int k=0;k<3;k++){
        if((j%3!=j/3||j/3!=k)&&(a[i]==j/3||a[i]==4)) dp[i][j] += dp[i-1][(j%3)*3+k];
      }
      dp[i][j] %= 10000;
    }
  }
  int ans = 0;
  for(int i=0;i<9;i++) ans += dp[n-1][i];
  printf("%d\n",ans%10000);
  return 0;
}

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

/*
long long int solve(long long int i,vector<long long int> c,long long int size,long long int cost)
{
    if(i>=size-1)
    {
        return cost;
    }
    else
    {
        if(i+1>=size)
        {
            return cost;
        }
        else if(i+2>=size && i+1==size-1)
        {
            return solve(i+1,c,size,cost+abs(c[i]-c[i+1]));
        }
        else
        {
            return min(solve(i+1,c,size,cost+abs(c[i]-c[i+1])),solve(i+2,c,size,cost+abs(c[i]-c[i+2])));
        }
    }
}
*/
int main()
{
    long long int n;
    cin >> n;
    vector<long long int> v(n+1);
    for(long long int i=1;i<=n;i++)
    {
        cin >> v[i];
    }
    long long int dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(v[2]-v[1]);
    for(long long int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i-1]-v[i]));
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func solve(nums []int) int {
	maxIdx, maxVal := 0, nums[0]
	for i := 1; i < len(nums); i++ {
		if nums[i] > maxVal {
			maxIdx = i
			maxVal = nums[i]
		}
	}

	sum := 0
	for i := 0; i < len(nums); i++ {
		if i == maxIdx {
			sum += nums[i] / 2
		} else {
			sum += nums[i]
		}
	}
	return sum
}

func main() {
	var N int
	fmt.Scanln(&N)

	nums := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&nums[i])
	}
	fmt.Println(solve(nums))
}


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

const int N = 1e5 + 5;

ll A[N], B[N], C[N];
ll sum[N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%lld", A + i);
    for (int i = 0; i < n; ++i) scanf("%lld", B + i);
    for (int i = 0; i < n; ++i) scanf("%lld", C + i);

    sort(A, A + n);
    sort(B, B + n);
    sort(C, C + n);

    for (int i = 0; i < n; ++i) {
        int x = upper_bound(C, C + n, B[i]) - C;
        sum[i] = n - x;
    }

    for (int i = n - 2; i >= 0; i--) {
        sum[i] += sum[i + 1];
    }

    ll res = 0;
    for (int i = 0; i < n; ++i) {
        ll x = upper_bound(B, B + n, A[i]) - B;
        res += sum[x];
    }

    cout << res << endl;
}

Measured memory_bytes: 3328
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

PII cood[180005];
LL cost[180005];

int main() {
	int h, w, d, q;
	scanf("%d%d%d", &h, &w, &d);
	REP(i, h) {
		REP(j, w) {
			int tmp;
			scanf("%d", &tmp);
			cood[tmp] = MP(i, j);
		}
	}
	REP(i, d) {
		int cur = i + 1;
		cost[cur] = 0;
		cur = cur + d;
		for (; cur <= h*w; cur += d) {
			cost[cur] = cost[cur-d] + abs(cood[cur].first - cood[cur - d].first) + abs(cood[cur].second - cood[cur - d].second);
		}
	}
	scanf("%d", &q);
	REP(i, q) {
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%lld\n", cost[r] - cost[l]);
	}
	return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <ctime>
#include <deque>
using namespace std;

int n;
vector <int> ans;

int S(int x) {
	return 1LL * x * (x + 1) / 2;
}

int main() {
	scanf("%d", &n);
	int x = 0;
	for (int i = 1; i <= n; i++)
		if (S(i) >= n) {
			x = i;
			break;
		}
	for (int i = x; i >= 1; i--) {
		if (n >= i)
			n -= i, ans.push_back(i);
	}
	sort(ans.begin(), ans.end());
	for (int i = 0; i < (int) ans.size(); i++)
		printf("%d\n", ans[i]);
}


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


int main() {
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  bool a = false;
  bool b = false;
  if ((x >= r) && (x <= (w - r))) {
    a = true;
  };
  if ((y >= r) && (y <= (h - r))) {
    b = true;
  };
  if (a && b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const float pi = 3.1415926535897;
    float r;
    cin >> r;
    // std::cout << std::fixed;
    // std::cout << std::setprecision(5);
    
    float ans = 2.0*pi*r;
   	printf("%0.5f", ans);  

    

	return 0;
}

Measured memory_bytes: 3792
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;
	scanf("%d %d",&a,&b);
	scanf("%d %d",&d,&e);
	scanf("%d %d %d %d",&f,&g,&h,&i);
	o=a/10;
	p=b/20;
	q=d/10;
	r=e/20;
	j=h*o;
	k=i*p;
	l=h*q;
	m=i*r;
	c=(a*f)+(b*g)+j+k;
	n=(d*f)+(e*g)+l+m;
	if(c<n) printf("kenjiro\n");
	if(c>n) printf("hiroshi\n");
	if(c==n) printf("even\n");
	return 0;
}


Measured memory_bytes: 2148
#include<iostream>
using namespace std;
int main(){
    int n,p;
    while(1){
        int ans;
        cin>>n>>p;
        if(n==0 && p==0) break;
        int a[50]={};
        while(1){
            int co=0;
            for(int i=0;i<n;i++){
                if(p==0){
                    int count=0;
                    for(int j=0;j<n;j++){
                        if(a[j]!=0)count++;
                    }
                    if(count==1){
                        ans=i-1;
                        co=1;
                        if(ans<0){
                            ans=n-1;
                        }
                    }
                    else {
                        p=a[i];
                        a[i]=0;
                    }
                }
                else {
                    p--;
                    a[i]++;
                }
                if(co==1){
                    co=2;
                    break;
                }
            }
            if(co==2){
                cout<<ans<<endl;
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3068
#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <limits>

using namespace std;

typedef unsigned long long ull;

int main()
{
    int m, n;
    string M[50];
    string N[50];
    
    cin >> n >> m;
    
    for (int i = 0; i < n; i++)
    {
        cin >> N[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> M[i];
    }
    
    bool isFound = false;
    for (int i = 0; i <= n - m; i++)
    {
        for (int j = 0; j <= n - m; j++)
        {
            if (N[i].find(M[0].c_str(), j) == static_cast<size_t>(j))
            {
                isFound = true;
                for (int k = 1; k < m; k++)
                {
                    if (N[i+k].find(M[k].c_str(), j) != static_cast<size_t>(j))
                    {
                        isFound = false;
                        break;
                    }
                }
            }
            if (isFound)
            {
                break;
            }
        }
        if (isFound)
        {
            break;
        }
    }
    
    printf("%s\n", isFound ? "Yes" : "No");
    
    return 0;
}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    n, t, x = map(int, input().split())

    ans = 0
    for i in range(9999):
        n -= t
        ans += x
        if n <= 0:
            break

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """20 12 6"""
        output = """12"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """1000 1 1000"""
        output = """1000000"""
        self.assertIO(test_input, output)

    # 自作テストパターン
    def test_original(self):
        pass


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


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

using namespace std;

int main(){
    long long K;
    cin >> K;
    string s;
    cin >> s;
    if(s.length() <= K){
        cout << s << endl;
    }
    else{
        string ans = "";
        for(long long i = 0; i < K; i++){
            string g(1, s[i]);
            ans += g;
        }
        ans += "...";
        cout << ans << endl;
    }
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int x;cin >> x;
    string ans = "ARC";
    if(x < 1200) ans = "ABC";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PokerPlaying {
    class Class2 {
        
        static void Main(string[] args) {
            new Class2().solve();
        }
        void solve() {
            int num_Data = int.Parse(Console.ReadLine());
            for (int i = 0; i < num_Data; i++) {
                string input = Console.ReadLine();
                int[] terminal = new int[2];
                for (int j = 0; j < 2; j++) {
                    terminal[j] = int.Parse(input.Split(' ')[j]);
                }
                Console.WriteLine(outRoot(terminal[0],terminal[1]));
            }
        }
        
        string outRoot(int start, int terminal){
            string root = start.ToString() + " ";
            bool mustReverse = false;
            if (start > terminal && terminal < 5) {
                mustReverse = true;
            }
            int currentPos = start;
           
            do {

                if (root.Length >= 4) {
                    if (root.Substring(root.Length-4 , 3) == "9 5") {
                        mustReverse = true;
                    }
                    if (root.Substring(root.Length-4 , 3) == "1 0") {
                        mustReverse = false;
                    }
                }
                currentPos = moveNextTerminal(currentPos, mustReverse);
                root += currentPos.ToString() + " ";
            } while (currentPos != terminal);
            string trimed = root.TrimEnd();
            return trimed;
        }

        int moveNextTerminal(int currentPos, bool needReverse) {
            
            if (currentPos == 9) {
                int numTerminal = 5;
                return numTerminal;
            }
            if (needReverse) {
                int numTerminal = currentPos - 1;
                return numTerminal;
            } else {
                int numTerminal = currentPos + 1;
                return numTerminal;
            }
        }
    }

}

Measured memory_bytes: 8952
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [100000] * N
    B = [int(i) for i in input().split()]
    for i in range(N-1):
        if A[i] > B[i]: A[i] = B[i]
        A[i+1] = B[i]
    print(sum(A))
   
    return 0

if __name__ == "__main__":
    solve()

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

struct UnionFind{
	vi par;
	vi rank;

	UnionFind(int n=1){
		init(n);
	}

	// n要素で初期化
	void init(int n=1){
		par.resize(n);
		rank.resize(n);
		REP(i, n){
			par[i]=i;
			rank[i]=0;
		}
	}

	// xの根を求める
	int find(int x){
		if(par[x]==x){
			return x;
		}
		else{
			return par[x]=find(par[x]);
		}
	}

	// xとyが属する集合を併合
	bool unite(int x, int y){
		x=find(x);
		y=find(y);
		if(x==y){
			return false;
		}
		if(rank[x]<rank[y]){
			par[x]=y;
		}
		else{
			par[y]=x;
			if(rank[x]==rank[y]){
				++rank[x];
			}
		}
		return true;
	}

	// xとyが同じ集合に属するか判定
	bool issame(int x, int y){
		return find(x)==find(y);
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, p[114514], x[114514], y[114514];
	cin>>n>>m;
	REP(i, n){
		cin>>p[i];
		--p[i];
	}
	UnionFind uf(n);
	REP(i, m){
		cin>>x[i]>>y[i];
		--x[i];
		--y[i];
		uf.unite(x[i], y[i]);
	}
	int ans=0;
	REP(i, n){
		if(uf.issame(i, p[i])){
			++ans;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

int main()
{
       int N, A, B,x,y;
       cin>> N >> A >> B;
       x=N*A;
       if(x<=B)
       {
              cout<< x<< endl;

       }
       else
       {
              cout<< B <<endl;
       }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define X           first
#define Y           second
#define N           205
#define pb          push_back
#define pp          pop_back
#define mk          make_pair
#define PI          acos(-1)
#define EPS         1e-9
#define INF         1<<29
#define ln          '\n'
#define sp          ' '
#define redian      180/PI
#define all(x)      x.begin(),x.end()
#define Sort(x)     sort(all(x))
#define mem(a,b)    memset(a,b,sizeof(a))
#define lpa(p,v)    for(auto p:(v))
#define lp(a,b,c)   for(int a=(b);a<(c);a++)
#define lp0(a,n)    lp(a,0,n)
#define lpr(a,b,c)  for(int a=(b);a>=(c);a--)
#define faster      ios_base::sync_with_stdio(0);cin.tie(0);

const int MOD=1e8+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;
typedef pair<int,string> psi;
typedef map<int,int>mii;
inline bool sc(int &_x){return scanf("%d",&_x)==1;}
inline bool sc(int &_x, int &_y){return sc(_x)&&sc(_y);}
inline bool sc(int &_x, int &_y, int &_z){return sc(_x)&&sc(_y)&&sc(_z);}
inline bool sc(int &_x, int &_y, int &_z, int &_zz){return sc(_x)&&sc(_y)&&sc(_z)&&sc(_zz);}
/*
int x4[]= {1,-1,0,0};
int y4[]= {0,0,1,-1};
int x8[]= {0,0,+1,-1,-1,+1,-1,+1};
int y8[]= {-1,+1,0,0,+1,+1,-1,-1};
int kx[]= {2,2,-2,-2,1,-1,1,-1};
int ky[]= {1,-1,1,-1,2,2,-2,-2};  */
mii m;
int main()
{
    faster
    int n;cin>>n;
    int x;
    lp0(i,n)
    {
        cin>>x;
        m[x]++;
    }
    int ans=0;
    lpa(i,m)
    {
        if(i.X<i.Y)ans+=i.Y-i.X;
        else if(i.X>i.Y)ans+=i.Y;
    }
    cout<<ans;

}



Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<vi> vii;
typedef map<int, int> mp;
typedef multiset<int> mset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef vector<int64> vi64;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define form(i,j,k,l) for(int i=j;i<int(k);i+=l)
#define rform(i,j,k,l) for(int i=int(j);i>int(l);i-=l)
#define rep(i, j) for(int i=0;i<int(j);i++)
#define rrep(i, j) for(int i=int(j);i>=0;i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define forc(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define INF (int)1e9
#define INF64 (int64)1e18
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define F first
#define S  second
const double pie = acos(-1.0);
template <typename T>
T Max(T x, T y)
{
  return (x > y) ? x : y;
}
template <typename T>
T Min(T x, T y)
{
  return (x > y) ? y : x;
}
int gcd(int n1, int n2)
{
  if (n2 != 0) return gcd(n2, n1 % n2);
  else return n1;
}
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...)
#endif
clock_t time_p = clock();
void rtime() { time_p = clock() - time_p; cerr << "Time Taken : " << (float)1000 * (time_p) / CLOCKS_PER_SEC << "\n";}
int main()
{ fast;
  long long int x;
  cin >> x;
  long long int r = 11;
  long long int ans = (long long int)2 * (x / r);
  long long int res = x % r;
  if(res==0)
  {  cout<<ans;
     return 0;
  }
 if (res <= 6)
    ans++;
  else
    ans = ans + 2;
  cout << ans;
 return 0;
 
}

Measured memory_bytes: 3648
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n,m,x = get_nums_l()

books = [ get_nums_l() for _ in range(n)]

ans = INF

for bits in range(2 ** n):
    skills = [0] * (m)
    cost = 0
    for i in range(n):
        if 2**i & bits != 0:
            cost += books[i][0]
            for j in range(m):
                skills[j] += books[i][j+1]
    if min(skills) >= x:
        ans = min(ans, cost)

print(-1 if ans==INF else ans)


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int a = read(), b = read(), h = 0;
  REP(i, b - a) h += i;
  print(h - a);
}


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


int main(void){
  double r; cin >> r;
  cout << 2*r*3.1415926535 << endl;
  return 0;
}


Measured memory_bytes: 3784
S = input()
Sf = int(S[:2])
Sb = int(S[2:])
F = 0 < Sf <= 12
B = 0 < Sb <= 12
if F and B:
    ans = 'AMBIGUOUS'
elif F and not B:
    ans = 'MMYY'
elif not F and B:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)

Measured memory_bytes: 3060
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

int dp[26][222222];
pair<int,char> tap[222222];

int main(){
  string a;
  cin>>a;
  int n=a.size();
  rep(i,26)dp[i][n]=n;
  for(int i=n-1;i>=0;--i){
    rep(j,26)dp[j][i]=dp[j][i+1];
    dp[a[i]-'a'][i]=i;
  }
  tap[n]=make_pair(1,'a');
  for(int i=n-1;i>=0;--i){
    pair<int,char> m(n+1,'+');
    rep(j,26){
      int nxt=dp[j][i]+1;
      char ch='a'+j;
      if(nxt>n)m=min(m,make_pair(1,ch));
      else m=min(m,make_pair(tap[nxt].first+1,ch));
    }
    tap[i]=m;
  }
  string ans;
  int rem=tap[0].first;
  int cur=0;
  while(rem>0){
    char ch=tap[cur].second;
    ans+=ch;
    cur=dp[ch-'a'][cur]+1;
    rem--;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 24580
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli a = 0ll, b = 0ll, k = 0ll;
	cin >> a >> b >> k;
	if (k <= a)
	{
		cout << (a - k) << " " << b;
	}
	else
	{
		k = k - a;
		if (k <= b)
		{
			cout << "0 " << (b - k);
		}
		else
		{
			cout << "0 0";
		}
	}
}

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

long long solve( int N,const vector<int> &A){
  int count = 1;
  
  for ( int i =0; i < N; i++){
    if ( A.at(i) == count ){
      count ++;
    }
  }
     
  if ( count == 1 ){
    return -1;
  }else{
    return N-(count - 1);
  }
  
} 

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  
  for ( int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  cout << solve(N,A) << endl;
  
}

Measured memory_bytes: 1024
#include<iostream>
int main(){
	int S, h, m, s;
	std::cin >> S;
	h = S / 3600 % 24;
	m = S / 60 % 60;
	s = S % 60;
	std::cout << h << ":" << m << ":" << s << std::endl;
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
using namespace std;
using i64 = int64_t;
const i64 mod = 1e9 + 7;
i64 fact_memo[10000];
i64 fact(i64 x) {
    if (fact_memo[x] > 0) return fact_memo[x];
    return fact_memo[x] = x > 0 ? x * fact(x - 1) % mod : 1;
}
i64 powi(i64 x, i64 k) {
    i64 y = 1, z = x;
    while (k > 0) {
        if (k & 1) y = y * z % mod;
        k >>= 1;
        z = z * z % mod;
    }
    return y;
}
i64 inv(i64 x) {
    return powi(x, mod - 2);
}
i64 perm(i64 a, i64 b) {
    return fact(a) * inv(fact(a - b)) % mod; 
}
i64 conb(i64 a, i64 b) {
    return perm(a, b) * inv(fact(b)) % mod;
}
i64 n, a, b, c, d;
int main() {
    cin >> n >> a >> b >> c >> d;
    vector<i64> dp(n + 1);
    dp[0] = 1;
    for (i64 i = a; i <= b; ++i) {
        for (i64 j = n; j >= 0; --j) {
            i64 y = dp[j];
            for (i64 k = 1; k <= d; ++k) {
                i64 x = j + k * i;
                if (x > n) break;
                y = y * conb(n - (x - i), i) % mod * inv(k) % mod;
                if (k >= c) {
                    (dp[x] += y) %= mod;
                }
            }
        }
        /*
        cerr << i << endl;
        for (int j = 0; j <= n; ++j) cerr << dp[j] << ' ';
        cerr << endl;
        */
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};


struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} combination(1000000);

int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;

    mint ans = 0;
    for (ll rc = 0; rc <= n; rc++) {
        ll rp = rc * a;
        ll bp = k - rp;
        if (bp < 0) continue;
        if (bp % b != 0) continue;
        ll bc = bp / b;
        if (bc > n) continue;

        mint now = combination(n, rc) * combination(n, bc);
        ans += now;
    }
    cout << ans << endl;
}


Measured memory_bytes: 18604
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	R, _ := strconv.Atoi(s)

	if R < 1200 {
		fmt.Println("ABC")
	} else if R < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}

}


Measured memory_bytes: 1772
ok = 0
sum = 0
n, m= (int(x) for x in input('').split())
l = list(int(y) for y in input('').split())
for i in range(n):
  sum = sum + l[i]
for j in range(n):
  if l[j] >= sum * (1 / (4 * m)):
    ok = ok + 1
if ok >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
use std::io;
use std::io::{Read, BufReader};

macro_rules! read {
    ( $( $t:ty ),* ) => {
        {
            let mut buf = String::new();
            io::stdin().read_line(&mut buf);
            let mut sp = buf.trim().split(" ");
            ($(
                {
                    sp.next().unwrap().parse::<$t>().unwrap()
                },
            )*)
        }
    }
}
macro_rules! read_vec {
    ($t:ty) => {
        {
            let mut buf = String::new();
            io::stdin().read_line(&mut buf);
            let mut sp = buf.trim().split(" ");
            let mut ret = vec![];
            for s in sp {
                ret.push(s.parse::<$t>().unwrap());
            }
            ret
        }
    }
}

const MOD: i64 = 998244353;

fn line(a: (i64, i64), b: (i64, i64), c: (i64, i64)) -> bool {
    let b = (b.0 - a.0, b.1 - a.1);
    let c = (c.0 - a.0, c.1 - a.1);

    b.1 * c.0 == b.0 * c.1
}

fn ctri(ni: i64) -> i64 {
    let mut ret = 1i64;
    for _ in 0..ni {
        ret = ret * 2 % MOD;
    }

    ret = (ret + MOD - 1) % MOD;
    ret = (ret + MOD - ni) % MOD;
    ret = (ret + MOD - ni * (ni - 1) / 2) % MOD;

    ret
}

fn main() {
    let (n,) = read!(usize);
    let mut pts = vec![];
    for _ in 0..n {
        pts.push(read!(i64, i64));
    }
    
    let mut lin = vec![0i64; n + 1];

    for i in 0..n {
        for j in (i + 1)..n {
            let mut cnt = 0;
            for k in 0..n {
                if line(pts[i], pts[j], pts[k]) {
                    cnt += 1
                }
            }

            lin[cnt] += 1
        }
    }

    let mut ret = 1i64;
    for _ in 0..n {
        ret = ret * 2 % MOD;
    }

    let ni = n as i64;
    ret = ctri(ni);

    for i in 3..(n + 1) {
        let act = lin[i] / ((i * (i - 1) / 2) as i64);
        ret = (ret + MOD - ctri(i as i64) * act % MOD) % MOD;
    }
    println!("{}", ret);
}

Measured memory_bytes: 4352
n=int(input())
arr=list(map(int,input().split()))
arr=[[arr[i],i] for i in range(n)]
arr=sorted(arr,reverse=True,key=lambda x:x[0])
dp=[[-1]*(n+1) for _ in range(n+1)]
dp[0][0]=0
for i in range(n):
  for j in range(n):
    if dp[i][j]==-1:
      continue
    dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+arr[i][0]*abs(arr[i][1]-j))
    dp[i+1][j]=max(dp[i+1][j],dp[i][j]+arr[i][0]*abs(n-1-(i-j)-arr[i][1]))
print(max(dp[-1]))

Measured memory_bytes: 100464
package main

// Solution for https://atcoder.jp/contests/abc074/tasks/arc083_b

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

const INF = 1 << 50

func (con *contest) main() error {
	var N int
	con.Scan(&N)
	A := make([][]int, N)
	B := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, N)
		B[i] = make([]int, N)
		for j := 0; j < N; j++ {
			con.Scan(&A[i][j])
			B[i][j] = A[i][j]
		}
	}
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				x := A[i][k] + A[k][j]
				if x < A[i][j] {
					A[i][j] = x
				}
			}
		}
	}
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if A[i][j] != B[i][j] {
				con.Println(-1)
				return nil
			}
		}
	}
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			for k := 0; k < N; k++ {
				if k == i || k == j {
					continue
				}
				if A[i][k]+A[k][j] == A[i][j] {
					B[i][j] = INF
					B[j][i] = INF
					break
				}
			}
		}
	}
	L := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if B[i][j] != INF {
				L += B[i][j]
			}
		}
	}
	con.Println(L)
	return nil
}


Measured memory_bytes: 4964
K, N = map(int, input().split())
house_list = list(map(int, input().split()))

dif_list = []  # 家の間の距離を格納する配列
for i, l in enumerate(house_list):
    if i == 0:  # 0番目はスキップ
        continue
    dif_list.append(house_list[i] - house_list[i - 1])  # 配列に押し込む

dif_last_start = K - house_list[-1] + house_list[0]  # 最後の家と最初の家の距離

if dif_last_start < max(dif_list):  
    ans = sum(dif_list) - max(dif_list) + K - house_list[-1] + house_list[0]
else:
    ans = sum(dif_list)

print(ans)


Measured memory_bytes: 26444
#include <stdio.h>
#include <stdlib.h>
int main(){
  int i,j,k,n,temp,s[1000];
  scanf("%d",&n );
  if(n==0 || n==1){
  printf("%d\n",n);
  return 0;
}

  for(i=0;i<1000;i++)  {
  if(n%2==0)
  s[i]=0;
  else{
    s[i]=1;
    n--;
  }
  n=n/-2;

  if(n==1)
  break;
}
s[i+1]=1;

for(j=0;j<(i+2)/2;j++){
  temp=s[j];
  s[j]=s[i+1-j];
  s[i+1-j]=temp;
}
for(j=0;j<i+2;j++)
printf("%d",s[j]);
}


Measured memory_bytes: 128
strlist = list(input())
a, b, c = [0, 0, 0]
for i in strlist:
  if i == "a":
    a += 1
  if i == "b":
    b += 1
  if i == "c":
    c += 1
if max(a, max(b, c)) - min(a, min(b, c)) <= 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        while (A > 0 && C > 0) {
            C -= B;  //aoki
            if (C <= 0) {
                System.out.println("Yes");
                break;
            }
            A -= D;  //takahashi
            if (A <= 0) {
                System.out.println("No");
                break;
            }
        }
    }
}

Measured memory_bytes: 35720
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int n,m;
  cin>>n>>m;
  vector<vector<int> > v_switch (n,vector<int>(m,0));
  for (int i = 0; i < m; i++)
  {
    int k;cin>>k;
    for (int j = 0; j < k; j++)
    {
      int x;cin>>x;
      v_switch[x-1][i] = 1;
    }
  }
  vector<int> data (m,0);
  for (int i = 0; i < m; i++)
  {
    cin>>data[i];
  }
  int res = 0;
  for (int b = 0; b < (1<<n); b++)
  {
      vector<int> bit;
      for (int i = 0; i < n; i++)
      {
          bit.push_back((b>>i)&1);
      }
      vector<int> on (m,0);
      for (int i = 0; i < n; i++)
      {
        if(bit[i] == 0)continue;
        for (int j = 0; j < m; j++)
        {
          on[j] += v_switch[i][j];
        }
        
      }
      int flg = 1;

      for (int i = 0; i < m; i++)
      {
        if(data[i] != on[i]%2)flg = 0;
      }

      if(flg)res++;
      
      
  }
  cout<<res<<endl;
  
  
  

  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3584