akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"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()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

type data struct {
	val, pos int
}

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

	N := getInt()
	a := make([]data, N)
	for i := 0; i < N; i++ {
		a[i].val = getInt()
		a[i].pos = i
	}

	sort.Slice(a, func(i, j int) bool {
		return a[i].val > a[j].val
	})
	// out(a)

	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, N+1)
	}

	ans := 0
	for l := 0; l <= N; l++ {
		for r := 0; r <= N; r++ {
			if l+r == N {
				// out(dp[l])
				ans = max(ans, dp[l][r])
				break
			}
			v, i := a[l+r].val, a[l+r].pos
			dp[l+1][r] = max(dp[l+1][r], dp[l][r]+asub(l, i)*v)
			dp[l][r+1] = max(dp[l][r+1], dp[l][r]+asub(N-1-r, i)*v)
		}
	}
	out(ans)
}


Measured memory_bytes: 23088
int main(){
  int n;
  scanf("%d",&n);
  int a[100001],b[100001];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    b[a[i]-1]=i+1;
  }
  for(int i=0;i<n;i++){
    printf("%d\n",b[i]);
  }
}

Measured memory_bytes: 1536
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
print(n * 800 - n//15 * 200)


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

int main(){
    int i;
    char str[1200];
     fgets(str, sizeof(str), stdin);
    for(i = 0; i <= strlen(str); i++){
        if(str[i]>=65&&str[i]<=90)
            str[i]=str[i]+32;
        else if(str[i]>=97&&str[i]<=122)
            str[i]=str[i]-32;
    }
    printf("%s", str);
    return 0;
}



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

int main() {
    int n = 3;

    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

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

    cout << abs(data.at(0) - data.at(1)) + abs(data.at(1) - data.at(2)) << endl;
}

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

int main() {
  string s;
  int size,count=0;
  cin >> s;
  size = s.length();

  for (int i = 0; i < size/2; i++) {
    if (s[i] != s[size-i-1]) {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int ac=0;
		int wa=0;
		int[][] p = new int[n][2];
		
		for(int i=0;i<m;i++) {
		
			int k = sc.nextInt()-1;
			String t = sc.next();
			
			
			if(p[k][0]==0&&t.equals("AC")) {
				p[k][0]++;
			}
			if(p[k][0]==0&&t.equals("WA")) {
				p[k][1]++;
			}	
			
		}
		
		for(int i=0;i<n;i++) {
			if(p[i][0]==1) {
				ac++;
				wa+=p[i][1];
			}
		}
		
		System.out.println(ac+" "+wa);
		
		sc.close();
	}
}


Measured memory_bytes: 63556
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

int main(){
  int a,b,c;
  cin>>a;
  b=0;c=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='R')
    b++;
    else
    c++;
  }
  if(b>c)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    cout << (N - 1) * N / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A.rbegin(), A.rend());

    ll ans = 0;
    for(int i=0;i<N-1;i++){
        ans += A[(i+1)/2];
    }

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

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  rep(i, n) ans += a[i];
  rep(i, n){
    if(ans % 10) break;
    if((ans - a[i]) % 10) {
      ans -= a[i];
      break;
    }
  }
  if(ans % 10 == 0) ans = 0;
  cout << ans << endl;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    string S;
    int Q;
    cin >> S >> Q;


    deque<char> T;

    rep(i,S.size()) {
        T.push_back(S[i]);
    }
    bool t = true;
    rep(i,Q) {
        int q;
        cin >> q;
        if (q==1){
            if (t) t=false;
            else t = true;
        }
        else {
            int a;
            char b;
            cin >> a >> b;
            if ((a==1 and t) or (a==2 and !t)) {
                T.push_front(b);
            }
            else {
                T.push_back(b);
            } 
        }   
    }
    int N = T.size();
    char s;
    if (t) {
        rep(i,N){
            s = T.front();
            T.pop_front();
            cout << s;
        }
        cout << endl;
    }
    else {
        rep(i,N) {
            s = T.back();
            T.pop_back();
            cout << s;
        }
        cout << endl;
    }
}



Measured memory_bytes: 896
N = int(input())
a = list(map(int,input().split()))
doubledCumSum = 0
total = sum(a)
lower = upper = 0
for v in a:
    doubledCumSum += 2 * v
    if doubledCumSum <= total:
        lower = doubledCumSum 
    else:
        upper = doubledCumSum
        break
ans = min(abs(total - lower), abs(total - upper))
print(ans)

Measured memory_bytes: 26096
import numpy as np
N = int(input())
S_list= []
P_list= []
for i in range(N):
    S,P = map(str,input().split())
    S_list.append(S+str(100-int(P)).zfill(3))

for j in np.argsort(S_list):
    print(j+1)

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

int main() {
  int n;
  cin >> n;
  
  vector<int> p(n);
  for( int i = 0; i < n; i++ ){
    cin >> p.at(i); 
  }
  
  int count = 0;
  for( int i = 0; i < n-2; i++ ){
    if( p.at(i) < p.at(i+1) && p.at(i+1) < p.at(i+2) ){
      count++;
    }else if( p.at(i+2) < p.at(i+1) && p.at(i+1) < p.at(i) ){
      count++;
    }
  }
  cout << count << endl;
}

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

int main(){
  long long mod=1e9+7, ans=0;
  string l;
  cin >> l;
  if(l.size()==1){
    cout << 1+2*(l[0]-'0') << endl;
    return 0;
  }
  long long expo3[l.size()+3];
  for(size_t i=l.size()-1;i>0;i--){
    if(i==l.size()-1){
      expo3[i]=3;
      ans+=expo3[i];
    }else{
      expo3[i]=expo3[i+1]*3ll;
      expo3[i]%=mod;
      ans+=expo3[i+1]*2;
    }
    ans%=mod;
  }
  long long tmp=2;
  for(size_t i=1;i<l.size();i++){
    if(l[i]=='1'){
      if(i!=l.size()-1){
        ans+=tmp*expo3[i+1];
        ans%=mod;
      }else{
        ans+=tmp*1ll;
        ans%=mod;
      }
      tmp*=2;
    }else{
      tmp*=1;
    }
    tmp%=mod;
  }
  cout << (ans+tmp)%mod << endl;
  return 0;
}

Measured memory_bytes: 1280
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,n) for(int i=(1);i<(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n;
    cin>>n;
    if(n==1){
        cout<<1;
        return 0;
    }
    int ans=0,my=0;
    for(int i=2;i<=n;i+=2){
        int cnt=0;
        int num=i;
        while(num%2==0){
            num/=2;
            cnt++;
        }
        if(my<cnt){
            my=cnt;
            ans=i;
        }
    }
    cout<<ans<<'\n';

    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int ans;
  if (b != 100) ans = pow(100, a) * b;
  else ans = pow(100, a) * 101;
  cout << ans << endl;
}

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

int main() {
    int N;
    int A;
    int B;
	cin >> N;
	cin >> A;
	cin >> B;
	int max = 0;
	if (A > B) {
	    max = B;
	} else {
	    max = A;
	}
	int min = 0;
	if (A + B > N) {
	    min = A + B - N;
	}
	cout << max << " " << min << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
signed main(){
	string s;
	cin >> s;
	int n = s.size();
	for (int i = n - 1; i >= 0; i--) {
		if (i >= 4 && s.substr(i - 4, 5) == "dream") {
			i -= 4;
		}
		else if (i >= 4 && s.substr(i - 4, 5) == "erase") {
			i -= 4;
		}
		else if (i >= 6 && s.substr(i - 6, 7) == "dreamer") {
			i -= 6;
		}
		else if (i >= 5 && s.substr(i - 5, 6) == "eraser") {
			i -= 5;
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);//その日までにやらなきゃいけない仕事
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    for (auto b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();//top()→先頭要素を取り出す関数
      q.pop();//pop()→先頭要素を削除する関数
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int x;
    cin >> x;
    int points = (x/500)*1000;
    x = x % 500;
    points += (x/5)*5;
    cout << points;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char str1[100];
    int a,b,i,n=0,m=0;
    for(i=0;i<100;i++){
        str1[i]=0;
    }
    scanf("%s",str1);
    for(i=0;i<100;i++){
        if(str1[i]!=0){
            printf("x");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
ll n;
void dfs(string str,ll cou,ll kind){
  if(cou == n){
    cout << str << endl;
    return;
  }
  char c;
  rep(i,kind+1){
    c = (char)('a' + i);
    if(i == kind){
      dfs(str + c,cou+1,kind+1);
    }else{
      dfs(str + c,cou+1,kind);
    }
  }
}
int main(){
  cin >> n;
  dfs("",0,0);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int gcd(int x, int y) {
  int r;
  if (x < y) swap(x, y);

  while (y > 0) {
    r = x % y;
    x = y;
    y = r;
  }

  return x;
}

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

  int x, r;
  cin >> x;
  r = abs(x-X);

  for (int i = 1; i < N; i++) {
    int tmp;
    cin >> tmp;
    tmp = abs(tmp-X);
    r = gcd(r, tmp);
  }

  cout << r << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n, a, b;
  cin >> n >> a >> b;

  int d = b - a;

  string ans;
  if (d % 2 == 0) {
    ans = "Alice";
  } else {
    ans = "Borys";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000

const ll MOD=998244353;

main(){
    int n,c,k;
    cin>>n>>c>>k;
    vec v;
    rep(i,n){
        int t=in();
        v.pb(t);
    }
    sort(all(v));
    int ans=0;
    rep(i,n){
        int cnt=0;
        int next=v[i]+k;
        while(i<n&&cnt<c&&v[i]<=next){
            i++;cnt++;
        }
        i--;
        ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 892
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll n,m;
    cin>>n>>m;
    string a,b;
    cin>>a>>b;
    ll x = __gcd(n,m);
    x = n / x * m;
    debug(x);
    REP(i,n)
    {
      ll tmp = (x / n) * i;
      debug(i,tmp);
      if(tmp % (x / m) == 0)
      {
        debug(tmp/(x/m),a,b);
        if(a[i] != b[tmp/(x/m)])
        {
          cout<<-1<<endl;
          return 0;
        }
      }
    }
    cout<<x<<endl;
}


Measured memory_bytes: 640
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input! {
        n: i32,
        v: [i32; n],
        c: [i32; n],
    }

    let mut ans = 0;
    for (v, c) in v.iter().zip(c.iter()) {
        if v > c {
            ans += v - c;
        }
    }
    println!("{}", ans);
}


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




int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);*/

    long long int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;



    char ch;
    cin>>ch;
    if(ch>=65 && ch<=90)
        cout<<"A\n";
    else
        cout<<"a\n";

    return 0;


}


Measured memory_bytes: 3632
#include<stdio.h>
 
int main(){
    int a, b ,c ,max,min,middle;
     
    scanf("%d %d %d", &a, &b, &c);
    
    max=a; 
    if (b>=max) {
      middle=a;
      max=b;
    } else {
        middle=b;
    }

    if (c>=max){
       min=middle;
       middle=max;
       max=c;
    } else if (c>=middle) {
       min=middle;
       middle=c;
    } else {
       min=c;
    }

    printf("%d %d %d\n", min, middle, max);
     
    return 0;
}
	

Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  
  long long d = c - a - b;
  
  if(d > 0 && d * d > 4 * a * b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'

int main(){
    int n;
    cin >> n;
    map<int, int> m;

    for(int i=0; i<n; ++i){
        int x;
        cin >> x;
        m[x]++;
    }

    int ans=0;
    for(auto x:m){
        if(x.second&1)
            ans++;
    }
    cout << ans;
}


Measured memory_bytes: 8040
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

int main() {
	int m, n;
	while (cin >> m >> n, m) {
		vector<char> num(8000000, 1);
		int k = 0, p = m;
		while (k < n) {
			for (int i = p; i < 8000000; i += p) {
				num[i] = 0;
			}
			while (num[p] == 0) {
				p++;
			}
			k++;
		}
		cout << p << endl;
	}
}

Measured memory_bytes: 10888
n,W,*t=map(int,open(0).read().split())
dp=[[0]*(W+1)for _ in range(n+1)]
for i,(v,w)in enumerate(zip(*[iter(t)]*2),1):
  for j in range(W+1):
    dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v,dp[i][j-w]+v)if j-w>=0else dp[i-1][j]
print(dp[n][W])


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

int main (void){
  long long int n,m,k,max = 0,k1,l,q;
  cin >> n >> m >> k;

  vector<long long int> a(n,0);
  vector<long long int> b(m,0);

  for(int i = 0;i < n;i++){
  cin >> a[i];
  }
  for(int i = 0;i < m;i++){
  cin >> b[i];
  }

  if(k < a[0] && k < b[0]){
    cout << "0\n";
    return 0;
  }

  for(int i = 0;i <= n;i++){
    k1 = k;
    if(i == 0){
      for(int p = 1;p <= m;p++){
        k1 = k1 - b[p-1];
        if(k1 < 0){
          l = p;
          q = k - k1;
          if(p-1 >= max){
            max = p-1;
          }
          break;
        }
        if(p == m){
          l = p;
          q = k - k1;
          if(p >= max){
            max = p;
          }
          break;
        }
      }
    }else{
      k = k - a[i-1];
      if(k < 0){
        if(i-1 >= max){
          max = i-1;
        }
        break;
      }
      k1 = k - q;
      for(int p = l;p >= 0;p--){
        if(p == m && k1 >= 0){
          if(p+i >= max){
            max = p+i;
          }
          break;
        }
        k1 = k1 + b[p-1];
        q -= b[p-1];
        if(k1 >= 0){
          l = p;
          q += b[p-1];
          if(p+i-1 >= max){
            max = p+i-1;
          }
          break;
        }
      }
    }
  }

  cout << max << endl;
  return 0;

}

Measured memory_bytes: 6340
#include<bits/stdc++.h>
#define    fios ios_base::sync_with_stdio(false); cin.tie(0);
#define    sf(x) scanf("%d",&x)
#define    sfl(x) scanf("%lld",&x)
#define    pf(x) printf("%d\n",x)
#define    pfl(x) printf("%lld\n",x)
#define    ll long long
#define    nl "\n"
#define    PB(x) push_back(x)
#define    For(i,n) for(int i=0; i<n; i++)
#define    PI acos(-1)
using namespace std;


int main()
{
  int n;

  cin>>n;

  ll a[n],ans=1;
  bool fl=0;

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

    if(a[i]==0)
    {

        fl=1;

    }


  }

  if(fl==1)
  {
      cout<<0<<nl;
      return 0;

  }

  ans=1;


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


        if(a[i]<=(long long)1e18/ans)
      {

          ans*=a[i];

      }
      else
      {

          cout<<-1<<nl;
          return 0;
      }

  }

     cout<<ans<<nl;


    return 0;
}


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

int main(){
  int n;
  cin >>n;
  int h[n];
  int min=1000000;
  int min_;
  int max=0;
  for (int i=0;i<n;i++){
    cin >> h[i];
  }
  for (int i=0;i<n;i++){
    if (max<h[i]){
      max=h[i];
    }
    if (max-1>h[i]){
      cout << "No";
      return 0;
    }
  }
  cout <<"Yes";
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,r; cin>>n>>r;
	if(n>=10) cout<<r<<endl;
	else{
		cout<<r+100*(10-n)<<endl;
	}
  return 0;
}


Measured memory_bytes: 256
n, d = map(int, input().split())
X = []
for i in range(n):
    X.append(list(map(int, input().split())))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        norm = 0
        for k in range(d):
            diff = abs(X[i][k] - X[j][k]) ** 2
            norm += diff
        for k in range(1, norm + 1):
            if k ** 2 == norm:
                ans += 1
                continue
print(ans)

Measured memory_bytes: 3064
import itertools
import math


def dist(a, b):
    return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)


N = int(input())
C = [tuple(map(int, input().split())) for _ in range(N)]

s = 0
for per in itertools.permutations(C):
    for i in range(N-1):
        s += dist(per[i], per[i+1])

print(s / len(list(itertools.permutations(C))))


Measured memory_bytes: 42588
#include <bits/stdc++.h>
using namespace std;
#define FI freopen ("inp.txt", "r", stdin)
#define FO freopen ("out.txt", "w", stdout)
#define FOR(v) for(int i : v) {printf("%d ", i);} printf("\n");
#define what_is(x) cerr << #x << " = " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
/* --------------------Code Bellow--------------------- */

long long W[105], V[105], mem[105][100005];
const int INF = 1e9 + 5;

long long knapsack(int i, int sack) {

    if (sack < 0) return -INF;
    if (i < 0) return 0;

    if (mem[i][sack] != -1) return mem[i][sack];

    long long ans1 = knapsack(i - 1, sack);
    long long ans2 = V[i] + knapsack(i - 1, sack - W[i]);

    return mem[i][sack] = max(ans1, ans2);
}

int main() {
    //FI;
    memset(mem, -1, sizeof(mem));

    int n, sack;
    scanf("%d %d", &n, &sack);
    for (int i = 0; i < n; ++i) {
        scanf("%lld %lld", &W[i], &V[i]);
    }

    printf("%lld\n", knapsack(n-1, sack));

    return 0;
}


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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

#define WMAX 100001
#define NMAX 100

int main(){
    int N,W;
    long long int w[NMAX],v[NMAX],k[2][WMAX],res;

    scanf("%d %d",&N,&W);
    memset(k,0,sizeof(long long int)*WMAX*2);

    for(int i=0;i<N;i++)
        scanf("%lld %lld",&w[i],&v[i]);
    
    k[0][w[0]] = v[0];            
    
    for(int i=1;i<N;i++){
        REPJ(W+1){
            if(j<w[i]){
                k[i%2][j] = k[(i-1)%2][j];
                continue;
            }
            else
                k[i%2][j] = max(k[(i-1)%2][j-w[i]]+v[i],k[(i-1)%2][j]);  
        }
    }
    
    res = 0;
    REPI(W+1)
        if(res<k[(N-1)%2][i])
            res = k[(N-1)%2][i];

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

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   int n;
   cin>>n;
   int flag=1;
   for(int i=1;i<10;i++){
      for(int j=1;j<10;j++){
         if(i*j==n) flag=0;
      }
   }
   flag==1? cout<<"No":cout<<"Yes";
}

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

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

    int lens = s.size();
    int lent = t.size();

    int sum = lent;
    for(int i=0; i<lens; i++){
        if(i+lent>lens) break;
        int cnt =0;
        for(int j=0; j<lent; j++){
            if(s[i+j]!=t[j]) cnt++;
        }
        sum = min(sum, cnt);
    }
    cout<<sum<<endl;
    return 0;
}


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

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

    int a[100010];
    int b[100010];
    int ans = INT_MAX;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        while(a[i] % 2 != 1){
            a[i] /= 2;
            b[i]++;
        }
        ans = min(ans, b[i]);
    }

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


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

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> v(H);
  for (int i = 0; i < H; i++) {
    cin >> v[i];
  }

  for (int i = 0; i < H; i++) {
    string s = v[i];

    for (int j = 0; j < W; j++) {
      char c = v[i][j];

      if (c == '.') {
        int sum = 0;
        int i_next = i + 1;

        for (int k = i - 1; k <= i_next; k++) {
          if (k < 0 || k >= H) {
            continue;
          }
          int j_next = j + 1;

          for (int l = j - 1; l <= j_next; l++) {
            if (l < 0 || l >= W) {
              continue;
            }
            if (v[k][l] == '#') {
              sum++;
            }
          }
        }
        cout << sum;
      } else {
        cout << c;
      }
    }
    cout << endl;
  }
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  ll ans=0;
  rep(i,N){
    ll a; cin >> a;
    ans += a;
  }
  cout << ans - N << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL  long long
#define INF 0x7FFFFFFF
using namespace std;
 
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a + b, min(b + c, c + a)) << endl; 
	return 0;
}

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

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

const int L = 10000 + 100;

struct Item {
  int w, s;
  ll v;
};

void update(ll& a, ll b) {
  if (b > a) a = b;
}

int main() {
  int N;
  while (cin >> N) {
    vector<Item> items(N);
    for (int i = 0; i < N; i++) cin >> items[i].w >> items[i].s >> items[i].v;
    sort(items.begin(), items.end(), [&](const Item& a, const Item& b) {
      return (a.w + a.s) < (b.w + b.s);
    });
    vector<ll> dp(L, 0);
    for (int i = 0; i < N; i++) {
      for (int j = L - 1; j >= 0; j--) {
        if (j <= items[i].s) {
          int w = min(L - 1, j + items[i].w);
          update(dp[w], dp[j] + items[i].v);
        }
      }
    }
    ll res = *max_element(dp.begin(), dp.end());
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define lli long long int

lli max(lli a,lli b)
{
   if(a>b)
   {
       return a;
   }
   return b;
}

lli power(lli x,lli n,lli mod)
{
    lli res=1;
    while(n>0)
    {
        if(n%2==1)
        {
            res=(res*x)%mod;
        }
        x=(x*x)%mod;
        n=n/2;
    }

    return  res%mod;

}




int main()
{
    long double a,b,c,d;
    cin>>a>>b>>c>>d;
    lli p=ceil(c/b);
    lli q=ceil(a/d);
    //cout<<p<<" "<<q<<"\n";
    if(p<=q)
    {
        cout<<"Yes"<<"\n";

    }
    else{
        cout<<"No"<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3732
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e5;
ll a[maxn],b[maxn],c[maxn],r1[20];
ll dis[205][205];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,m,r;
	cin>>n>>m>>r;
	for(int i=0;i<r;++i)
	{
		cin>>r1[i];
	}
	for(int i=0;i<205;++i)for(int j=0;j<205;++j)dis[i][j]=1e16;
	for(int i=0;i<m;++i)
	{
		ll x,y,z;
		cin>>x>>y>>z;
		dis[x][y]=z;
		dis[y][x]=z;
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
		{
			for(int k=1;k<=n;++k)
			{
				dis[j][k]=min(dis[j][k],dis[j][i]+dis[i][k]);
			}
		}
	}
	vector<int>per(r);
	for(int i=0;i<r;++i)per[i]=i;
	ll ans=1e16;
	while(1)
	{
		ll pa=0;
		for(int i=0;i<r-1;++i)
		{
			pa+=dis[r1[per[i]]][r1[per[i+1]]];
		}
		ans=min(ans,pa);
		bool aaa=next_permutation(all(per));
		if(!aaa)break;
	}
	cout<<ans<<'\n';
}













Measured memory_bytes: 640
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int n;
  string s;
  int an=0;
  int un=0; 
  int i;
  bool ans=true;

  cin>>n;
  rep(i,n){
    cin>>s;
    if(s[0]=='A'){
      an++;
    }else{
      un++;
      if(an<un)ans=false;
    }
  }

  if(an==un && ans)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

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

#define INF 100100100
#define MOD 1000000007

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

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   string S;
   cin >> S;
   if(S.size()==2)cout<<S;
   else {
      for(int i=S.size()-1;i>=0;i--){
         cout<<S[i];
      }
   }
   return 0;
}


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

using namespace std;

struct T {
  bool b = false;
  int w = 0;
} t;

int main() {
	int n, m;
	int p;
	int correct = 0, penalty = 0, temp = 0;
	string s;
	cin >> n >> m;
	vector<T> a (n+1);
	for(int i = 0; i < m; i++) {
		cin >> p >> s;
      	if(a[p].b == false) {
			if(s == "AC") {
				correct++;
				a[p].b = true;
			} else {
				a[p].w++;
			}
		}
	}

	for(int i = 1; i < a.size(); i++) {
		if(a[i].b) {
			penalty += a[i].w;
		}
	}
	cout << correct << " " << penalty;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
s = input()

def integral(li, query):
    res = [0]
    for i in li:
        cnt = res[-1] + (1 if i == query else 0)
        res.append(cnt)
    return res[1:]

w = integral(s, 'W')
e = integral(s[::-1], 'E')[::-1]

su = [x + y for x, y in zip(w, e)]
ans = min(su) - 1


print(ans)


Measured memory_bytes: 43108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  std::transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
  std::transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
  std::transform(s3.begin(), s3.end(), s3.begin(), ::toupper);
  cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 256
import math

N=int(input())

A=[0 for i in range(N)]
for i in range(N):
	A[i]=int(input())

c=0 
cnt=0

for k in range(N):
	x=math.sqrt(A[k])
	x=(int)(x)
	for j in range(2,x+1):
		if A[k]%j==0:
			cnt+=1
			break
	if cnt==0:
		c+=1
	
	cnt=0


print(c)


Measured memory_bytes: 5988
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>



using namespace std;
typedef long long ll;
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





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];
  }
  int max=-1;
  for(int i=0;i<N;i++){
    string l=s[i];
    int sum=1;
    for(int j=0;j<N;j++){
      if(j==i){
        continue;
      }else if(
        l==s[j]
      ){
        sum++;
      }

    }
    for(int j=0;j<M;j++){
      if(l==t[j]){
        sum--;
      }
    }
    if(sum>max){
      max=sum;

    }
  }
  if(max<0){
    cout<<0<<endl;
  }else{
    cout<<max<<endl;
  }
  

  
}


  
  

Measured memory_bytes: 256
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

ans = []

if n != 1:
    for i in range(n-1):
        ame = 0
        ame += sum(a1[0:i+1])+sum(a2[i:n])

        ans.append(ame)
    print(max(ans))
else:
    print(sum(a1)+sum(a2))

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

int main() {
  int a[3][3] = {0};
  cin >> a[0][0];
  cin >> a[0][1];
  cin >> a[1][1];
  for (int i = 0; i <= 300; i++) {
    bool flag = true;
    a[0][2] = i - (a[0][0] + a[0][1]);
    a[2][2] = i - (a[0][0] + a[1][1]);
    a[2][1] = i - (a[0][1] + a[1][1]);
    a[2][0] = i - (a[2][1] + a[2][2]);
    a[1][0] = i - (a[0][0] + a[2][0]);
    a[1][2] = i - (a[0][2] + a[2][2]);
    int s = a[0][0] + a[0][1] + a[0][2];
    for (int i = 0; i < 3; i++) {
      int tmp1 = 0, tmp2 = 0;
      for (int j = 0; j < 3; j++) {
        tmp1 += a[i][j];
        tmp2 += a[j][i];
      }
      if (s != tmp1) {
        flag = false;
      }
      if (s != tmp2) {
        flag = false;
      }
    }
    int tmp1 = a[0][0] + a[1][1] + a[2][2];
    int tmp2 = a[0][2] + a[1][1] + a[2][0];
    if (s != tmp1) {
      flag = false;
    }
    if (s != tmp2) {
      flag = false;
    }
    if (flag) {
      for (int i = 0; i < 3; i++) {
        cout << a[i][0];
        for (int j = 1; j < 3; j++) {
          cout << " " << a[i][j];
        }
        cout << endl;
      }
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int	n,x,cur=1,cnt=0; cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x==cur) cur++,cnt++;
	}
	if(cur==1) cout<<-1<<endl;
	else cout<<n-(cnt)<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
class Program {
  static void Main (string[] args) {
    string str = Console.ReadLine();
    string y_s = str.Substring(0, 4);
    int y_i = int.Parse(y_s);
    string m_s = str.Substring(5, 2);
    int m_i = int.Parse(m_s);
    string d_s = str.Substring(8, 2);
    int d_i = int.Parse(d_s);
    bool is_heisei = false;
    if (y_i >= 2019) {
      if (y_i == 2019 && m_i <= 4) {
        is_heisei = true;
      }
    } else {
      is_heisei = true;
    }
    if (is_heisei) {
      Console.WriteLine("Heisei");
    }
    else 
    {
      Console.WriteLine("TBD");
    }
  }
}

Measured memory_bytes: 13140