akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,t,a;
  cin>>n>>t>>a;
  vector<Int> h(n);
  for(Int i=0;i<n;i++) cin>>h[i];
  t*=1000;a*=1000;
  auto calc=[&](Int x){return abs((t-x*6)-a);};
  
  Int ans=0;
  for(Int i=0;i<n;i++)
    if(calc(h[i])<calc(h[ans])) ans=i;
 
  //for(Int i=0;i<n;i++) cout<<calc(h[i])<<endl;
  cout<<ans+1<<endl;
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for (ll i = 0; i < (n); i++)
# define reps(i, n) for (ll i = 1; i <= (n); i++)
# define foreps(i, m, n) for (ll i = (m); i < (n); i++)
# define len(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const long long mod = 1e9 + 7;
const long long inf = 1e18;

int main() {
    ll N; cin >> N;
    string S; cin >> S;

    ll Ecnt = 0;
    rep(i, len(S)) {
        if (S[i] == 'E') ++Ecnt;
    }

    ll res = 1e9, Waft = 0;
    rep(i, len(S)) {
        if (S[i] == 'W') {
            res = min(res, Waft + Ecnt);
            ++Waft;
        }
        else {
            --Ecnt;
            res = min(res, Waft + Ecnt);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3872
def delete_head_zeros(n):
	n = str(n)
	l = len(n)
	if "." in n:
		l = n.find(".")
	head_zeros = 0
	for i in range(l - 1):
		if n[i] == "0":
			head_zeros += 1
		else:
			break

	return n[head_zeros:]

# compare a, b
# a, b: int or string
def bigint_compare(a, b):
	a = delete_head_zeros(a)
	b = delete_head_zeros(b)
	if len(a) > len(b):
		return 1
	elif len(a) < len(b):
		return -1
	else:
		if a > b:
			return 1
		elif a < b:
			return -1
		else:
			return 0

# calculate a + b
# a, b: int or string
def bigint_plus(a, b):
	a = str(a)
	b = str(b)

	d = max([len(a), len(b)])
	a = '0' * (d - len(a)) + a
	b = '0' * (d - len(b)) + b

	ans = ""
	carry = 0
	for i in range(d):
		s = int(a[-i-1]) + int(b[-i-1]) + carry
		carry = s // 10
		ans = str(s % 10) + ans
	else:
		if carry:
			ans = str(carry) + ans

	return ans

# calculate a - b
# a, b: int or string
def bigint_minus(a, b): 
	a = str(a)
	b = str(b)
	M = []
	m = []
	sign = ""

	if len(a) > len(b) or (len(a) == len(b) and a >= b):
		[M, m] = [a, b]
	else:
		[M, m] = [b, a]
		sign = "-"
	m = '0' * (len(M) - len(m)) + m

	ans = ""
	borrow = 0
	for i in range(len(M)):
		s = int(M[-i-1]) - int(m[-i-1]) - borrow
		if s < 0:
			borrow = 1
			s += 10
		else:
			borrow = 0
		ans = str(s) + ans

	return sign + delete_head_zeros(ans)

# calculate a * b
# a, b: int or string
def bigint_multiply(a, b):
	a = str(a)
	b = str(b)

	md = []
	for j in range(len(b)):
		carry = 0
		mj = ""
		for i in range(len(a)):
			m = int(a[-i-1]) * int(b[-j-1]) + carry
			carry = m // 10
			mj = str(m % 10) + mj
		else:
			if carry:
				mj = str(carry) + mj
		md.append(mj)

	ans = 0
	for k in range(len(md)):
		ans = bigint_plus(md[k] + "0" * k, ans)

	return ans


# calculate a / b to d digits after decimal point
# a, b, d: int or string
def bigint_divide(a, b, d = 0):
	a = str(a)
	b = str(b)
	d = int(d)
	if d < 0:
		d = 0

	ans = ""
	r = ""
	for i in range(len(a) + d):
		q = 0
		if i < len(a):
			r += a[i]
		elif i == len(a):
			ans += "."
			r += "0"
		else:
			r += "0"

		if bigint_compare(r, b) == -1:
			ans += str(q)
		else:
			while bigint_compare(r, b) >= 0:
				r = bigint_minus(r, b)
				q += 1
			ans += str(q)

	return delete_head_zeros(ans)

def main():
	N, K = input().split(" ")
	A = [int(a) - 1 for a in input().split(" ")]
	visited = [0] * int(N)
	towns = []
	now = 0
	while visited[now] == 0:
		towns.append(now)
		visited[now] = 1
		now = A[now]
	else:
		loop_begin_idx = towns.index(now)
		loop_end_idx = len(towns) - 1
		loop_n = loop_end_idx - loop_begin_idx + 1
	if int(K) < len(towns):
		print(towns[int(K)] + 1)
		return 0
	K_from_loop = bigint_minus(K, loop_begin_idx)
	q = bigint_divide(K_from_loop, loop_n)
	r = bigint_minus(K_from_loop, bigint_multiply(loop_n, q))
	print(towns[loop_begin_idx + int(r)] + 1)

main()


Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
const double EPS = 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

using namespace std;

int partition(int A[], int p, int r){
  int x=A[r], i=p-1;
  for(int j=p;j<r;j++)
    if(A[j]<=x)swap(A[++i],A[j]);
  swap(A[i+1],A[r]);
  return i+1;
}

int main(){
  int n,A[100000];
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  int a=partition(A,0,n-1);
  for(int i=0;i<n;i++){
    if(i!=0)cout<<" ";
    if(i==a)cout<<"[";
    printf("%d",A[i]);
    if(i==a)cout<<"]";
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using Graph = vector<vector<int>>;

vector<int> color;

bool dfs(const Graph &G, int v, int c){
  color[v] = c;
  for(auto next_v : G[v]){
    if(color[next_v] == c) return false;
    if(color[next_v] == 0 && !dfs(G, next_v, -c)) return false;
  }
  return true;
}

int main(){
  long long n, m;
  cin >> n >> m;
  Graph G(n);
  int a, b;
  for(int i=0; i<m; ++i){
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  color.assign(n, 0);
  bool flag = true;
  for(int i=0; i<n; ++i){
    if(color[i] == 0){
      if(!dfs(G, i, 1)) flag = false;
    }
  }

  if(flag){
    long long white = 0;
    long long black = 0;
    for(int i=0; i<n; ++i){
      if(color[i] == 1) white++;
      else if(color[i] == -1) black++;
    }
    cout << white*black - m << "\n";
  }
  else{
    cout << n*(n-1)/2 - m << "\n"; //任意の２点間の距離を奇数にできる
  }
}

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

// Union-Find Tree
struct UnionFind {
  vector<int> par; // 親のid(親の場合, 集合の頂点数の-1倍)
  
  UnionFind(int n): par(n, -1) {}
  
  void init(int n) {
    par.assign(n, -1);
  }
  
  // 根の検索
  int find(int x) {
    if (par[x] < 0) return x;
    return par[x] = find(par[x]);
  }
  
  // xとyの属する集合を併合
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  
  // xとyが同じ集合に属するか
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  
  // 集合の頂点数
  int size(int x) {
    return -par[find(x)];
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  UnionFind uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, uf.size(i));
  
  cout << ans << '\n';
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int a, b, c;
void solve()
{
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    cout << max((c - (a - b)), 0) << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	s := ""
	fmt.Scan(&s)
	info := strings.Split(s, "")
	result := 0
	for i := 0; i < len(info); i++ {
		switch {
		case info[i] == "+":
			result += 1
		case info[i] == "-":
			result -= 1
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
a=input()
b=input()
dic_a={}
dic_b={}
for i in a:
    if i not in dic_a:
        dic_a[i]=1
    else:
        dic_a[i] += 1
for i in b:
    if i not in dic_b:
        dic_b[i]=1
    else:
        dic_b[i] += 1


print("Yes" if (sorted(dic_a.values())==sorted(dic_b.values())) else "No" )

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

using namespace std;

const int N = 100000 + 77;
int n , a[N] , A;
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n;
   for(int i = 1;i <= n;++ i)
      cin >> a[i];
   sort(a + 1 , a + 1 + n);
   for(int i = 1;i <= n;++ i){
      int t = a[i] - a[i - 1];
      if(t & 1)
         A ^= (n - i + 1);
   }
   if(A == 0)
      cout << "second";
   else
      cout << "first";

   return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
  ll x,y;
  cin >> x >> y;
    long long res = 1LL<<60;
    //cout << res << endl;
    if (x <= y) res = min(res, y-x);
    if (-x <= y) res = min(res, y+x+1);
    if (x <= -y) res = min(res, -y-x+1);
    if (-x <= -y) res = min(res, -y+x+2);
    cout << res << endl;

    
}

Measured memory_bytes: 3616
#include <algorithm>
#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()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int X;
    cin >> X;
    if (X >= 400 && X <= 599) {
        cout << 8 << endl;
    } else if (X >= 600 && X <= 799) {
        cout << 7 << endl;
    } else if (X >= 800 && X <= 999) {
        cout << 6 << endl;
    } else if (X >= 1000 && X <= 1199) {
        cout << 5 << endl;
    } else if (X >= 1200 && X <= 1399) {
        cout << 4 << endl;
    } else if (X >= 1400 && X <= 1599) {
        cout << 3 << endl;
    } else if (X >= 1600 && X <= 1799) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

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

int main()
{
    bitset<64> bit;
    int q;
    int i;
    int operation;
    cin >> q;
    while (q--)
    {

        cin >> operation;
        switch (operation)
        {
        case 0:
            cin >> i;
            cout << bit.test(i) << endl;
            break;

        case 1:
            cin >> i;
            bit.set(i);
            break;

        case 2:
            cin >> i;
            bit.reset(i);
            break;

        case 3:
            cin >> i;
            bit.flip(i);
            break;

        case 4:
            cout << bit.all() << endl;
            break;

        case 5:
            cout << bit.any() << endl;
            break;

        case 6:
            cout << bit.none() << endl;
            break;

        case 7:
            cout << bit.count() << endl;
            break;

        case 8:
            cout << bit.to_ulong() << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}

ll n;
ll a[105];
ll dp[100005][2];

ll solve(ll k,ll f)
{
	if(k==0)
	{
		return (f+1)%2;
	}
	if(dp[k][f]!=-1)
	{
		return dp[k][f];
	}
	ll i,w=0;
	for(i=0;i<n;i++)
	{
		if(k-a[i]>=0)
		{
			if(solve(k-a[i],(f+1)%2)==f)
			{
				w=1;
				break;
			}
		}
	}
	if(w==1)
	{
		dp[k][f]=f;
	}
	else
	{
		dp[k][f]=(f+1)%2;
	}
	return dp[k][f];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,w,k;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    w=solve(k,0);
    if(w==0)
    {
    	cout<<"First\n";
    }
    else
    {
    	cout<<"Second\n";
    }
	return 0;
}


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

int main() {
  int room = 0;
  int view = 0;
  
  int N;
  cin >> N;
  
  vector<int> H(N);
  
  for (int k = 0; k < N; k++){
    cin >> H.at(k);
  }
  for (int i = 0; i < N; i++){
    for(int j = 0; j <= i; j++){
      if( H.at(i) >= H.at(j) ){
        view = 1;
      }
      else{
        view = 0;
        break;
      }
    }
    room = room + view;
  }
  cout << room << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn read_n<T: FromStr>(n: u32) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

fn read_n_logic<T: FromStr>(n: u32, mut a: Vec<T>) -> Vec<T> {
  match n {
      0 => a,
      _ => {
          a.push(read::<T>());
          read_n_logic(n - 1, a)
      },
  }
}

fn main() {
  let n = read::<u32>();
  let mut d = read_n::<u32>(n);

  d.sort();
  println!("{}", d[d.len() / 2] - d[d.len() / 2 - 1]);
}


Measured memory_bytes: 13692
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int a, b, c,ans =0;cin >> a >> b >> c;
	for (;;) {
		if (b % 2 || a % 2 || c % 2) break;
		if (a == b && b == c) {
			ans = -1;
			break;
		}
		ans++;
		int p, q, r;p = a;q = b, r = c;
		a = (r + q) / 2;b = (p + q) / 2;c = (p + r) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}


void cerrall(const vector<bool>& a){rep(i,a.size()) cerr << i << " " << (a[i]? "True" : "False") << "\n"; cerr << "\n";}
template<class T> void cerrall(const vector<T>& a){for(auto& t : a) cerr << t << " "; cerr << "\n";}
template<class T> void cerrall(const set<T>& a){for(auto& t : a) cerr << t << " "; cerr << "\n";}
template<class T> void cerrall(const multiset<T>& a){for(auto& t : a) cerr << t << " "; cerr << "\n";}
template<class T, class U> void cerrall(const vector<pair<T,U>>& a){rep(i,a.size()) cerr << i << " : " << a[i].first << " " << a[i].second << "\n";}
template<class T, class U> void cerrall(const map<T,U>& a){for(auto& t : a) cerr << t.first << " " << t.second << "\n";}
template<class T, class U> void cerrall(const unordered_map<T,U>& a){for(auto& t : a) cerr << t.first << " " << t.second << "\n";}

template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}

template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    string s;cin >> s;
    rep(i,s.size()){
        if(s[i] == '?') s[i] = 'D';
    }
    cout << s << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pi  3.14159265359
#define mod 1000000007
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    ll n;
    cin>>n;
    map<ll,ll>val;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        val[a[i]]++;
    }
    ll total=0;
    for(auto it=val.begin();it!=val.end();it++)
    {
        total+=(it->second*(it->second-1));
    }
    for(int i=0;i<n;i++)
    {
        ll ans=total;
        ans=ans-(val[a[i]]*(val[a[i]]-1));
        ll cal=val[a[i]]-1;
        ans+=(cal*(cal-1));
        cout<<ans/2<<endl;
    }



}



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

int main(){ 
  int n, m, R;
  cin >> n >> m >> R;
  vector<int> r(R);
  rep(i,R) cin >> r[i], r[i]--;
  sort(r.begin(), r.end());
  vector<vector<ll>> dp(n, vector<ll>(n, INF));
  rep(i,n) dp[i][i] = 0;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dp[a][b] = c;
    dp[b][a] = c;
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }

  ll res = INF;

  do {
    ll tmp = 0; 
    for (int i = 0; i < R - 1; i++) tmp += dp[r[i]][r[i + 1]];
    res = min(res, tmp);
  } while (next_permutation(r.begin(), r.end()));

  cout << res << endl;
  return 0; 
} 


Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string str;
int B[MAX_N];
int dp[(1 << 26)];

void solve() {
	cin >> str;
	N = sz(str);
	rep(i, 0, N) {
		int s = str[i] - 'a';
		B[i + 1] = (1 << s) ^ B[i]; 
	}
	rep(i, 0, (1 << 26)) dp[i] = inf;
	dp[0] = 0;
	rep(i, 0, N) {
		// dp[B[i + 1]]++;
		rep(j, 0, 26) {
			int to = B[i + 1] ^ (1 << j);
			MIN(dp[B[i + 1]], dp[to] + 1);
		}
	}
	cout << max(dp[B[N]], 1) << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 263504
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

struct UnionFind {
    vector<int> u;
    explicit UnionFind(int n): u(n+5, -1) {}
    int  size(int x)        { return (-u[root(x)]); }
    int  root(int x)        { return (u[x] < 0)? x : u[x] = root(u[x]); }
    bool same(int x,int y) { return root(x) == root(y); }
    bool unite(int x,int y){return (x=root(x))==(y=root(y))?false:(u[x]+=u[y],u[y]=x,true) ;}
};

int n, x, y, p[100100], m;
int t[100100];
signed main() {

    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 1; i <= n; i++) {
        cin >> p[i];
        t[p[i]] = i;
    }

    for(int i = 0; i < m; i++) {
        cin >> x >> y;
        uf.unite(x, y);
    }

    int ans = 0;

    for(int i = 1; i <= n; i++) {
        ans += uf.same(i, t[i]);
    }

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



Measured memory_bytes: 1408
#!python3.8
# -*- coding: utf-8 -*-
# abc163/abc163_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = i2nn()
    B = [0] * N
    for a in A:
        B[a - 1] += 1
    for b in B:
        print(b)
    return

main()


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

template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
struct Unionfind {
    vector<int> par;
    vector<int> sizes;

    Unionfind(int n) : par(n), sizes(n, 1) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return sizes[root(x)];
    }

};

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

    int n, m, k;
    cin >> n >> m >> k;

    Unionfind tree(n);

    vector<vector<int>> bk(n);
    vector<int> fd(n);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        ++fd[a];
        ++fd[b];
        tree.unite(a, b);
    }

    rep(i, k) {
        int c, d;
        cin >> c >> d;
        --c, --d;
        bk[c].emplace_back(d);
        bk[d].emplace_back(c);
    }

    rep(i, n) {
        int ans = tree.size(i) - 1 - fd[i];
        for(int x : bk[i]) {
            if(tree.same(i, x)) --ans;
        }
        printf("%d%c", ans, i == n-1 ? '\n' : ' ');
    }
    return 0;
}


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

int main(void)
{
	int h, m, s;
	while (cin >> h >> m >> s){
		if (h == -1) break;
		int rest = 120 * 60;
		rest -= (h * 60 * 60);
		rest -= (m * 60);
		rest -= s;
		
		printf("%02d:%02d:%02d\n", rest / 3600, (rest / 60) % 60, rest % 60);
		rest *= 3;
		printf("%02d:%02d:%02d\n", rest / 3600, (rest / 60) % 60, rest % 60);
	}
	
	return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;

  ll L0 = 2;
  ll L1 = 1;
  if (N == 1) {
    cout << L1 << endl;
    return 0;
  }

  ll L;
  REPI(i, 2, N + 1) {
    L = L0 + L1;
    L0 = L1;
    L1 = L;
  }

  cout << L << endl;

  return 0;
}


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

//nまでの素数を求める。n<=10は無視
vector<int> getPrimes(int n) {
    vector<int> ret;
    ret.push_back(2);
    ret.push_back(3);
    ret.push_back(5);
    ret.push_back(7);
    for (int i = 11; i <= n; i += 2) {
        bool isPrime = true;
        for (int d : ret) {
            if (i % d == 0) {
                isPrime = false;
                break;
            }
        }
        if (isPrime) {
            ret.push_back(i);
        }
    }
    return ret;
}

//nを素因数分解したときの各乗数配列を求める
// ret[i] の数値が、 primse[i] ^ xx の xxに相当する
//ex: ret[0] が 2の乗数。1が3の乗数...
vector<int> getFactorsCount(const vector<int> &primes, int n) {
    vector<int> ret(primes.size(), 0);
    //1は無視。約数算出も不要
    int idx = 0;
    while (true) {
        int d = primes[idx];
        if (d > n) {
            break;
        }
        if (n % d == 0) {
            ret[idx]++;
            n /= d;
        } else {
            idx++;
        }
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    //1000まで素因数分解する
    //X= 2^x1 * 3^x2 * 5 ^x3 ... とすると
    //素数の数 = (x1+1) * (x2+1) * (x3+1) ...
    //X * Y = ((2^x1) * (3^x2) ...) * ((2^y1) * (3^y2) ...)
    // = (2^(x1+y1) * 3^(x2+y2) ...)
    //約数の数 = (x1+y1+1) + (x2+y2+2) ...
    //なのでまずは素因数分解し、各素数の乗数を求める
    const vector<int> primes = getPrimes(N);
    //各要素を素因数分解し、要素ごとに加算
    const int len = primes.size();
    vector<int> factorCounts = vector<int>(len, 0);
    loop(i, 2, N + 1) {
        vector<int> factors = getFactorsCount(primes, i);
        rep(j, len) {
            factorCounts[j] += factors[j];
        }
    }
    //最後に乗算する
    ll ans = 1;
    const ll MOD_NUM = 1e9+7;
    for (int f : factorCounts) {
        if (f > 0) {
            ans = (ans * (f + 1)) % MOD_NUM;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, K;
    cin >> N >> K;

    ll ans = K;
    rep(i, N - 1){
        ans *= K - 1;
    }

    cout << ans << endl;

    return 0;
}

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

template<typename T> T LCM(T a, T b) {
    if (a > b) swap(a, b);
    T r = a%b, c = a, d = b;
    while (r != 0) {a = b; b = r; r = a%b; }
    return c/b*d;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& e : a) cin >> e;
    
    auto f = [](int a, int b) { return LCM(a, b); };
    int ans = accumulate(a.begin(), a.end(), 1, f);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3100
n, x = map(int, input().split())
arr = list(map(int, input().split()))
sum_arr = sum(arr)

for i in range(n - 1):
    if arr[i] + arr[i + 1] > x:
        arr[i + 1] -= min(arr[i] + arr[i + 1] - x, arr[i + 1])
    if arr[i] + arr[i + 1] > x:
        arr[i] -= arr[i] - x

print(sum_arr - sum(arr))

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

int main() {
	int i,a[12];
	double d[12],g=128,n;
	for (i=0;i<12;i++) { d[i]=g; g/=2;} 
	while (cin >> n && n>0) {
	 for (i=0;i<12;i++) if (n>=d[i]) {n-=d[i]; a[i]=1;} else a[i]=0;
	 if (n==0) {
		 for (i=0;i<8;i++) cout << a[i];
		 cout << '.';
		 for (i=8;i<12;i++) cout << a[i];
	 } else cout << "NA";
	 cout << endl;
  } 
  return 0;
}

Measured memory_bytes: 1224
line=list(map(int,input().split()))
N=line[0]
K=line[1]
S=line[2]
ans=[]
for i in range(K):
  ans.append(S)

for j in range(N-K):
  if S==1:
    ans.append(S+1)
  else:
    ans.append(S-1)
for k in range(N):
  print(str(ans[k])+" ",end="")


Measured memory_bytes: 8136
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    vector<ll> a(3);
    cin >> a[0] >> a[1] >> a[2];

    sort(a.begin(), a.end(), greater<ll>());

    ll cnt(0);
    
    while (a[0]>a[1]) a[1] += 2, cnt++;
    while (a[0]>a[2]) a[2] += 2, cnt++;

    if (a[0] != a[1] || a[1] != a[2])
    {
        a[1] -=2, cnt--;
        a[2] -=2, cnt--;
    }

    if (a[0] == a[1] && a[1] == a[2])
        goto fin;

    sort(a.begin(), a.end(), greater<ll>());


    if (a[0]>a[1] && a[1] == a[2])  
        cnt++, a[1]++, a[2]++;
    else
        cnt+=3;
    //{
    //    cnt++, a[2]+=2;
    //    cnt++, a[0]++, a[1]++; 
    //    cnt++, a[1]++, a[2]++;
    //}

fin:


    //for (auto i: a)
    //    cout << ' ' << i;
    //cout << endl;

    cout << cnt << endl; 

    return 0;
}


Measured memory_bytes: 256
from fractions import gcd

a, b, c, d = map(int,input().split())
cn_l, cn_r, cn_d = 0,0,0
l_list = []
r_list = []
if a%c == 0:
    start_l = a//c
else:
    start_l = a//c+1
# print('left')
cn_l = b//c+1 - start_l
# for i in range(start_l, b//c+1):
#     l_list.append(c*i)
#     cn_l += 1
if a%d == 0:
    start_r = a//d
else:
    start_r = a//d+1
# print('right')
cn_r = b//d+1 - start_r
# for i in range(start_r, b//d+1):
#     r_list.append(d*i)
#     cn_r += 1
# print(cn_l, cn_r)
# for val in l_list:
#     if val in r_list:
#         cn_d +=1
def lcm(x, y):
    return (x * y) // gcd(x, y)
lcm = lcm(c,d)
if a%lcm == 0:
    start_d = a//lcm
else:
    start_d = a//lcm+1
cn_d = b//lcm+1 - start_d
n = b-a+1
print(n-(cn_l+cn_r-cn_d))



Measured memory_bytes: 5076
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1000000007;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
int main(){
    int a,b,k;
    cin>>a>>b;
    if(a > b) swap(a,b);
    k = (a+b)/2;
    if((a+b)%2 == 1){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << k << endl;
    return 0;
}



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

int main() {
    ll N;
    cin >> N;
    ll ans = N;
    for (int i = 1; i < 1000001; ++i) {
        if(N % i == 0){
            ans = min(ans, i + N/i - 2);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    from bisect import bisect_left
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for a in range(N-2):
        for b in range(a+1, N-1):
            ans += bisect_left(L, L[a]+L[b]) - b - 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int x, a, b;
  cin >> x >> a >> b;
  cout << (abs(x-a) > abs(x-b) ? "B" : "A") << endl;
	return 0;
}


Measured memory_bytes: 256
from copy import deepcopy
s = list(input())    
N = len(s)
count= 0
counter = []
ans = []
real = deepcopy(s)
syurui = set(s)
for j in syurui:
    while True:
        #終了条件
        if N == s.count(j):
            counter.append(count)
            count = 0
            s = deepcopy(real)
            N = len(s)
            break

        for i in range(N-1):
            if s[i]==j or s[i+1]==j:
                ans.append(j)
            else:
                ans.append(s[i])
        #値の更新
        N = len(ans)
        s = deepcopy(ans)
        count += 1

        #変数のリセット
        ans = []
print(min(counter))

Measured memory_bytes: 44520
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

typedef long long ll;
typedef pair<int,int> P;

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    int pre = 0;
    for(int i = 1; i <= sqrt(N); i++){
        if(i*i < N) pre = i*i;
        if(i*i == N) {
            pre = i*i;
            break;
        }
        if(i*i > N) break;
    }
    cout << pre << endl;
    return 0;
}


Measured memory_bytes: 256
while 1:
	a,b,c,d,e = map(int,raw_input().split())
	if a == 0: break
	na,nb,nc = map(int,raw_input().split())
	ans = a*na + b*nb + c*nc
	if nc >= d:
		ans = a*na + b*nb +e*nc
	else:
		nd = d; d -= nc
		t = min(nb,d)
		nb -= t; d -= t
		t = min(na,d)
		na -= t; d -= t
		ans = min(ans,a*na + b*nb + e*nd)
	print ans

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

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

  //選ばれた数がカードの中にあったら印0をつける
  vector<int> b(N);
  for (int k = 0; k < N; k++) {
    cin >> b.at(k);
    
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (b.at(k) == A.at(i).at(j)) {
          A.at(i).at(j) = 0;
        }
      }
    }
  
  }
  
  //ビンゴになってるかどうか
  bool bingo = false;
  
  while (true) {
  	//縦
  	for (int i = 0; i < 3; i++) {
    	if ((A.at(i).at(0) + A.at(i).at(1) + A.at(i).at(2)) == 0) {
      		bingo = true;
      		break;
    	}
    }
  	for (int j = 0; j < 3; j++) {
     	if ((A.at(0).at(j) + A.at(1).at(j) + A.at(2).at(j)) == 0) {
       		bingo = true;
       		break;
     	}
    }
  	if (A.at(0).at(0) + A.at(1).at(1) + A.at(2).at(2) == 0 || A.at(0).at(2) + A.at(1).at(1) + A.at(2).at(0) == 0) {
    	bingo = true;
      	break;
  	}
    break;
  }
  if (bingo) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

int main() {
    int cups[] = {1, 0, 0};
    char a, b;
    while (scanf("%c,%c ", &a, &b) != EOF) {
        std::swap(cups[a - 'A'], cups[b - 'A']);
    }
    for (int i = 0; i < 3; i++) {
        if (cups[i]) printf("%c\n", i + 'A');
    }
    return 0;
}

Measured memory_bytes: 1144
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int a,b,c[100];
	cin>>a>>b;
	c[0]=a*b;
	c[1]=a+b;
	c[2]=a-b;
	sort(c,c+3);
	cout<<c[2];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+9, INF = 0x3f3f3f3f;

bool check( int n ) {
    if( n == 2 || n == 3 ) return true;
    if( ( n + 1 ) % 6 != 0 && ( n - 1 ) % 6 != 0 ) return false;
    for( int i = 5; i * i <= n; i += 6 ) {
        if( n % i == 0 || n % ( i + 2 ) == 0 ) return false;
    }
    return true;
}

int main( void ) {
    ios::sync_with_stdio( false );
    int n, v, ans = 0;
    cin >> n;
    for( int i = 0; i < n; ++i ) {
        cin >> v;
        if( check( v ) ) ++ans;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

void bug();

/* BIEN CUC BO BEGIN*/
	int n, m, k, A[22], B[22];
	
	int ans = 0, su;
/* BIEN CUC BO END*/


void solve(){	
	cin >> n >> m >> k;
	for (int i=1; i<=m; ++i) cin >> B[i];
	for (int i=1; i<=n; ++i){
		su = k;
		for (int j=1; j<=m; ++j){
			cin >> A[j];
			su += A[j]*B[j];
		}
		if (su > 0) ++ans;
	}
	cout << ans;
}

int main(){ FIO;
	solve();
return 0;}	

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<LL> a(n);
  LL total=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    total+=a[i];
  }
  LL ans=2000000000000000;
  LL ruiseki=0;
  for(int i=0;i<n-1;i++){
    ruiseki+=a[i];
    ans=min(ans,max(total-2*ruiseki,2*ruiseki-total));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
    int i, n;
    int v[10000];
    int min, max;
    long long sum = 0;

    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%d", &v[i]);
    }
    min = max = v[0];
    for (i = 0; i < n; i++)
    {
        if (min > v[i])
        {
            min = v[i];
        }
        else if (max < v[i])
        {
            max = v[i];
        }
        sum += v[i];
    }

    printf("%d %d %lld\n", min, max, sum);

    return 0;
}



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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint d, n;
    cin >> d >> n;

    llint cnt = 0, div;
    if(d==0) { 
        for(llint i=1;i<=10000005;i++) {
            if(i%100!=0) cnt++;
            if(cnt==n) {
                cout << i << endl;
                break;
            }
        }
    }
    else {
        if(d==1) div = 100;
        else div = 10000;
        for(llint i=1;i<=10000005;i++) {
            if(i%div==0&&(i/div)%100!=0) cnt++;
            if(cnt==n) {
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 101
#define W 100001
typedef long long int lli;
lli dp[N][W];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n, w;
	cin>>n>>w;
	vector<int> wei(n); 
	vector<lli> val(n);
	for(int i=0; i<n; i++) cin>>wei[i]>>val[i];
	for(int i=1; i<=n; i++){
		for(int j=0; j<=w; j++) dp[i][j] = dp[i-1][j];
		for(int j=0; j<=w; j++)
			if(j+wei[i-1] <= w)
				dp[i][j+wei[i-1]] = max(dp[i][j+wei[i-1]], dp[i-1][j]+val[i-1]);

	}
	// for(int i=1; i<=n; i++){
	// 	for(int j=0; j<=w; j++) cout<<dp[i][j]<<' ';
	// 	cout<<endl;
	// }
	lli mx = -1;
	for(int j=0; j<=w; j++)
		mx = max(mx, dp[n][j]);
	cout<<mx;
	return 0;
}

Measured memory_bytes: 78336
import sys,bisect as bs,collections as cl,heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
k = onem()

a = l()

ma = 3
mi = 2

if a[-1] != 2:
    print(-1)
    exit()

for i in range(1,k):
    if ma >= (-(-mi//a[-(i+1)])) * a[-(i+1)]:
        ma = ma//a[-(i+1)] * a[-(i+1)]  + a[-(i+1)] - 1
        mi = (-(-mi//a[-(i+1)])) * a[-(i+1)]
    else:
        print(-1)
        exit()
print(mi,ma)

Measured memory_bytes: 63984
#include <bits/stdc++.h>
#define endl '\n'
#define forn(i, n) for(int i=0;i<n;i++)
#define lli long long int
#define pii pair<int,int>
#define fi first
#define se second
#define psi pair<int,pii>
#define pb push_back
#define vi vector<int>
#define vii vector< vi >

using namespace std;

const int MAXN = 1000001;

int n,m;
int tam[MAXN];
int num[MAXN];
int parent[MAXN];

int Find(int u) {
	return u == parent[u] ? u : parent[u] = Find(parent[u]);
}

void Union(int u,int v) {
	int Ru = Find(u), Rv = Find(v);
	if(Ru == Rv) return;
	parent[Ru] = Rv;
	tam[Rv] += tam[Ru];
}

void Crear(int i,int a,int b) {
	while(a < b) {
		Union(i * m + a, i * m + b);
		a++, b--;
	}
}

void Crear2(int j,int a,int b) {
	while(a < b) {
		Union(a * m + j, b * m + j);
		a++, b--;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	char c;
	cin>>n>>m;
	forn(i, n * m) {
		cin>>c;
		num[c]++;
	}

	forn(i, n)
	forn(j, m) {
		tam[i * m + j] = 1;
		parent[i * m + j] = i * m + j;
	}

	forn(i, n)
		Crear(i, 0, m - 1);

	forn(i, m)
		Crear2(i, 0, n - 1);

	set<int> s;
	vector<int> aux;
	forn(i, n)
	forn(j, m)
		if(s.find(Find(i * m + j)) == s.end()) {
			s.insert(Find(i * m + j));
			aux.pb(tam[Find(i * m + j)]);
		}
	sort(aux.begin(), aux.end());
	priority_queue<int> q;
	forn(i, MAXN)
		if(num[i]) {
			q.push(num[i]);
		}

	int i;
	for(i=aux.size()-1;i>=0 && !q.empty();) {
		int num = q.top();
		q.pop();
		if(num < aux[i]) break;
		if(num - aux[i] > 0) q.push(num - aux[i]);
		i--;
	}

	if(i < 0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(), a.end()

const int maxn = 200010;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
int n, m;
ll a[maxn];
string s, ss;

void solve()
{
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    ll prefix[maxn];
    fill(prefix, prefix+n+2, 1LL*0);
    for(int i = 1; i <= n; i++)
        prefix[i] = prefix[i-1]+(ll)a[i-1];
    ll ans=0;
    for(int i = 0; i < n-1; i++)
    {
        ll aa = (ll)prefix[n]-(ll)prefix[i+1];
        aa%=MOD, aa*=a[i], aa%=MOD;
        ans%=MOD, ans+=aa, ans%=MOD;
        //cout << aa << " " << a[i] << " " << ans << "\n";
    }
    cout << ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t=1;
    //cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 6772
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long v = sc.nextLong();
    long b = sc.nextLong();
    long w = sc.nextLong();
    long t = sc.nextLong();
    String ans = "NO";
    if((t * (v - w)) >= (long)Math.abs(a - b)) ans = "YES";
    System.out.println(ans);
  }
}

Measured memory_bytes: 35612