akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int x = scanner.nextInt();
        final List<Integer> primeNumbers = sieveOfEratosthenes(100004);
        final int index = extendedBinarySearch(primeNumbers, x);
        System.out.println(primeNumbers.get(index));
    }

    private static List<Integer> sieveOfEratosthenes(final int number) {
        List<Integer> numbers = IntStream.rangeClosed(2, number)
                .boxed()
                .collect(Collectors.toList());

        final int sqrt = (int) Math.sqrt(number);
        final List<Integer> primeNumbers = new ArrayList<>();
        int condition;

        do {
            final int prime = numbers.get(0);
            primeNumbers.add(prime);
            numbers = numbers.stream()
                    .filter(i -> i % prime != 0)
                    .collect(Collectors.toList());
            condition = prime;
        } while (condition < sqrt);

        primeNumbers.addAll(numbers);
        return primeNumbers;
    }

    private static int extendedBinarySearch(final Object indexes, final int value) {
        final int rawIndex;
        if (indexes instanceof int[]) {
            rawIndex = Arrays.binarySearch((int[]) indexes, value);
        } else {
            rawIndex = Collections.binarySearch((List<Integer>) indexes, value);
        }

        if (rawIndex >= 0) {
            return rawIndex;
        }

        return -(rawIndex + 1);
    }
}


Measured memory_bytes: 43476
#include <iostream>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;

int main(){
  int n;
  bool w[27] = {};
  char c[110];
  int ans = 0;
  cin >> n;
  rep(i,n){
    cin >> c[i];
    w[c[i]-'A'] = true;
  }
  rep(i,27){
    if(w[i]) ans++;
  }
  if(ans == 3){
    cout << "Three" << endl;
  }else if(ans == 4){
    cout << "Four" << endl;
  }
  return 0;
}


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

int main() {
  char c;
  cin >> c;
  string str = "aeiou";
  
  for (int i = 0; i < str.size(); i++) {
    if (c == str.at(i)) {
      cout << "vowel" << endl;
      break;
    }
    else if (i == str.size() - 1)
      cout << "consonant" << endl;
  }   
}

Measured memory_bytes: 256
N = int(input())
ex_x = 0
ex_y = 0
ex_t = 0
for _ in range(N):
    t, x, y = map(int, input().split(' '))
    dist = abs(x - ex_x) + abs(y - ex_y)
    dt = t - ex_t
    if dist > dt:
        print('No')
        break
    if dist % 2 != dt % 2:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3064
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
d=[]
for i in p:
    d.append((i,0))
for i in q:
    d.append((i,1))
for i in r:
    d.append((i,2))
d.sort(reverse=True)
ss=x+y
cnt=0
ans=0
xx=0
yy=0
z=0
for i ,j in d:
    if j==0:
        if x>0:
            
            ans+=i
            x-=1
            cnt+=1
    elif j==1 :
        if y>0:
            ans+=i
            cnt+=1
            y-=1
    else:
        ans+=i
        cnt+=1
    if ss==cnt:
        break
print(ans)

Measured memory_bytes: 123108
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define INF 2147483647
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
    int a, b;
    char buf[32] = "";

    while (cin >> a >> b, b) {
        map<int, int> mp;
        mp[a] = 0;
        int j;
        for (j = 1; ; j++) {
            sprintf(buf, "%0*d", b, a);
            sort(buf, buf+b);
            int c = atoi(buf);
            reverse(buf, buf+b);
            int d = atoi(buf);
            a = d - c;

            if (!mp.insert(pair<int,int>(a, j)).second) {
                break;
            }
        }

        int r = mp[a];
        printf("%d %d %d\n", r, a, j - r);
    }

    return 0;
}

Measured memory_bytes: 3236
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let mut a: Vec<u64> = read_vec();
    let b: Vec<u64> = read_vec();

    let mut cnt: u64 = 0;

    for i in 0..n {
        if a[i] >= b[i] {
            cnt += b[i];
        } else {
            cnt += a[i];
            let tmp = b[i] - a[i];
            if tmp >= a[i + 1] {
                cnt += a[i + 1];
                a[i + 1] = 0;
            } else {
                cnt += tmp;
                a[i + 1] -= tmp;
            }
        }
    }

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


Measured memory_bytes: 9972
N,M,C = gets.split.map(&:to_i)
Bs = gets.split.map(&:to_i)
As = []

ans = 0
N.times do
  a = gets.split.map(&:to_i)
  tmp = C
  M.times do |i|
    tmp += (a[i] * Bs[i])
  end

  ans += 1 if tmp > 0
end

puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = (1e5+10);
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

int a_place[MAXN];

constexpr int power(int b, int i){
  if (i == 1) return b % MOD;
  if (i % 2 == 0) {
    return power(b*b % MOD, i/2) ;
  } else {
    return power(b*b % MOD, i/2)*b % MOD ;
  }
}

constexpr int fact_seed(int n){
  if (n == 0 ) return 1;
  return (n * (fact_seed(n-1))) % MOD;
}

constexpr int invMod(int n){
  return power(n,MOD - 2);
}


template<int N>
struct Facts {
    constexpr Facts() : arr() {
        for (auto i = 0; i != N; ++i){
            arr[i] = fact_seed(i); 
        }
    }
    int arr[N];
};

constexpr auto facts = Facts<MAXN>();
int fact(int n){
  return facts.arr[n];
}

int combination(int m, int n){
  if(m<0 || n < 0 || m < n) return 0;
  return (((fact(m)*invMod(fact(n))) % MOD) * invMod(fact(m-n))) % MOD;
}

signed main(){
    int n;

    cin >> n;
    int same_smaller;
    int same_bigger;

    for(int i=1;i<=n+1;i++) a_place[i]=-1;
    for (int i = 1; i <= n+1; i++){
      int a;
      cin >> a;
      if(a_place[a]!=-1){
        same_smaller=min(a_place[a],i);
        same_bigger=max(a_place[a],i);
        break;
      }else{
        a_place[a]=i;
      }
    }

    int n1 = same_smaller - 1;
    int n2 = n - same_bigger + 1;

  for(int k=1;k<=n+1;k++){
    auto ans = combination(n+1,k) - combination(n1+n2,k-1);
    cout << (ans < 0 ? ans + MOD : ans) << endl;
  }
   return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>

int main(){
  int n, a[20], b[20], c[20], i, ans = 0, k;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%d", &a[i]);
  for(i = 0; i < n; ++i) scanf("%d", &b[i]);
  for(i = 0; i < n - 1; ++i) scanf("%d", &c[i]);
  k = a[0] - 1;
  ans = b[k];
  for(i = 1; i < n; ++i){
    if(a[i] == a[i - 1] + 1) ans += c[a[i] - 2];
    ans += b[a[i] - 1];
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int i,j,n,q,c=0;

  scanf("%d",&n);

  int S[n+1];
  for(i=0;i<n;i++) scanf("%d",&S[i]);

  scanf("%d",&q);

  int T[q];
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);

    j=0;
    S[n]=T[i];

    while(S[j]!=T[i]) j++;

    if(j!=n) c++;
  }

  printf("%d\n",c);

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


int n,c;
int ch[35][100010];
int main(){
    cin >> n >> c;
    rep(i,35){
        rep(j,100010){
            ch[i][j]=0;
        }
    }
    rep(i,n){
        int s,t,c;
        cin >> s >> t >> c;
        s--;t--;c--;
        ch[c][s]++;
        ch[c][t+1]--;
    }
    rep(i,35){
        rep(j,100005){
            ch[i][j+1]+=ch[i][j];
        }
    }
    int ans = 0;
    rep(i,100001){
        int tmp = 0;
        rep(j,35){
            if(ch[j][i])tmp++;
        }
        chmax(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
int x1,y1,x2,y2,x3,y3,x4,y4;
cin >> x1 >> y1 >> x2 >> y2;
int dx = x2 - x1;
int dy = y2 - y1;
x3 = x2 - dy;
y3 = y2 + dx;
x4 = x1 - dy;
y4 = y1 + dx;
cout << x3 << " "<< y3<<" " << x4 <<" " << y4 << endl;
 }


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

int main()
{
    int n;
    string str;
    cin >> n;
    cin >> str;
    vector<int> v(str.size());
    for(int i = 0; i < (int)str.size(); ++i)
    {
        v[i] = (str[i] - 'A') + n;
    }
    for(int num : v)
    {
        cout << (char)('A'+(num%26));
    }
    cout << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<vector<ll>> net(n);
    for(int i = 0; i < n - 1; ++i){
        ll ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        net.at(ai).push_back(bi);
        net.at(bi).push_back(ai);
    }

    ll nf = 1, ns = 1;
    vector<bool> visited(n);
    visited.at(0) = true;
    visited.at(n - 1) = true;
    vector<ll> vf, vs;
    vf.push_back(0);
    vs.push_back(n - 1);
    while(!vf.empty() || !vs.empty()){
        if(!vf.empty()){
            vector<ll> new_vf;
            for(ll cur : vf){
                for(ll nxt : net.at(cur)){
                    if(visited.at(nxt)){ continue; }
                    new_vf.push_back(nxt);
                    nf++;
                    visited.at(nxt) = true;
                }
            }
            vf.swap(new_vf);
       }

        if(!vs.empty()){
            vector<ll> new_vs;
            for(ll cur : vs){
                for(ll nxt : net.at(cur)){
                    if(visited.at(nxt)){ continue; }
                    new_vs.push_back(nxt);
                    ns++;
                    visited.at(nxt) = true;
                }
            }
            vs.swap(new_vs);
       }
    }

    if(nf > ns){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
    return 0;
}

Measured memory_bytes: 6800
from collections import deque
h,w = list(map(int,input().split()))
f = []
q = deque()
for i in range(h):
    a = list(input())
    for j in range(w):
        if a[j] == '#':
            q.append([0,i,j])
    f.append(a)

ans =0
dxy = [0,1,0,-1,0]
while(len(q)):
    c,y,x = q.popleft()
    for i in range(4):
        ny = y+dxy[i]
        nx = x+dxy[i+1]
        if nx >= w or ny >= h or nx <0 or ny <0:
            continue
        if f[ny][nx] == '.':
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])
            ans = max(ans,c+1)
        elif f[ny][nx] != '#' and f[ny][nx] > c+1:
            f[ny][nx] = c+1
            q.append([c+1,ny,nx])
            ans = max(ans,c+1)

print(ans)


Measured memory_bytes: 181388
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(); // ??´??°?????° n
		int min     = 1000000;
        	int max     = -1000000;
        	long sum   = 0;
		for(int i = 0;i < n;i++){
			int num = scan.nextInt(); // ??´??°??\???
			sum += num;
			if(min > num){min = num;}
			if(max < num){max = num;}
		}
	System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 40980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

ll A[101];

int main(){
  int N; cin>>N;
  rep(i,N) cin>>A[i+1];
  A[0]=1e18;
  ll mon=1000,kab=0;
  for(int i=1;i<=N;i++){
    if(A[i-1]>=A[i]&&A[i+1]>=A[i]){
      kab+=mon/A[i];
      mon=mon%A[i];
    }
    if(A[i-1]<=A[i]&&A[i+1]<=A[i]){
      mon+=kab*A[i];
      kab=0;
    }
  }
  cout<<mon<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, p;
  string s;
  cin >> n >> p >> s;
  if (p != 2 && p != 5) {
    vector<ll> num(p);
    ll prev = (s[n-1]-'0')%p, rem10n = 1;
    num[prev]++;
    for (int i = n-2; i >= 0; i--) {
      (rem10n *= 10) %= p;
      prev = ((s[i]-'0')%p*rem10n+prev)%p;
      num[prev]++;
    }
    ll ans = 0;
    rep(i, p)
      ans += num[i]*(num[i]-1)/2;
    ans += num[0];
    cout << ans << endl;
  } else {
    vector<vector<ll>> dp(n+1, vector<ll>(p));
    rep(i, n) {
      int a = s[i]-'0';
      rep(j, p)
        dp[i+1][(j*10+a)%p] += dp[i][j];
      dp[i+1][a%p]++;
    }
    ll ans = 0;
    rep(i, n+1)
      ans += dp[i][0];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 14484
#include <iostream>
#include<algorithm>
using namespace std;
class dice
{
public:
	int l[6];//label
	void in()
	{
		for(int i=0;i<6;i++)cin>>l[i];
	}
	void r(char a)//roll
	{
		if(a=='S')
		{
			int sto=l[0];
			l[0]=l[4];
			l[4]=l[5];
			l[5]=l[1];
			l[1]=sto;
		}
		else if(a=='N')
		{
			int sto=l[0];
			l[0]=l[1];
			l[1]=l[5];
			l[5]=l[4];
			l[4]=sto;
		}
		else if(a=='E')
		{
			int sto=l[0];
			l[0]=l[3];
			l[3]=l[5];
			l[5]=l[2];
			l[2]=sto;
		}
		else if(a=='W')
		{
			int sto=l[0];
			l[0]=l[2];
			l[2]=l[5];
			l[5]=l[3];
			l[3]=sto;
		}
		else if(a=='R')
		{
			r('N');r('E');r('S');
		}
		else if(a=='L')
		{
			r('N');r('W');r('S');
		}
		return;
	}
	void r_tf(int t,int f)
	{
		int i;for(i=0;i<6;i++)if(l[i]==t)break;
		if(i==1)r('N');
		else if(i==2)r('W');
		else if(i==3)r('E');
		else if(i==4)r('S');
		else if(i==5)r('N'),r('N');
		
		for(i=1;i<5;i++)if(l[i]==f)break;
		if(i==2)r('L');
		else if(i==3)r('R');
		else if(i==4)r('L'),r('L');
		
		return;
	}
};

int main() {
	int n;cin>>n;
	dice d[100];bool flag=true,flags=false,flagall=false;
	int i;for(i=0;i<n;i++)d[i].in();int a[6],b[6];
	for(int j=0;j<n;j++)for(int k=j+1;k<n;k++){
	for(int l=0;l<6;l++){a[l]=d[j].l[l];b[l]=d[k].l[l];}sort(a,a+6);sort(b,b+6);
	for(int l=0;l<6;l++)if(a[l]!=b[l])flag=false;if(!flag){flag=true;continue;}
	for(i=1;d[j].l[0]==d[j].l[1]&&i<5;i++)d[j].r('R');
	if(d[j].l[0]==d[j].l[1])for(flags=true,i=1;d[j].l[5]==d[j].l[1]&&i<5;i++)d[j].r('R');
	if(flags)d[j].r_tf(d[j].l[5],d[j].l[1]);flags=false;
	d[k].r_tf(d[j].l[0],d[j].l[1]);
	for(int i=2;i<6;i++)if(d[j].l[i]!=d[k].l[i])flag=false;
	if(flag)flagall=true;
	flag=true;
	}
	if(flagall)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;

int exp_log(int b, int exp)
{
    int prod = 1;
    while (exp)
    {
        if (exp % 2) prod = (1LL * prod * b) % mod;
        exp /= 2;
        b = (1LL * b * b) % mod;
    }
    return prod;
}

int combinari(int n, int k)
{
    int p1 = 1, p2 = 1, p3 = 1;
    for (int i = 1; i <= n; ++i) p1 = (1LL * p1 * i) % mod;
    for (int i = 1; i <= n - k; ++i) p2 = (1LL * p2 * i) % mod;
    for (int i = 1; i <= k; ++i) p3 = (1LL * p3 * i) % mod;
    p2 = exp_log(p2, mod - 2); p3 = exp_log(p3, mod - 2);
    return ((1LL * p1 * p2) % mod * 1LL * p3) % mod;
}

int main()
{
    int x, y, nr1 = 0, s_inversa = 0, rez = 0;
    cin >> x >> y;
    nr1 = x;
    int nr_termeni = nr1;
    s_inversa = 2 * nr1;
    while (nr1 >= 0)
    {
        if (s_inversa == y)
        {
            rez = 1LL * (1LL * rez + 1LL * combinari(nr_termeni, nr1)) % mod;
        }
        nr1 -= 2; nr_termeni--;
        s_inversa -= 3;
    }
    cout << rez;
    return 0;
}


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

using namespace std;

int lcs(const string& a, const string& b) {
    int dp[1000+1][1000+1];
    int al = a.size();
    int bl = b.size();
    memset(dp, 0, sizeof(dp[0][0])*al*bl);
    for (int i = 1; i <= al; ++i) {
        for (int j = 1; j <= bl; ++j) {
            if(a[i - 1] == b[j - 1]) {
//                cout << "=" << endl;
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
            // cout << a[i] << ":" << b[j] << endl;
            // cout << i << "," << j << "," << dp[i][j] << endl;
            // cout << endl;
        }
    }
    return dp[al][bl];
}

int main() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        string a, b;
        cin >> a >> b;
        cout << lcs(a, b) << endl;
    }
}



Measured memory_bytes: 7136
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int now = a[0], cunt = 0;
  for (int i = 0; i < n; i++) {
    cunt++;
    if (now == 2) {
      break;
    }
    if (cunt >= n) {
      cout << -1 << endl;
      return 0;
    }
    now = a[now - 1];
  }
  cout << cunt << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;
vi a;

bool f(int x){
	vb b(2*n-1,0);
	// m以下ならばflase mより大きいならばtrue
	for(int i=0;i<2*n-1;i++) if(a[i]>x) b[i]=1;
	bool flag=b[n-1]^n%2==0;
	int M=inf;
	for(int i=1;i<n;i++) if(b[i]==b[i-1]&&n-i-1<M) {
		M=n-i-1;
		flag=b[i];
	}
	for(int i=n-1;i<2*n-2;i++) if(b[i]==b[i+1]&&i-n+1<M){
		M=n-i-1;
		flag=b[i];
	}
	return flag;
}

int main(){
	cin>>n;
	a=vi(2*n-1);
	for(int i=0;i<2*n-1;i++) cin>>a[i];
	int s=0,t=2*n-1;
	while(t-s>1){
		int m=(s+t)/2;
		if(f(m)) s=m;
		else t=m;
	}
	cout<<t<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N,W;
int w[100000],v[100000];

ll dp[101][100001];
void solve(){
	reps(i,100000)
		dp[0][i] = LINF;
	rep(i,N){
		reps(j,100000){
			dp[i + 1][j] = LINF;
			dp[i + 1][j] = dp[i][j];
			if(j - v[i] >= 0){
				chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
			}
		}
	}
	int ans = 0;
	reps(i, 100000){
		if(dp[N][i]<=W){
			chmax(ans,i);
		}
	}
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>N>>W;
	rep(i,N) {
		cin>>w[i]>>v[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 79232
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  Array.init n (fun i -> 
    let rec aux c x = if x >= k then c else aux (c+1) (2*x) in
    0.5 ** float_of_int (aux 0 (i+1)))
  |> Array.fold_left (+.) 0.
  |> fun p -> Printf.printf "%.11f\n" (p /. float_of_int n)

Measured memory_bytes: 4736
#include<stdio.h>
int main(void){
	int a=0;
  	int b=0;
  	int c=0;
  	int d=0;
  	int result=0;
  	scanf("%d %d %d %d",&a,&b,&c,&d);
    if(b<c){result=0;}
  	else if(d<a){result=0;}
  	else if(a>c){
    	if(b>d){
         result=d-a; 
        }  
    	else{
        	result=b-a;
        }
    }
  	else{
        if(b>d){
         result=d-c; 
        }  
    	else{
        	result=b-c;
        }
    
    }
  
  printf("%d",result);
  
  
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  int ans=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    ans=ans^a[i];
  }
  int b[n];
  for(int i=0;i<n;i++)
  {
    cout<<(a[i]^ans)<<" ";
  }
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[1000009];
vector<int> ind;
int cnt[100001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		ind.push_back(a[i]);
	}
	sort(ind.begin(),ind.end());
	ind.erase(unique(ind.begin(),ind.end()),ind.end());
	for(int i=0;i<n;i++){
		a[i]=lower_bound(ind.begin(),ind.end(),a[i])-ind.begin();
		cnt[a[i]]++;
	}
	ll maxi1=0,maxi2=0;
	for(int i=(int)ind.size()-1;i>=0;i--){
		if(cnt[i]>=4){
			maxi1=max(maxi1,(ll)ind[i]);
			maxi2=max(maxi2,(ll)ind[i]);
		}
		if(cnt[i]>=2){
			if(maxi1==0)maxi1=(ll)ind[i];
			else{
				maxi2=max(maxi2,(ll)ind[i]);
			}
		}
	}
	printf("%lld\n",maxi1*maxi2);
	return 0;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

LL a, b, x;
LL func(LL n) {
	return n < 0ll ? 0ll : n / x + 1;
}

LL solve()
{
	return func(b) - func(a - 1);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> a >> b >> x;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = make_pair(0, i+1);
        cin >> a[i].first;
    }

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

    for (int i = 0; i < n; i++) {
        cout << a[i].second << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main() {
  char a;
  
  cin >> a;
  if(a >= 'a' && a <= 'z')
  {
    cout << 'a' << endl;
  }
  else
  {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(),c.end()
#define rep(i,a,n) for(long long i=a;i<=n;i++)
typedef long long ll;

#define NDEBUG
#ifdef  NDEBUG
#define dbg(...)
#else
#include"debug.cpp"
#endif

const int N=2e7+10;
long long T, n, m, k, x, y, z, l, r, q, ans, a[N], b[N], mod = 1e9+7;

void solve(){
	cin >> n;
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			for(int k=1;k<=100;k++){
				a[(i+j)*(i+j)+(k+j)*(k+j)+(i+k)*(i+k)]++;
			}
		}
	}
	rep(i,1,n){
		cout<<a[2*i]<<"\n";
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//cin >> T; while(T--)
	solve();
}


Measured memory_bytes: 4460
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    int H,W; cin>>H>>W;

    char MAS[H+2][W+2];
    for (int i = 0; i < H+2; ++i) { // 初期化
        for (int j = 0; j < W+2; ++j) {
            MAS[i][j]='0';
        }
    }


    for (int i = 0; i < H; ++i) {   // 入力
        for (int j = 0; j < W; ++j) {
            cin>>MAS[i+1][j+1];
        }
    }

    int xAxis[8] = {0,1,1,1,0,-1,-1,-1};//上、右上、…左上。
    int yAxis[8] = {1,1,0,-1,-1,-1,0,1};
    for (int i = 1; i < H+1; ++i) {
        for (int j = 1; j < W+1; ++j){
            if(MAS[i][j]=='#') continue;
            int cnt=0;
            for (int k = 0; k < 8; ++k) {
                if(MAS[i+xAxis[k]][j+yAxis[k]]=='#') cnt++;
            }
            MAS[i][j] = '0'+cnt;
        }
        cout<<endl;
    }

    for (int i = 1; i < H+1; ++i) {
        for (int j = 1; j < W+1; ++j) {
            cout<<MAS[i][j];
        }
        cout<<endl;
    }



}


Measured memory_bytes: 256
n= int(input())
cont=0
yes=0
for x in range(n):
    a,b= input().split()
    a, b= int(a), int(b)
    if a==b:
        cont+=1
    else:
        cont=0
    if cont>=3:
        yes=1
if yes==1:
    print("Yes")
else:
    print("No")

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> rp(n);
    vector<pair<int,int>> bp(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        rp[i]=make_pair(b,a);
    }
    rep(i,n){
        int c,d;
        cin >> c >> d;
        bp[i]=make_pair(c,d);
    }

    
    
    sort(bp.begin(),bp.end());
    sort(rp.begin(),rp.end(),greater<pair<int,int>>());

    //cout << rp[0].first << rp[1].first << rp[2].first << endl;

    int ans=0;
    int i=0;
    while(i<rp.size()){
        bool z=false;
        int j=0;
        while(j<bp.size()){
            if(rp[i].second-bp[j].first<0 && rp[i].first-bp[j].second<0){
                ans++;
                rp.erase(rp.begin()+i);
                bp.erase(bp.begin()+j);
                z=true;
                break;
            }
            j++;
        }
        if(!z) i++;
    }

    cout << ans << "\n";
    
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        BigDecimal  W = new BigDecimal(scanner.next());
        BigDecimal H = new BigDecimal(scanner.next());
        BigDecimal x = new BigDecimal(scanner.next());
        BigDecimal y = new BigDecimal(scanner.next());

        BigDecimal menseki = W.multiply(H).divide(BigDecimal.valueOf(2), 9, RoundingMode.HALF_UP);
        BigDecimal halfW = W.divide(BigDecimal.valueOf(2), 9, RoundingMode.HALF_UP);
        BigDecimal halfH = H.divide(BigDecimal.valueOf(2), 9, RoundingMode.HALF_UP);

        int divType = 0;
        if (halfW.compareTo(x) == 0
                && halfH.compareTo(y) == 0) {
            divType = 1;
        }
        System.out.printf("%f %d\n", menseki.doubleValue(), divType);
    }
}

Measured memory_bytes: 23252
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int ans;

	scanf("%d%d", &a, &b);

	ans = a - b;

	if( ans > 0 )
	{
		printf("a > b\n");
	}
	if( ans < 0 )
	{
		printf("a < b\n");
	}
	if( ans ==0 )
	{
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
use std::collections::HashSet;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let s = s.trim();
    let set: HashSet<&str> = ["a", "e", "i", "o", "u"].iter().cloned().collect();

    println!(
        "{}",
        if set.contains(s) {
            "vowel"
        } else {
            "consonant"
        }
    );
}


Measured memory_bytes: 4352
N = int(input())
A=[list(map(int, input().split())) for i in range(N)]
num = 0
zoro = 0
while num < N:
  if A[num][0] ==A[num][1]:
    num +=1
    zoro +=1 
  else:
    num +=1
    if zoro >2:
      zoro = zoro
    else:
      zoro = 0
if zoro >2 :
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9188
#include <stdio.h>
#define  MAX 100
#define INF 1000000000

void matrixChainMultiplication(int *);
int min(int,int);

int n;
int main(){
    int i;
    int A[MAX+1];
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&A[i-1],&A[i]);
    }
    matrixChainMultiplication(A);
    return 0;
}
void matrixChainMultiplication(int *A){
    int i,l,j,k;
    int m[MAX][MAX];
    for(i=1;i<=n;i++) m[i][i]=0; 

    for(l=2;l<=n;l++){
        for(i=1;i<=n-l+1;i++){
            j=i+l-1;
            m[i][j]=INF;
            for(k=i;k<=j-1;k++){
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+A[i-1]*A[k]*A[j]);
            }
        }
    }
    printf("%d\n",m[1][n]);
}
int min(int a,int b){
    if(a>b) return b;
    else return a;

}


Measured memory_bytes: 2108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],cnt[N],p[N],vis[N],las;
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		p[i]=i;
		a[i]=read();
		++cnt[a[i]];
	}
	if(n==2)return !printf("-1\n");
	for(int i=1;i<=n;++i){
		int u=p[i];
		if(vis[a[u]]){
			if(i==n-2&&a[p[i+1]]==p[i+2]&&a[p[i+2]]==p[i+1]){
				if(p[i+1]==a[las]){
					swap(p[i],p[i+2]);
					swap(p[i+1],p[i+2]);
				}
				else{
					swap(p[i],p[i+1]);
				}
			}
		}
		else if(cnt[a[u]]==n-i){
			for(int j=i+1;j<=n;++j){
				if(p[j]==a[u]){
					for(int k=j;k>i;--k){
						swap(p[k],p[k-1]);
					}
					break;
				}
			}
		}
		if(a[las]==p[i]){
			swap(p[i],p[i+1]);
		}
		printf("%d ",p[i]);
		vis[p[i]]=1;
		--cnt[a[p[i]]];
		las=p[i];
	}
	return 0;
}



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

int gcd(int a, int b)
{
	if (a < b)swap(a, b);
	int r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

vector<int> gcdList(vector<int> diff)
{
	if (diff.size() == 1)
	{
		return diff;
	}
	vector<int> newDiff;
	for (int i = 1; i < diff.size(); i++)
	{
		auto d = gcd(diff[i], diff[i - 1]);
		if (find(newDiff.begin(), newDiff.end(), d) == newDiff.end())
			newDiff.push_back(d);
	}
	return gcdList(newDiff);
}

int main()
{
	int n, x;
	vector<int> point;
	cin >> n >> x;
	for (int i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		point.push_back(p);
	}
	if (n == 1)
	{
		cout << abs(point[0] - x) << endl;
		return 0;
	}
	vector<int>diff;
	for (int i=0;i<n;i++)
	{
		diff.push_back(abs(point[i] - x));
	}
	diff = gcdList(diff);
	cout << diff[0] << endl;
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    while(cin >>n,n)
    {
        vector<string> s(n);
        vector<int> d(n);
        rep(i,n)
        {
            cin >>s[i];

            int ct=0;
            while(s[i][ct]=='.') ++ct;

            if(ct>0)
            {
                s[i][ct-1]='+';
                rep(j,ct-1) s[i][j]=' ';
            }

            d[i]=ct;
        }


        for(int i=1; i<n; ++i)
        {
            int idx=-1;
            for(int j=i+1; j<n; ++j)
            {
                if(d[j]==d[i])
                {
                    idx=j;
                    break;
                }
                if(d[j]<d[i]) break;
            }

            if(idx>0)
            {
                for(int j=i+1; j<idx; ++j) s[j][d[i]-1]='|';
            }
        }

        rep(i,n) cout << s[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
S = input()
length_substring_S = len(S)
test_str_list = ['dream', 'dreamer', 'erase', 'eraser']
flag = True

while flag == True:
  flag = False
  for i in range(len(test_str_list)):
    if S[0:length_substring_S].endswith(test_str_list[i]):
      length_substring_S -= len(test_str_list[i])
      flag = True
      break

if length_substring_S == 0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3188
H,W = map(int,input().split())
N = int(input())
a = [i for i in map(int,input().split())]

ans = [[0 for i in range(W)] for j in range(H)]
x=0
y=0
color=0
reverse=0

while y<H:
  ans[y][x] = color+1
  a[color]-=1
  if a[color]==0:
    color+=1
  if (reverse==0 and x==W-1) or (reverse==1 and x==0):
    reverse = 1-reverse
    y+=1
  else:
    if reverse==0:
      x+=1
    else:
      x-=1
    
for i in range(H):
  print(" ".join(map(str,ans[i])))

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,T,i,c,t,ans=1e4;
  cin>>n>>T;
  for(i=0;i<n;i++){
    cin>>c>>t;
    if(t<=T&&c<ans) ans=c; 
  }
  if(ans<1e4) cout<<ans<<endl;
  else cout<<"TLE"<<endl;
}

Measured memory_bytes: 3600
using System;
using System.Linq;

namespace aizu
{
    public class OnlineJudge
    {
        static void Main()
        {
            int[] input;
            while(((input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray())[0] | input[1]) != 0) {
                Console.WriteLine(input[0] % 2 == 0 || input[1] % 2 == 0 ? "yes" : "no");
            }
        }
    }
}

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

int main()
{
  int a,b,ans;
  while(cin >> a >> b)
    {
      a += b;
      for(ans = 0;a > 0;ans++)
	{
	  a = a / 10;
	}
      cout << ans << endl;
    }

  return 0;
}

  

Measured memory_bytes: 1160
import numpy as np

A = []
for i in range(3):
    A.append(list(map(int,input().split())))
N = int(input())
B = []
for i in range(N):
    B.append(int(input()))

for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0

A = np.array(A)
flag = False
for a in A:
    if a.sum() == 0:
        flag = True
for a in A.T:
    if a.sum() == 0:
        flag = True

if np.diag(A).sum()==0:
    flag = True
if np.diag(np.fliplr(A)).sum()==0:
    flag = True

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12508
import sys
input = sys.stdin.readline


def main():
    s = int(input())

    num = [s]
    ans = 1
    while True:
        if s%2==0:
            s = s//2
        else:
            s = 3*s + 1
        ans += 1
        if s in num:
            print(ans)
            return
        num.append(s)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<cstdio>
char a[105];
char b[105];

int main(){
    int n;
    scanf("%d",&n);
    scanf("%s%s",a,b);
    for(int i = 0; i < n; i++) printf("%c%c",a[i],b[i]);
    printf("\n");
    return 0;
}


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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> stlist(N);
    string ans = "";
    for (int i = 0; i < N; i++) cin >> stlist.at(i);

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

    for (int i = 0; i < N; i++) ans += stlist.at(i);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val a1 = readLine()!!.split(" ").map { it.toInt() }
    val a2 = readLine()!!.split(" ").map { it.toInt() }
    val a3 = readLine()!!.split(" ").map { it.toInt() }
    val b1 = listOf(a1[0], a2[0], a3[0])
    val b2 = listOf(a1[1], a2[1], a3[1])
    val b3 = listOf(a1[2], a2[2], a3[2])
    val c1 = listOf(a1[0], a2[1], a3[2])
    val c2 = listOf(a1[2], a2[1], a3[0])

    val n = readLine()!!.toInt()
    val nn = mutableListOf<Int>()
    var bingo = false

    repeat(n) {
        nn.add(readLine()!!.toInt())
        if (bingo) return@repeat

        if (nn.containsAll(a1)) bingo = true
        if (nn.containsAll(a2)) bingo = true
        if (nn.containsAll(a3)) bingo = true
        if (nn.containsAll(b1)) bingo = true
        if (nn.containsAll(b2)) bingo = true
        if (nn.containsAll(b3)) bingo = true
        if (nn.containsAll(c1)) bingo = true
        if (nn.containsAll(c2)) bingo = true
    }

    println(if (bingo) "Yes" else "No")
}

Measured memory_bytes: 37936
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
#define for_b(i, b) for (int i = 0; i < ll(b); ++i)
#define for_ab(i, a, b) for (int i = a; i < ll(b); ++i)
#define what_is(x) cout << #x << " = " << x << endl;
#define what_are(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl;
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) cout << #___x << " = "; for (auto& ___num : ___x) cout << ___num << ", "; cout << endl;
#define show_2d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }
#define show_3d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto& ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }


int main()
{
    int n;
    cin >> n;
    
    v<int> tb (n);
    for_b(i,n)
        cin >> tb[i];
        
    int res = 0;
    for_b(i,tb.size()-2)
    {
        for_ab(j,i+1,tb.size()-1)
        {
            for_ab(k,j+1,tb.size())
            {
                if (
                    tb[i] != tb[j] &&
                    tb[j] != tb[k] &&
                    tb[i] != tb[k] &&
                    tb[i] + tb[j] > tb[k] &&
                    tb[i] + tb[k] > tb[j] &&
                    tb[j] + tb[k] > tb[i])
                {
                    ++res;
                }
            }
        }
    }
    cout << res << endl;
        
    return 0;
}


Measured memory_bytes: 3648
import math
def sieve(n):
    p = [1] * (n + 1)
    p[0] = p[1] = 0
    
    for i in range(math.ceil((n + 1) ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p

from itertools import compress, count
def prime_factor(n):
    p = sieve(int(n ** 0.5))
    factor = []
    for pi in compress(count(0), p):
        while n % pi == 0:
            n //= pi
            factor.append(pi)

    if n != 1:
        factor.append(n)
    return factor

from collections import Counter
from sys import stdin
readline = stdin.readline

n = int(readline())
c =[Counter(prime_factor(ai)) for ai in map(int, readline().split())]
s = set()
for ci in c:
    s.update(ci.keys())

ret = 1
for i in [i ** max(ci[i] for ci in c) for i in s]:
    ret *= i
print(ret)

Measured memory_bytes: 6908
gets
c0, *cs = gets.chomp.reverse.chars
cs << nil
hs = [{}]
cs.each_with_index {|c, i|
  h = hs.last.clone
  h[c0] = i
  c0 = c
  hs << h
}
hs = hs.reverse
rec = lambda do |i, d|
  if d == 0
    hs[i].size
  else
    hs[i].map {|k, v| rec[-v-1, d-1] }.reduce(0, :+)
  end
end
puts rec[0, 2]


Measured memory_bytes: 30716
import sys
input = sys.stdin.readline
K = list(map(int, list(input())[: -1]))
D = int(input())
mod = 10 ** 9 + 7
dp = [[0] * D for _ in range(len(K) + 1)]
dplim = [[0] * D for _ in range(len(K) + 1)]
dplim[0][0] = 1
for i in range(len(K)):
  for j in range(D):
    dplim[i + 1][(j + K[i]) % D] += dplim[i][j]
    for k in range(10):
      if k < K[i]:
        dp[i + 1][(j + k) % D] += dplim[i][j]
      dp[i + 1][(j + k) % D] += dp[i][j]
      dp[i + 1][(j + k) % D] %= mod
print((dp[-1][0] + dplim[-1][0] - 1) % mod)

Measured memory_bytes: 60652
#include <iostream>
#include <vector>
#define int long long
using namespace std;

typedef pair<int,int> P;

class RUQ{
	int n,seg,init;
	vector<P> dat;
public:
	RUQ(int siz,int def) : n(siz),init(def),seg(1){
		while(seg < n) seg *= 2;
		dat.resize(seg * 2 - 1);
		for(int i = 0;i < seg * 2 - 1;i++) dat[i] = P(-1,init);
	}
	void update(int a,int b,int x,int tim,int k = 0,int l = 0,int r = -1){
		if(r == -1) r = seg;
		if(r <= a || b <= l) return;
		if(a <= l && r <= b){
			dat[k] = P(tim,x);
			return;
		}
		update(a,b,x,tim,k * 2 + 1,l,(l + r) / 2);
		update(a,b,x,tim,k * 2 + 2,(l + r) / 2,r);
	}
	P get(int i){
		i += seg - 1;
		P ret = dat[i];
		while(i){
			i = (i - 1) / 2;
			ret = max(ret,dat[i]);
		}
		return ret;
	}
};

signed main() {
	int n,q;
	cin >> n >> q;
	RUQ ruq(n,(1 << 31) - 1);
	for(int i = 0;i < q;i++){
		int t;
		cin >> t;
		if(t == 0){
			int s,t,x;
			cin >> s >> t >> x;
			ruq.update(s,t + 1,x,i);
		}else{
			int x;
			cin >> x;
			cout << ruq.get(x).second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7064
N = int(input())
A = list(map(int,input().split()))

a = list(set(A))

ans = "No"

if len(a) == 1:
    if a == [0]:
        ans = "Yes"
elif len(a) == 2:
    if N % 3 == 0 and A.count(0) == N//3:
        ans = "Yes"
elif len(a) == 3:
    if a[0] ^ a[1] ^ a[2] == 0 and N % 3 == 0 and (A.count(a[0]),A.count(a[1])) == (N//3,N//3):
        ans = "Yes"

print(ans)

Measured memory_bytes: 14212
P = []
for n in range(10000):
    p = 3
    c = 0
    if n % 2 == 0:
        c += 1
    else:
        while p < int(n**0.5) + 1:
            if n % p != 0:
                p += 2
            else:
                c += 1
                break
    if c == 0:
        P.append(n)

P.reverse()

while 1:
        j = 0
        n = int(input())
        if n == 0:
            break
        else:
            for i in range(len(P)):
                if n >= P[i]:
                    j = i
                    break
            while 1:
                if P[j]-2 == P[j+1]:
                    print(P[j+1],P[j])
                    break
                else:
                    j += 1



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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

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

  int ans = 0, cnt = 0;
  for(int i=1; i<n; ++i){
    cnt = 0;
    for(char c='a'; c<='z'; ++c){
      bool left = false, right = false;

      for(int j=0; j<i; ++j){
        if(s[j]==c) left = true;
      }

      for(int j=i; j<n; ++j){
        if(s[j]==c) right = true;
      }
      if(left && right) ++cnt;
    }
    if(ans<cnt) ans = cnt;
  }


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
c_list=[]
s_list=[]
f_list=[]
for i in range(n-1):
    c,s,f=map(int,input().split())
    c_list.append(c)
    s_list.append(s)
    f_list.append(f)
for i in range(n):
    now=0
    j=i
    while j<n-1:
        if now>=s_list[j]:
            now=f_list[j]*((now+f_list[j]-1)//f_list[j])+c_list[j]
        else:
            now=s_list[j]+c_list[j]
        j=j+1
    print(now)


Measured memory_bytes: 41580
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc169
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc169B();
            Console.Out.Flush();
        }

        public static void solve_abc169C()
        {
            
        }

        public static void solve_abc169B()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            long[] a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long mult = 1;
            long limit = 1000000000000000000;
            bool ok = true;
            bool hasZero = false;
            for (int i = 0; i < n; i++)
            {
                if (a[i] > 0)
                {
                    mult *= a[i];
                    if (mult > limit || mult <= 0)
                    {
                        ok = false;
                    }
                }
                else
                {
                    hasZero = true;
                    break;
                }
            }
            if (hasZero)
            {
                Console.WriteLine(0);
            }
            else if (!ok)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(mult);
            }
        }

        public static void solve_abc169A()
        {
            int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine(ab[0] * ab[1]);
        }

        /*
            int[] test = new int[7]  {3, 5, 7, 9, 10, 11, 13};
            int[] keys = new int[9] {1, 3, 4, 5, 8, 11, 12, 13, 14};
            for (int i = 0; i < keys.Length; i++)
            {
                Console.WriteLine(binSearch(test, keys[i]));
            }
        */
        public static int binSearch(int[] a, int x)
        {
            int l = 0;
            int r = a.Length - 1;
            while (l <= r)
            {
                int mid = (l + r) / 2;
                if (a[mid] == x)
                {
                    return mid;
                }
                else if (a[mid] > x)
                {
                    r = mid - 1;
                }
                else
                {
                    l = mid + 1;
                }
            }
            return -1;
        }

        public static int binSearchLeft(int[] a, int x)
        {
            int l = 0;
            int r = a.Length - 1;
            while (l < r)
            {
                int mid = (l + r) / 2;
                if (a[mid] < x)
                {
                    l = mid + 1;
                }
                else
                {
                    r = mid;
                }
            }
            return l;
        }
    }
}

Measured memory_bytes: 41752