akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    for(int i = 0;i<4;i++){
      if(s.substring(i,i+1).equals("+")){
        ans++;
      }else{
        ans--;
      }
    }
    System.out.println(ans);
  }
}


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

ll MX = 1000005;
const int mod = 1000000007;

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;
  }
};

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; i++) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }

  bool isPrime(int x) {return f[x] == x;}

  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};



int main() {
  Sieve sieve(1e6);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  map<int, int> mp;
  rep(i, N) {
    auto f = sieve.factor(A[i]);
    for (auto p : f) {
      mp[p.first] = max(mp[p.first], p.second);
    }
  }

  mint lcm = 1;
  for (auto p : mp) {
    rep(i, p.second) {
      lcm *= p.first;
    }
  }

  mint ans;
  rep(i, N) {
    mint b = lcm / A[i];
    ans += b;
  }

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


Measured memory_bytes: 4984
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
long long k,cl,cr,cm,l,r,m,tot,a[2000100],INF=1e9+1;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	INF*=INF,cl=-INF,cr=INF;
	while(cl+1<cr){
		cm=(cl+cr)/2LL,tot=0LL;
		for(int i=0;i<n;i++){
			if(a[i]<0){
				l=-1,r=n;
				while(l+1<r){
					m=(l+r)/2LL;
					if(a[i]*a[m]<cm) r=m;
					else l=m;
				}
				tot+=(long long)(n)-r;
			}
			else{
				l=-1,r=n;
				while(l+1<r){
					m=(l+r)/2LL;
					if(a[i]*a[m]<cm) l=m;
					else r=m;
				}
				tot+=r;
			}
			if((a[i]*a[i])<cm) tot-=1LL;
		}
		tot/=2LL;
		if(tot<k) cl=cm;
		else cr=cm;
	}
	cout<<cl<<endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n, x;
		while (sc.hasNext()) {
			int count = 0;
			n = Integer.parseInt(sc.next());
			x = Integer.parseInt(sc.next());
			if (n == 0 && x == 0) break;
			for (int i=1; i < n+1; i++) {
				for (int j=i+1; j < n+1; j++) {
					for (int k=j+1; k < n+1; k++) {
						if (i + j + k == x) count++;
					}
				}
			}
			System.out.println(count);
		}
		sc.close();
	}
}

Measured memory_bytes: 19108
N = int(input())
x, u = [0] * N, [0] * N
for i in range(N):
    x[i], u[i] = input().split()
bsum, ysum = 0, 0
for i in range(N):
    if u[i] == 'BTC':
        bsum += float(x[i])
    else:
        ysum += float(x[i])
print(ysum + bsum * 380000)

Measured memory_bytes: 3060
// AOJ 2590: Unknown Switches
// 2017.11.30 bal4u@uu

#include <stdio.h>
#include <string.h>

char sw[1002][38];
char bul[1002][1002];
char can[38][1002];

int main()
{
	int n, m, q, i, j, k, c, cnt;
	char b1[40], b2[1010], *p;

	while (scanf("%d%d%d", &n, &m, &q) && n > 0) {
		memset(sw, 0, sizeof(sw));
		memset(bul, 0, sizeof(bul));
	    memset(can, 1, sizeof(can));
		for (i = 0; i < q; i++) {
			scanf("%s%s", b1, b2);
			for (p = b1, j = 0; j < n; j++) {
				sw[i][j] = *p++ & 1;
				if (i > 0) sw[i][j] ^= sw[i-1][j];
			}
			for (p = b2, j = 0; j < m; j++) bul[i][j] = *p++ & 1;
	    }

	    for (i = 0; i < q; i++) for (j = 0; j < n; j++) for (k = 0; k < m; k++)
			can[j][k] &= (sw[i][j] == bul[i][k]);

		for (i = 0; i < m; i++) {
			for (cnt = 0, j = 0; j < n; j++) if (can[j][i]) cnt++, k = j;
			if (cnt > 1) c = '?';
			else if (k < 10) c = k + '0';
			else             c = k -10 + 'A';
			putchar(c);
		}
		putchar('\n');
	}
	return 0;
}

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

double distance(pair<int, int> p1, pair<int, int> p2) {
  return sqrt(pow(p1.first-p2.first, 2) + pow(p1.second - p2.second, 2));
}

int main() {
  int n, cnt = 0;
  double ans = 0.0;
  cin >> n;
  vector<pair<int, int>> town;
  vector<int> t(n);
  for (int i = 0; i < n; ++i) {
    t[i] = i + 1;
    int x, y;
    cin >> x >> y;
    town.push_back(make_pair(x, y));
  }
  
  do {
    for (int i = 0; i < n-1; ++i) {
      ans += distance(town[t[i]-1], town[t[i+1]-1]);
    }
    ++cnt;
    
  } while (next_permutation(t.begin(), t.end()));
  
  cout << setprecision(12) << ans / cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
char buf[22222];
signed main(){
  scanf("%s",buf);
  string s(buf);
  int n=s.size();
  int ans=0;
  vector<int> v;
  for(int i=0;i<n;i++){
    if(s[i]!='\\') continue;
    int h=0,tmp=0;
    for(int j=i;j<n;j++){
      if(s[j]=='/') h--;
      if(s[j]=='_') tmp+=h*2;
      else tmp+=h*2+1;
      if(s[j]=='\\') h++;
      //cout<<j<<":"<<h<<" "<<tmp<<endl;
      if(s[j]!='/') continue;
      if(h==0){
	ans+=tmp/2;
	v.push_back(tmp/2);
	i=j;
	break;
      }
    }
  }
  cout<<ans<<endl;
  cout<<v.size();
  for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i];
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn=20;
struct node{
	int id,rl;
};
vector<node> adj[maxn];
int a[maxn];
int c[maxn],ans;
int n;
bool chk(){
	for (int i=1;i<=n;i++){
		if (c[i]==0) continue;
		for (int k=0;k<adj[i].size();k++){
			int id=adj[i][k].id;
			int rl=adj[i][k].rl;
			if (c[id]!=rl) return false;
		}
	}
	return true;
}
void dfs(int cur,int sum){
	if (cur==n+1){
		if (chk()){
			ans=max(ans,sum);
		}
		return;
	}
	c[cur]=0;
	dfs(cur+1,sum);
	c[cur]=1;
	dfs(cur+1,sum+1);
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		for (int j=1;j<=a[i];j++){
			node tp;
			cin>>tp.id>>tp.rl;
			adj[i].push_back(tp);
		}
	}
	dfs(1,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# coding: utf-8

A = map(int, list(raw_input()))

if A[0] + A[1] + A[2] + A[3] == 7:
    print str(A[0]) + "+" + str(A[1]) + "+" + str(A[2]) + "+" + str(A[3]) + "=7"

elif A[0] - A[1] + A[2] + A[3] == 7:
    print str(A[0]) + "-" + str(A[1]) + "+" + str(A[2]) + "+" + str(A[3]) + "=7"

elif A[0] + A[1] - A[2] + A[3] == 7:
    print str(A[0]) + "+" + str(A[1]) + "-" + str(A[2]) + "+" + str(A[3]) + "=7"

elif A[0] + A[1] + A[2] - A[3] == 7:
    print str(A[0]) + "+" + str(A[1]) + "+" + str(A[2]) + "-" + str(A[3]) + "=7"

elif A[0] + A[1] + A[2] - A[3] == 7:
    print str(A[0]) + "+" + str(A[1]) + "+" + str(A[2]) + "-" + str(A[3]) + "=7"

elif A[0] - A[1] - A[2] + A[3] == 7:
    print str(A[0]) + "-" + str(A[1]) + "-" + str(A[2]) + "+" + str(A[3]) + "=7"

elif A[0] - A[1] + A[2] - A[3] == 7:
    print str(A[0]) + "-" + str(A[1]) + "+" + str(A[2]) + "-" + str(A[3]) + "=7"

elif A[0] + A[1] - A[2] - A[3] == 7:
    print str(A[0]) + "+" + str(A[1]) + "-" + str(A[2]) + "-" + str(A[3]) + "=7"

elif A[0] - A[1] - A[2] - A[3] == 7:
    print str(A[0]) + "-" + str(A[1]) + "-" + str(A[2]) + "-" + str(A[3]) + "=7"


Measured memory_bytes: 2696
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

#include <regex>

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int main()
{
   int a,b;cin >> a >> b;
   string  s; cin >> s;

   std::regex re("\\d+");
   std::string textA(s.substr(0,a));
   std::string textB(s.substr(a+1,b));
   Yes(std::regex_match(textA,re)&&std::regex_match(textB,re)&&s.substr(a,1)=="-")
}

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

int main(){
    string s;
    cin >> s;
    if (s.size() != 4){
        cout << "No" << endl;
        exit(0);
    }
    vector<int> check(26, 0);
    for (int i = 0; i < 4; i++){
        if (s[i] - 'A' < 0 || s[i] - 'A' > 25){
            cout << "No" << endl;
            exit(0);
        }
        check[s[i] - 'A']++;
    }
    for (int i = 0; i < 26; i++){
        if (check[i] != 0 && check[i] != 2){
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        StringBuilder s = new StringBuilder(scanner.nextLine());
        s.append(s);
        String p = scanner.nextLine();

        if(!s.toString().contains(p)){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }

        scanner.close();
    }
}



Measured memory_bytes: 26172
N = int(input())
a = list(map(int, input().split()))
ans = [0]*N
anss = []
ball = 0
for i in range(N, 0, -1):
    count = N//i
    total = 0
    for j in range(1, count+1):
        total += ans[i*j-1]
    if total%2 == a[i-1]:
        ans[i-1] = 0
    else:
        ans[i-1] = 1
        anss.append(i)
        ball += 1
if ball == 0:
    print(0)
else:
    print(ball)
    anss.reverse()
    print(" ".join(map(str, anss)))


Measured memory_bytes: 106548
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
count = 0 
for i in range(a+1) :
    for j in range(b+1) :
        for k in range(c+1) :
            if (500*i + 100*j + 50*k ) == x:
                 count += 1
            
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    string s; cin>>s;
    int n=s.size();
    long long ans=0;
    long long ww=0;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='W') ww++;
        if(s[i]=='B') ans+=ww;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
<?PHP
$first_line = fgets(STDIN);
$second_line = fgets(STDIN);
$first_line_array = explode(" ", $first_line);
$steps_amount=$first_line_array[0];
//ジャンプで飛べる足場の数
$skip_power=$first_line_array[1];
$steps_heights = explode(" ", $second_line);

//足場ごとにたどり着くまでのコストの総和の最小値を入れていく配列
$dps=[];

foreach (range(0, $steps_amount-1) as $index) {

    // 最初にいた足場に辿り着くまでのコストは０
    if($index===0){
        $dps[0]=0;
        continue;
    }

    // 一つ前の踏み台につくまでの総コスト
    $previous_total_cost=$dps[$index-1];
    // 一つ前の踏み台から飛ぶためのコスト
    $jump_cost=abs($steps_heights[$index]-$steps_heights[$index-1]);
    // とりあえず一つ前の踏み台から飛んだ場合の総コストで初期化して、数を比較して最小値を入れていく
    $dps[$index]= $previous_total_cost+$jump_cost;
    
    // 足場を飛ばした場合のことを考える
    foreach (range(1, $skip_power) as $i) {
        if($index>=$i){
            $new_total_cost=abs($dps[$index - $i] + abs($steps_heights[$index] - $steps_heights[$index - $i]));
            // 足場を飛ばした時のコストの方が少ない場合は値を更新する
            if ($dps[$index]> $new_total_cost){
                $dps[$index]=$new_total_cost;
            }
        }
    }
    
}

//最後の足場の総コストを出力
echo end($dps);

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

int main() {
char X, Y;
cin >> X >> Y;
int x, y;
if(X == 'A'){
	x = 10;
}
if(X == 'B'){
	x = 11;
}
if(X == 'C'){
	x = 12;
}
if(X == 'D'){
	x = 13;
}
if(X == 'E'){
	x = 14;
}
if(X == 'F'){
	x = 15;
}
if(Y == 'A'){
	y = 10;
}
if(Y == 'B'){
	y = 11;
}
if(Y == 'C'){
	y = 12;
}
if(Y == 'D'){
	y = 13;
}
if(Y == 'E'){
	y = 14;
}
if(Y == 'F'){
	y = 15;
}

if(x == y){
	cout << "=" << endl;
}
else if(x < y){
	cout << "<" << endl;
}
else{
	cout << ">" << endl;
}
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<string> ts = {
    "dream", "dreamer", "erase", "eraser"
  };
  for (ll i = 0; i < ts.size(); ++i) {
    reverse(ts[i].begin(), ts[i].end());
  }

  reverse(s.begin(), s.end());
  while (s.size() > 0) {
    bool ok = false;
    for (ll j = 0; j < ts.size(); ++j) {
      if (equal(ts[j].begin(), ts[j].end(), s.begin())) {
        s = s.substr(ts[j].size());
        ok = true;
        break;
      }
    }
    if (!ok) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}

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

const ll INF = 1LL << 60;

const int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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];
  }
} comb(2e6 + 10);

ll r1, c1, r2, c2;

mint f(ll r, ll c) {
    return comb(r + c + 2, r + 1) - 1;
}

int main() {
    cin >> r1 >> c1 >> r2 >> c2;
    r1--; c1--;
    mint ans = f(r2, c2);
    ans -= f(r1, c2);
    ans -= f(r2, c1);
    ans += f(r1, c1);

    cout << ans << endl;
}

Measured memory_bytes: 34176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <fstream>

using namespace std;

typedef long long ll;
struct Magic{
	string name;
	int mp;
	bool isAll;
	int dmg;
};

int n;
int hps[101];
int m;
Magic magics[101];
const ll INF=100000000000000LL;

// SÌÉ é_[Wð^¦éÌÉKvÈÅ¬ÌMP(¶ÝµÈ¯êÎ-1)
ll dp[2][200001];
// PÌÉ é_[Wð^¦éÌÉKvÈÅ¬MP(¿å¤ÇÌ_[WÅÈ­Äàæ¢
ll dp2[2][200001];

int main(){
	while(cin>>n&&n){
		vector<Magic> allMagics;
		vector<Magic> singleMagics;
		vector<Magic> crit;
		for(int i=0;i<n;i++)cin>>hps[i];
		cin>>m;
		for(int i=0;i<m;i++){
			cin>>magics[i].name>>magics[i].mp;
			string tgt;
			cin>>tgt;
			if(tgt=="All")magics[i].isAll=true;
			else magics[i].isAll=false;
			cin>>magics[i].dmg;
			if(magics[i].dmg==0)continue;
			else if(magics[i].isAll){
				// 100000ÈãÌêAêKE
				if(magics[i].dmg>=100000)crit.push_back(magics[i]);
				else allMagics.push_back(magics[i]);
			}
			else singleMagics.push_back(magics[i]);
		}
		ll minMP=INF;
		// êKE
		for(int i=0;i<(int)crit.size();i++)minMP=min(minMP,crit[i].mp*1LL);
		for(int i=0;i<2;i++)for(int j=0;j<=200000;j++)dp[i][j]=dp2[i][j]=INF;
		dp[(allMagics.size())%2][0]=0;
		dp2[(singleMagics.size())%2][0]=0;
		for(int i=allMagics.size()-1;i>=0;i--){
			for(int j=0;j<=200000;j++){
				int dmg=j;
				int pos=i;
				ll res=INF;
				int cur=(i+1)%2;
				int nxt=i%2;
				res=min(res,dp[cur][dmg]);
				// ¿å¤Ç0ÉÈéKvª é
				if(dmg-allMagics[pos].dmg>=0)
					res=min(res,dp[nxt][dmg-allMagics[pos].dmg]+allMagics[pos].mp);
				dp[nxt][dmg]=res;
			}
		}
		for(int i=singleMagics.size()-1;i>=0;i--){
			for(int j=0;j<=200000;j++){
				int dmg=j;
				int pos=i;
				ll res=INF;
				int cur=(i+1)%2;
				int nxt=i%2;
				res=min(res,dp2[cur][dmg]);
				if(dmg-singleMagics[pos].dmg>=0)
					res=min(res,dp2[nxt][dmg-singleMagics[pos].dmg]+singleMagics[pos].mp);
				// KvÈÌÍ¡ñÌªÌÝ
				else res=min(res,singleMagics[pos].mp*1LL);
				dp2[nxt][dmg]=res;
			}
		}
		// SÌÉ^¦é_[WÊðvZ
		for(int i=0;i<=200000;i++){
			if(dp[0][i]==INF)continue;
			ll cnt=0;
			for(int j=0;j<n;j++){
				int a=hps[j]-i;
				if(a>0)cnt+=dp2[0][a];
			}
			minMP=min(minMP,cnt+dp[0][i]);
		}
		cout<<minMP<<endl;
	}
	return 0;
}

Measured memory_bytes: 7184
/*
* @Author: dnhirapara
* @Date: 2020-04-27 23:04
* @Name: dp_h
*/
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define log(x) cerr << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

void in_out_file(){
    #ifdef _DEBUG
        freopen("F:/Coding/CompetitiveProg/static/input.txt", "r", stdin);
        freopen("F:/Coding/CompetitiveProg/static/output.txt", "w", stdout);
        freopen("F:/Coding/CompetitiveProg/static/debug.txt", "w", stderr);
    #endif
}

const long long int mod=1e9+7;

#define add(a,b) ((a%mod)+(b%mod))%mod
#define sub(a,b) ((a%mod)-(b%mod)+mod)%mod
#define mul(a,b) ((a%mod)*(b%mod))%mod


//@time comp : O(n^2)
//@space comp : O(n^2)
int main(){
    // cin.ignore(); must be there when using getline(cin, s)
    #ifndef AUTO
        in_out_file();
    #endif
    ll n, m;
    cin>>n>>m;
    ll dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    dp[1][1] = 1;
    string s;
    for(ll i=1;i<=n;i++){
        cin>>s;
        for(ll j=1;j<=m;j++){
            if(s[j-1]=='.'){
                dp[i][j] = add(dp[i][j],add(dp[i-1][j],dp[i][j-1]));
            }
        }
    }
    // for(ll i=0;i<=n;i++){
    //     for(ll j=0;j<=m;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    cout<<dp[n][m]<<endl;
    return 0;
}


Measured memory_bytes: 8064
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    S=ST()
    if S[:N//2] == S[N//2:]:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int l,i;
  string s;
  cin>>s;
  l=s.length();
  for (i=1;i<l;i++)
  {
    if (s[i]==s[i-1])
    {
      cout<<"Bad";
      return 0;
    }
  }
  cout<<"Good";
  return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static char s[200001];

int main(void) {
	scanf("%s", s);

	size_t aPos = 0;
	while (true) {
		if (s[aPos] == 'A') {
			break;
		}

		aPos++;
	}

	size_t zPos = strlen(s) - 1;
	while (true) {
		if (s[zPos] == 'Z') {
			break;
		}

		zPos--;
	}

	printf("%zu\n", zPos - aPos + 1);

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> p(N+1);
    for (int i = 0; i < N; i++) {
        int n;
        cin >> n;
        p[n] = i+1;
    }
    vector<long int> num;
    long int ans = 0;
    num = {0, 0, p[N], N+1, N+1};
    for (int i = N-1; i >= 1; i--) {
        auto lb = lower_bound(num.begin(), num.end(), p[i]);
        int t = lb - num.begin();
        ans += i * ((num[t-1] - num[t-2]) * (num[t] - p[i]) + (num[t+1] - num[t]) * (p[i] - num[t-1]));
        num.insert(lb, p[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2040
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n - 1; i++) {
			int b = Integer.parseInt(sa[i]) - 1;
			a[b]++;
		}
		br.close();

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			pw.println(a[i]);
		}
		pw.flush();
	}
}


Measured memory_bytes: 63004
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  if (n%2) {
    cout << 0 << endl;
    return 0;
  }
  else {
    n/=2;
    ll b=0;
    while (n){
      b+=n/5;
      n/=5;
    }
    cout << b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(W, H, P, Q):
    W += 1
    H += 1
    ans = sum(P) + sum(Q)

    P.sort()
    Q.sort()
    # print(P)
    for q in Q:
        i = bisect.bisect_left(P, q)
        # print(i, q)
        ans += q * (len(P)-i)
    for p in P:
        i = bisect.bisect_right(Q, p)
        # print(i, p)
        ans += p * (len(Q)-i)

    return ans


def main():
    W, H = read_int_n()
    P = [read_int() for _ in range(W)]
    Q = [read_int() for _ in range(H)]
    print(slv(W, H, P, Q))


if __name__ == '__main__':
    main()


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

int main()
{
    ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

    int n ; cin >> n ;

    vector < int > ve1, ve2 , ve;

    for(int i = 1 ; i <= n ; i++){
         ve.push_back(i) ;
         int x;  cin >> x;
         ve1.push_back(x);
    }

    for(int i = 0 ; i < n ; i++){
         int x; cin >> x ;
         ve2.push_back(x);
    }

    int res1 = 0 , res2 = 0 ;
    int id = 1;

    do{

       bool ok = 1 ;
       for(int i = 0 ; i < n ; i++){
            if(ve1[i] != ve[i]) ok = 0 ;
       }

       if(ok) res1 = id ;

       ok = 1 ;
       for(int i = 0 ; i < n ; i++){
          if(ve2[i] != ve[i]) ok = 0 ;
       }

       if(ok) res2 = id ;


       id++ ;
    }while(next_permutation(ve.begin() , ve.end()));

    cout << abs(res1 - res2) << endl ;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    static long INF = 1000000000000L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int q = sc.nextInt();
        long[] s = new long[a + 2];
        long[] t = new long[b + 2];
        long[] x = new long[q + 2];
        s[0] = -INF;
        for (int i = 1; i <= a; i++) {
            s[i] = sc.nextLong();
        }
        s[a + 1] = INF;

        t[0] = -INF;
        for (int i = 1; i <= b; i++) {
            t[i] = sc.nextLong();
        }
        t[b + 1] = INF;

        for (int i = 0; i < q; i++) {
            x[i] = sc.nextLong();
        }
        Arrays.sort(s);
        Arrays.sort(t);
        for (int i = 0; i < q; i++) {
            int ok = binSearch(s, a + 1, -1, x[i]);
            long sb = s[ok];
            long sa = s[ok - 1];

            ok = binSearch(t, b + 1, -1, x[i]);
            long tb = t[ok];
            long ta = t[ok - 1];

            long res1 = Math.abs(tb - x[i]) * 2 + Math.abs(sa - x[i]);
            long res2 = Math.abs(sa - x[i]) * 2 + Math.abs(tb - x[i]);
            long res3 = Math.abs(ta - x[i]) * 2 + Math.abs(sb - x[i]);
            long res4 = Math.abs(sb - x[i]) * 2 + Math.abs(ta - x[i]);
            long res5 = Math.abs(ta - x[i]) + Math.abs(sa - ta);
            long res6 = Math.abs(sa - x[i]) + Math.abs(ta - sa);
            long res7 = Math.abs(tb - x[i]) + Math.abs(sb - tb);
            long res8 = Math.abs(sb - x[i]) + Math.abs(tb - sb);
            long ans = Math.min(res1,
                Math.min(res2,
                    Math.min(res3,
                        Math.min(res4, Math.min(res5, Math.min(res6, Math.min(res7, res8)))))));
            System.out.println(ans);
        }
    }
    public static int binSearch(long[] s, long ok, long ng, long x) {
        while (Math.abs(ok - ng) > 1) {
            long mid = (ok + ng) / 2;
            if (solve(s[(int) mid], x)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        return (int) ok;
    }
    public static boolean solve(long s, long x) {
        if (s > x) {
            return true;
        }
        return false;
    }
}


Measured memory_bytes: 99892
using System;
using System.Collections.Generic;

namespace AtCoderTest
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine().Trim());
            var buff = Console.ReadLine().Trim().Split();
            List<uint> a = new List<uint>();
            uint xorsum = 0;
            uint tmpbf;
            foreach (var bf in buff) {
                tmpbf = uint.Parse(bf);
                a.Add(tmpbf);
                xorsum=xorsum^tmpbf;
            }

            for (int i = 0; i < N; i++) {
                uint result = xorsum ^ a[i];
                Console.Write(result);
                if (i != N - 1) Console.Write(" ");
                else Console.Write(System.Environment.NewLine);
            }
        }


    }

}


Measured memory_bytes: 57680
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
    LL res=1;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
    assert(MOD>=SIZE);
    fac[0]=1;
    REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD;
    inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2);
    for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
int main(){
    MOD = 998244353;
    build();
    LL N,A,B,K;
    R(N,A,B,K);
    LL an=0;
    FOR(i,0,N){
        if(K>=i*A&&(K-i*A)%B==0&&(K-i*A)/B<=N){
            ADD(an,C(N,i)*C(N,(K-i*A)/B));
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    ll n;
    cin>>n;
    vll v(n);
    rep(i,n)cin>>v[i];
    vll csum(n+1,0);
    rep(i,n)csum[i+1]=csum[i]+v[i];
    map<ll,ll> m;
    rep(i,n+1)m[csum[i]]++;
    ll ans=0;
    irep(i,m){
        ans+=(i->second)*(i->second-1)/2;
    }
    fin(ans);

}


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

const int MAXN = 100005;

int N, M;
bool dp[MAXN];
int cnt[MAXN];

int main() {
	scanf("%d%d", &N, &M);
	dp[1] = true;
	for (int i = 1; i <= N; i++)
		cnt[i] = 1;
	while (M--) {
		int x, y;
		scanf("%d%d", &x, &y);
		cnt[x]--;
		cnt[y]++;
		if (dp[x]) {
			dp[y] = true;
			if (!cnt[x]) dp[x] = false;
		}
	}
	int sol = 0;
	for (int i = 1; i <= N; i++)
		sol += dp[i];
	printf("%d\n", sol);
	return 0;
}

Measured memory_bytes: 640
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
    auto start = chrono::high_resolution_clock::now();
#endif
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    VII arr(n + 1, 0);
    for (int i = 1; i*i <= n;++i)
    {
        for (int j = 1; j*j <= n;++j)
        {
            for (int k = 1; k*k <= n;++k)
            {
                int v = i * i + j * j + k * k + i * j + j * k + i * k;
                if(v<=n)
                {
                    arr[v]++;
                }
            }
        }
    }

    for (int i = 1; i <= n;++i)
        cout << arr[i] << '\n';

    exit(0);

#ifdef LOCAL
    auto end = chrono::high_resolution_clock::now();
    double time_taken =
        chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    time_taken *= 1e-9;

    cerr << "\nTime taken by program is : " << fixed
         << time_taken << setprecision(9);
    cerr << " sec" << endl;
#endif
    return 0;
}


Measured memory_bytes: 3544
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> list = RLl();
            Console.WriteLine((double)list[0] / list[1]);
        }
        private static List<int> RLl() => Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <chrono>
#include <vector>

using namespace std;
typedef map<int, int> NumDict;

int main()
{
    int n, buf;
    cin >> n;
    NumDict num_cnt_even;
    NumDict num_cnt_odd;
    for (int i = 1; i < n + 1; i++)
    {
        cin >> buf;
        if (i % 2 == 0)
        {
            if (num_cnt_even.find(buf) == num_cnt_even.end())
            {
                num_cnt_even[buf] = 1;
            }
            else
            {
                num_cnt_even[buf] += 1;
            }
        }
        else
        {
            if (num_cnt_odd.find(buf) == num_cnt_odd.end())
            {
                num_cnt_odd[buf] = 1;
            }
            else
            {
                num_cnt_odd[buf] += 1;
            }
        }
    }

    vector<pair<int, int> > pairs_even;
    vector<pair<int, int> > pairs_odd;

    for (auto &x : num_cnt_even) {
        pairs_even.emplace_back(x.second, x.first);
        if (pairs_even.size() == 1) {
            pairs_even.emplace_back(0, -1);
        }
    }
    for (auto &x : num_cnt_odd) {
        pairs_odd.emplace_back(x.second, x.first);
        if (pairs_odd.size() == 1) {
            pairs_odd.emplace_back(0, -1);
        }
    }
    sort(pairs_even.rbegin(), pairs_even.rend());
    sort(pairs_odd.rbegin(), pairs_odd.rend());

    int ans = 0;
    for (int i=0; i<2; i++) {
        for (int j=0; j<2; j++) {
            if ( pairs_even[i].second != pairs_odd[j].second ) {
                ans = max(ans, pairs_even[i].first + pairs_odd[j].first);
            }
        }
    }
    cout << n - ans << endl;
    return 0;
}

Measured memory_bytes: 6140
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    a: i32,
    b: i32,
  }
  let fee = if a >= 13 {
    b
  } else if a >= 6 {
    b / 2
  } else {
    0
  };
  println!("{}", fee);
}


Measured memory_bytes: 4352
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	P := sc.nextIntSlice(N)
	ans := 0
	for i := 1; i < N-1; i++ {
		mi := min(P[i-1], P[i+1])
		ma := max(P[i-1], P[i+1])
		if mi < P[i] && P[i] < ma {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# dp[i][j]
def init_dp_table(i, j, init=INF):
  return [[ init for _ in range(j)] for _ in range(i)]

########

S = input()

dp = init_dp_table(len(S)+1, 4, 0)
dp[0][0] = 1

for i in range(len(S)):
    Si = S[i]
    if Si == "A" or Si == "?":
        dp[i+1][0] += dp[i][0] % MOD
        dp[i+1][1] += dp[i][1] % MOD
        dp[i+1][2] += dp[i][2] % MOD
        dp[i+1][3] += dp[i][3] % MOD
        dp[i+1][1] += dp[i][0] % MOD
    if Si == "B" or Si == "?":
        dp[i+1][0] += dp[i][0] % MOD
        dp[i+1][1] += dp[i][1] % MOD
        dp[i+1][2] += dp[i][2] % MOD
        dp[i+1][3] += dp[i][3] % MOD
        dp[i+1][2] += dp[i][1] % MOD
    if Si == "C" or Si == "?":
        dp[i+1][0] += dp[i][0] % MOD
        dp[i+1][1] += dp[i][1] % MOD
        dp[i+1][2] += dp[i][2] % MOD
        dp[i+1][3] += dp[i][3] % MOD
        dp[i+1][3] += dp[i][2] % MOD

print(dp[len(S)][3] % MOD)

Measured memory_bytes: 58460
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
  int n;
  cin>>n;
  vector<int> f(n);
  for(int i=1; i*i<n; i++){
    int i2 = i*i;
    for(int j =i; i2 +j *j<n; j++){
      int j2 =j*j;
      for(int k =j; i2 + j2 + k*k<n; k++){
		if(i2 +j2 + k*k + i*j + j *k+ k*i <=n){
	  		if(i ==j){
	    		if(j==k){
	      		f.at(i2 +j2 + k*k + i*j + j *k+ k*i -1)++;
	    		}
	    		else{
	      			f.at(i2 +j2 + k*k + i*j + j *k+ k*i -1) += 3;
	    		}
			}
			else{
	    	if(j ==k){
	      	f.at(i2 +j2 + k*k + i*j + j *k+ k*i -1) += 3;
	    	}
	    	else{
	      	f.at(i2 +j2 + k*k + i*j + j *k+ k*i -1) += 6;
	    	}
	  	  	}		
	  	}
	  	
      }
    }
  }
  for(int i =0; i<n; i++){
    cout<<f.at(i)<<endl;
  }
  
//    cout << fixed << setprecision(10);
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}


Measured memory_bytes: 256