akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ABC067B
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int N = int.Parse(target[0]);
            int K = int.Parse(target[1]);
            int[] L = new int[N];
            target = Console.ReadLine().Split(' ');
            for(int i=0; i<N;i++){
                L[i] = int.Parse(target[i]);
            }
            Array.Sort(L); Array.Reverse(L);
            int len = 0;
            for(int i=0; i<K;i++){
                len += L[i];
            }
                Console.WriteLine(len);
        }
    }
}


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

#define maks 1234567890

int main(){
	int n, k;
	cin >> n >> k;
	int h[n+1], dp[n+1];
	for(int i = 0 ; i < n ; i++)
		cin >> h[i];

	dp[0] = 0;
	for(int i = 1 ; i < n ; i++){
		dp[i] = maks;
		for(int j = 1 ; j <= k ; j++)
			if(i - j >= 0)
				dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
	}

	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
use proconio::{fastout, input};

#[fastout]
#[allow(non_snake_case)]
#[allow(unused)]
fn main() {
    input! {
        X: i64,
        K: i64,
        D: i64,
    }

    let n = std::cmp::min(X.abs() / D, K);
    let x = X.abs() - n * D;
    let ans = if (K - n) % 2 == 0 { x } else { (x - D).abs() };

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


Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.int", "r", stdin);
	string str = "";
	int x = 600;
	
	while ( getline (cin, str )){
		int d;
		stringstream ss(str);
		ss >> d;
		int i;
		int sum = 0;
		for (i = d; i < x; i += d){
			sum += i*i*d;
		} // end for
		cout << sum << endl;
	} // end for

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main
{
	static int bubbleSort(int A[], int n)
	{
		boolean flag = true;
		int ret = 0;
		while(flag)
		{
			flag = false;
			for (int j = n - 1; j > 0; j--)
			{
				if(A[j] < A[j - 1])
				{
					int temp = A[j];
					A[j] = A[j - 1];
					A[j - 1] = temp;
					flag = true;
					++ret;
				}
			}
		}
		return ret;
	}
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int A[] = new int[n];
		for (int i = 0; i < n; i++)
		{
			A[i] = sc.nextInt();
		}
		int ans = bubbleSort(A, n);
		for (int i = 0; i < n; i++)
		{
			System.out.print(A[i]);
			if(i < n -1)
			{
				System.out.print(" ");
			}
		}
		System.out.println("\n" + ans);
		sc.close();
	}
}


Measured memory_bytes: 26260
N,X = list(map(int,input().split()))
L = list(map(int,input().split()))

d = 10**9
for i in range(N):
    newd = abs(X-L[i])
    if newd<d:
        d = newd
        ind = i

near = L[ind]
Y = []
for i in range(N):
    if i!=ind:
        Y.append(abs(near-L[i]))
Y.append(d)

import fractions
ans = Y[0]
for i in range(1, N):
    ans = fractions.gcd(ans, Y[i])
print(ans)

Measured memory_bytes: 84116
import math
a, b ,h, m = map(int,input().split())
ra = (h * (360/12)) + m * 1/2
rb = m * (360/60)
ang = abs(rb - ra)
min(ang, (360-ang))

cos = math.cos(math.radians(ang))
c = (a**2) +(b**2) -(2 *a *b*cos)
print(math.sqrt(c))

Measured memory_bytes: 9448
require 'set'
loop {
    n = gets.to_i
    break if n == 0
    a = []
    n.times do |i|
        l = gets.split.map(&:to_i)[1, 1000]
        a << Set.new(l)
    end
    l = Set.new(gets.split.map(&:to_i)[1, 1000])

    ans = (0...n).select{|i| l.subset?(a[i])}
    if ans.size == 1
        puts ans[0] + 1
    else
        puts -1
    end
}


Measured memory_bytes: 7880
#![allow(unused_imports, dead_code, unused_variables, unused_mut)]
use std::cmp::{max, min};
use std::mem::swap;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use permutohedron::LexicalPermutation;
use text_io::{read, scan};
use proconio::{input, marker::*, fastout};
use num::{abs};
use num::integer::{gcd};
const INF: i32 = std::i32::MAX;
const MOD: i32 = 1e9 as i32 + 7;
static dx: [i32; 4] = [1, 0, -1, 0];
static dy: [i32; 4] = [0, -1, 0, 1];

#[fastout]
fn main() {
    input! {
        k: i32,
    }
    for i in 0..k {
        print!("ACL");
    }
    println!();
}

Measured memory_bytes: 2120
#include <iostream>

using namespace std;
int main(){
    char abcd;
    int ABCD[4];
    for(int i=0; i<4; i++){
    	cin>>abcd;
    	ABCD[i]=(int)(abcd-'0');
    }
    int A=ABCD[0];
    int B=ABCD[1];
    int C=ABCD[2];
    int D=ABCD[3];

    int iop[3]={-1,-1,-1};
    char ope[2]={'+', '-'};
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                int ans;
                if(i==0)ans=A+B;
                if(i==1)ans=A-B;
                if(j==0)ans+=C;
                if(j==1)ans-=C;
                if(k==0)ans+=D;
                if(k==1)ans-=D;
                
                if(ans==7){
                    iop[0]=i;
                    iop[1]=j;
                    iop[2]=k;
                    break;
                }
            }
            if(iop[1]!=-1)break;
        }
        if(iop[0]!=-1)break;
    }
    cout<<A<<ope[iop[0]]<<B<<ope[iop[1]]<<C<<ope[iop[2]]<<D<<"=7\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int l;
    sf(l);
    long double a = l * 1.0 / 3;
    long double b = a;
    long double c = l * 1.0 - a - b;
    pr(a);pr(b);prln(c);
    long double ans = a * b * c;
    prln(ans);
    // printf("%.10lf\n", ans);
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int[] arr = new int[3];
		int ans = 0;
		arr[0] = input.nextInt();
		arr[1] = input.nextInt();
		arr[2] = input.nextInt();
		Arrays.sort(arr);
		int D1 = arr[2]-arr[0];
		int D2 = arr[2]-arr[1];
		if (D1%2!=D2%2) {
			ans++; //Increment largest by 1 and number with odd difference by 1
			if (D1%2==1) D1++;
			else D2++;
		}else if (D1%2==1&&D2%2==1) {
			ans++;
			D1--;
			D2--;
		} 
		ans+=D1/2;
		ans+=D2/2;
		System.out.println(ans);
	}	
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
using namespace std;

typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;

int solve() {
    int H, W; 
    int Cr, Cc;
    int Dr, Dc;
    cin >> H >> W;
    cin >> Cr >> Cc; Cr--; Cc--;
    cin >> Dr >> Dc; Dr--; Dc--;
    vector<string> S(H);
    for (int r = 0; r < H; r++) {
        cin >> S[r];
    }

    if (S[Cr][Cc] == '#' || S[Dr][Dc] == '#') {
        return -1;
    }

    auto deltas = vector<tuple<int, int, int>>();
    deltas.push_back(tuple(0, +1, 0));
    deltas.push_back(tuple(0, -1, 0));
    deltas.push_back(tuple(+1, 0, 0));
    deltas.push_back(tuple(-1, 0, 0));
    for (int dr = -2; dr <= 2; dr++) {
        for (int dc = -2; dc <= 2; dc++) {
            if (dr == 0 and dc == 0) continue;
            deltas.push_back(tuple(dr, dc, 1));
        }
    }

    auto dis = vector<int>(H * W, inf);
    auto que = priority_queue<pii, vector<pii>, greater<pii>>();

    dis[Cr * W + Cc] = 0;
    que.push(pii(0, Cr * W + Cc));

    while (!que.empty()) {
        auto [d, u] = que.top();
        que.pop();

        if (dis[u] < d) continue;

        for (auto&& [dr, dc, w] : deltas) {
            auto nr = u / W + dr;
            auto nc = u % W + dc;
            if (nr < 0 || nr >= H) continue;
            if (nc < 0 || nc >= W) continue;
            if (S[nr][nc] == '#') continue;
            if (dis[nr * W + nc] > dis[u] + w) {
                dis[nr * W + nc] = dis[u] + w;
                que.push(pii(dis[nr * W + nc], nr * W + nc));
            }
        }
    }

    if (dis[Dr * W + Dc] == inf) {
        return -1;
    }
    return dis[Dr * W + Dc];
}

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

    cout << solve() << endl;

    return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		




VI g[100005];

vector<bool> used(100005, true);

VI v;

void dfs(int n) {
	if (!used[n])return;
	used[n] = false;
	for (int i : g[n]) {
		dfs(i);
	}
	v.push_back(n);
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

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

	REP(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
	}

	REP(i, n) {
		dfs(i);
	}


	VI dp(n + 10, 0);

	REP(i, n) {
		for (int j : g[v[i]]) {
			dp[v[i]] = max(dp[v[i]],dp[j] + 1);
		}
	}

	int ans = 0;
	REP(i, n) {
		ans = max(ans, dp[i]);
	}

	cout << ans << endl;

}

Measured memory_bytes: 8696
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

#define REP(i,n) for(int i = 0;i < n;i++)
#define print(o) cout << o << "\n"

using namespace std;
typedef long long ll;
const int INF = INT_MAX / 4;

const int max_n = 1e3;

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

  int N;
  cin >> N;

  ll T[N], A[N];
  REP(i, N) {
    cin >> T[i];
  }
  REP(i, N) {
    cin >> A[i];
  }

  ll cand[N];
  REP(i, N) {
    ll t_diff = T[i] - T[i-1];
    ll a_diff = A[i] - A[i+1];
    if(i == 0) t_diff = T[i];
    if(i == N-1) a_diff = A[i];
    if(t_diff < 0 || a_diff < 0) {
      cand[i] = 0;
      break;
    }
    else if(t_diff == 0 && a_diff == 0) {
      cand[i] = min(T[i], A[i]);
    }
    else if(t_diff == 0 && a_diff != 0) {
      cand[i] = 1;		// A[i]
      if(T[i] < A[i]) {
	cand[i] = 0;
	break;
      }
    }
    else if(t_diff != 0 && a_diff == 0) {
      cand[i] = 1;		// T[i]
      if(T[i] > A[i]) {
	cand[i] = 0;
	break;
      }
    }
    else {
      cand[i] = 1;
      if(T[i] != A[i]) {
	cand[i] = 0;
	break;
      }

    }
  }

  ll ans = 1;
  REP(i, N) {
    ans *= cand[i];
    ans %= (ll)(1e9 + 7);
  }

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


Measured memory_bytes: 2560
#include <iostream>
#define mod 1000000007
#define maxn 2003
using namespace std;
int fac[maxn * maxn], inv[maxn * maxn], f[maxn][maxn];
int fpw(int x, int y){
    int ans = 1;
    for (int i = 1; i <= y; i <<= 1, x = 1LL * x * x % mod)
        if (y & i)
            ans = 1LL * ans * x % mod;
    return ans;
}
int C(int n, int m){
    return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main(){
    int n, k;
    cin >> n >> k;
    if (k == 1){
        cout << 1 << endl;
        return 0;
    }
    fac[0] = 1;
    for (int i = 1; i <= n * k; ++ i)
        fac[i] = 1LL * fac[i - 1] * i % mod;
    inv[n * k] = fpw(fac[n * k], mod - 2);
    for (int i = n * k - 1; i >= 0; -- i)
        inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
    f[0][0] = 1;
    for (int i = 1; i <= n; ++ i)
        for (int j = 0; j <= i; ++ j){
            f[i][j] = f[i - 1][j];
            if (j)
                f[i][j] = (f[i][j] + 1LL * f[i][j - 1] * C(n * k - (j - 1) * (k - 1) - i - 1, k - 2) % mod * (n - j + 1)) % mod;
        }
    cout << f[n][n] << endl;
    return 0;
}


Measured memory_bytes: 46336
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;

ll C[55][55];
ll v[55];
ll MAX,MIN;
int CMIN,ALLMIN;

void init(int n) {
  C[0][0] = 1;
  for(int i = 1; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
  }

  for(int i = 2; i <= n; i++) {
    for(int j = 1; j < i; j++) {
      C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
  }
  return;
}
  
int main() {
  int n,a,b;
  cin >> n >> a >> b;
  init(n);
  for(int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v,v+n,greater<ll>() );
  MAX = v[0];
  MIN = v[a-1];
  ll sum = 0;
  for(int i = 0; i < a; i++) {
    sum += v[i];
    if(v[i] == MIN) CMIN++;
  }
  for(int i = 0; i < n; i++) {
    if(v[i] == MIN) ALLMIN++;
  }
  
  cout << fixed << setprecision(6) << sum / (double)a << endl;

  if(MIN != MAX) {
    cout << C[ALLMIN][CMIN] << endl;
  }
  else {
    ll ans = 0;
    int tmp = min(ALLMIN,b);
    for(int i = a; i <= tmp; i++) {
      ans += C[ALLMIN][i];
    }
    cout << ans << endl;
  }
}
      
    



Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
ans = b - a + 1
x = c * d
e = c
f = d
if e < f:
    e = f
    f = c
r = e % f
while r != 0:
    e = f
    f = r
    r = e % f
x //= f
ans -= b // c - (a-1) // c + b // d - (a-1) // d
ans += b // x - (a-1) // x
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void) {
  int s;
  int f, b;
  int flag_y = 0;
  int flag_m = 0;
  scanf("%d", &s);
  f = s / 100;
  b = s % 100;
  if ( f >= 1 && f <= 12 ) {
    flag_y = 1;
  }
  if ( b >= 1 && b <= 12 ) {
    flag_m = 1;
  }
  if ( flag_y && flag_m ) {
    printf("AMBIGUOUS\n");
  } else if ( flag_m ) {
    printf("YYMM\n");
  } else if ( flag_y ) {
    printf("MMYY\n");
  } else {
    printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int fir[2010],dis[4010],nxt[4010],id;
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int lp[4010],rp[4010],lps[4010],rps[4010],del[4010],M,pa[4010],pb[4010],dir[4010];
struct pr{int fi,se,th;};
std::vector<pr>v[2010];
int n,m,FA[2010],ans;
int hd(int x){return FA[x]==x?x:FA[x]=hd(FA[x]);}
std::bitset<2001>dfs(int x,int fa=-1){
	std::bitset<2001>ret;
	for(int i=1;i<=m;++i)if(pa[i]==x||pb[i]==x)ret[i]=1;
	for(int i=fir[x];i;i=nxt[i])if(dis[i]!=fa)ret^=dfs(dis[i],x),FA[dis[i]]=x;
	if(x==1)return ret;
	for(int i=1;i<=M;++i)if(hd(pa[i])==hd(pb[i]))del[i]=1;
	ans+=std::min(2,(int)ret.count());
	std::vector<pr>_;
	for(pr i:v[x])if(!del[i.fi])_.push_back(i);
	v[x]=_;
	if(v[x].size()>=2){
		pr a=v[x][0],b=v[x][1];
		v[x].erase(v[x].begin(),v[x].begin()+2);
		a.se=hd(a.se),b.se=hd(b.se);
		++M;pa[M]=a.se,pb[M]=b.se;
		lp[M]=a.fi,rp[M]=b.fi;
		lps[M]=!a.th,rps[M]=b.th;
		del[a.fi]=del[b.fi]=1;
		v[a.se].push_back({M,b.se,1});
		v[b.se].push_back({M,a.se,0});
	}
	if(~fa)for(pr i:v[x])v[fa].push_back(i);
	return ret;
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	n=gi(),m=gi();int a,b;M=m;
	for(int i=1;i<=n;++i)FA[i]=i;
	for(int i=1;i<n;++i)a=gi(),b=gi(),link(a,b),link(b,a);
	for(int i=1;i<=m;++i)pa[i]=gi(),pb[i]=gi(),v[pa[i]].push_back({i,pb[i],1}),v[pb[i]].push_back({i,pa[i],0});
	dfs(1);
	for(int i=M;i;--i){
		if(!dir[i])dir[i]=1;
		dir[lp[i]]=lps[i]?dir[i]:3-dir[i];
		dir[rp[i]]=rps[i]?dir[i]:3-dir[i];
	}
	printf("%d\n",ans);
	for(int i=1;i<=m;++i)
		if(dir[i]==1)printf("%d %d\n",pa[i],pb[i]);
		else assert(dir[i]==2),printf("%d %d\n",pb[i],pa[i]);
	return 0;
}


Measured memory_bytes: 5632
n,m = map(int,input().split())

klist = []
slist = [list() for _ in range(m)]

for i in range(m):
    k,*s = map(int,input().split())
    klist.append(k)
    slist[i] = s

p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    for j in range(m):
        cnt = 0
        for l in slist[j]:
            if (i >> (l-1))&1 ==1:
                cnt += 1
        if cnt%2 != p[j]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
const int md = (int)1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int)((long long)a * b % md);
}

inline int power(int a, long long b) {
  int res = 0;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
      b--;
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if(a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= a * t; swap(a, b);
    u -= v * t; swap(u, v);
  }
  assert(b == 1);
  if(u < 0) u += md;
  return u;
}

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

  int n;
  cin >> n;
  vector<int> a(n);
  a[0] = 0;
  for (int i = 1; i < n; i++){
    a[i] = a[i - 1];
    add(a[i], inv(i + 1));
  }

  int ans = 0;
  for (int i = 0; i < n; i++){
    int m = 1;
    add(m, a[i]);
    add(m, a[n - i - 1]);

    int temp = m;
    for (int j = 0; j < n; j++){
      temp = mul(temp, j + 1);
    }
 
    int w;
    cin >> w;
    add(ans, mul(m, w));
  }

  for (int i = 0; i < n; i++){
    ans = mul(ans, i + 1);
  }
    cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define M 131
using namespace std;
typedef unsigned long long ull;

int main(){
  string t,p;
  ull a=0,b=0,c=1;
  cin>>t>>p;
  ull tlen=t.size();
  ull plen=p.size();
  for(int i=0;i<plen;i++)a=a*M+p[i];
  for(int i=0;i<plen;i++)b=b*M+t[i],c*=M;
  if(a==b)cout<<0<<endl;
  for(int i=plen;i<tlen;i++){
    b=b*M-c*t[i-plen]+t[i];
    if(a==b)printf("%d\n",i-plen+1);
  }
  return 0;
}

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

int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  unsigned long long left = 4*a*b;
  unsigned long long right = (c-a-b)*(c-a-b);
  if(left < right && c-a-b>0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import fractions
n = int(input())
#a = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(int(input()))

ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

print(ans)

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

int main() {

  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    int j[30][30] = {0};
    for(int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      j[y][x] = 1;
    }

    int m;
    cin >> m;
    int nx = 10, ny = 10, num = 0;
    for(int i = 0; i < m; i++) {
      char d;
      int s;
      cin >> d >> s;

      int y = 0, x = 0;
      if(d == 'N') y++;
      else if(d == 'S') y--;
      else if(d == 'E') x++;
      else if(d == 'W') x--;

      for(int k = 0; k < s; k++) {
        nx += x;
        ny += y;
        if(j[ny][nx] == 1) {
          num++;
          j[ny][nx] = 0;
        }
      }
    }

    if(num == n) cout << "Yes";
    else cout << "No";
    cout << endl;
  }

	return 0;
}

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

int main(){
  int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
  int ans = 1001001001;
  for(int i = 0; i <= 2*max(x, y); i++){
    int tmp = i * c;
    if(x - i/2 > 0) tmp += a * (x - i/2);
    if(y - i/2 > 0) tmp += b * (y - i/2);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}
    
      

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b, c, d;
    int flag=0;
    
    scanf("%d%d%d%d", &a, &b, &c, &d);
    
    if (abs(a-c)<=d) {
        flag++;
    } else if (abs(a-b)<=d&&abs(b-c)<=d) {
        flag++;
    }
    
    if (flag) {
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
}



Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double x;
    string u;
    long double sum = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> x >> u;
        if(u == "BTC")
        {
            x *= 380000.0;
        }
        sum += x;
    }
    cout << setprecision(30) << sum;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define f q.front()
#define SIZE (ll)(1e3)
#define mod (ll)(1e9+7)
using namespace std;
typedef long long int ll;

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

	int a[n+1],i,j;
	for(int i=1;i<=n;i++)cin>>a[i];
     int dp[n+1];
 for(i=1;i<=n;i++)dp[i]=mod;
 	dp[1]=0;
 for(i=1;i<=n;i++){
   for(j=i+1;j<i+k+1;j++){
   	if(j<=n)
   
   	dp[j]=min(dp[i]+abs(a[i]-a[j]),dp[j]);
 }}
 cout<<dp[n];
return 0;}

Measured memory_bytes: 1024
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>

#define rep(i,n) for(int i=0;i<n;i++)
#define scanInt(i) scanf("%d", &i)

using namespace std;

int main(){

	int n=9;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			cout << i << "x" << j << "=" << i*j <<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3084
N, S = map(int, input().split())
A = [int(a) for a in input().split()]
X = [0] * 3001
pre = 0
ans = 0
P = 998244353
for i, a in enumerate(A):
    for j in range(S, a, -1):
        X[j] = (X[j] + X[j-a]) % P
    X[a] += i + 1
    ans += (X[S] - pre) * (N - i)
    pre = X[S]
print(ans % P)

Measured memory_bytes: 42348
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(;;){
			int n=sc.nextInt();
			if(n==0)
				break;
			int[][] a=new int[n][n];
			int x=n/2;
			int y=n/2+1;
			for(int m=1; m<=n*n; m++){
				while(a[y][x]!=0){
					x=(x+n-1)%n;
					y=(y+1)%n;
				}
				a[y][x]=m;
				x=(x+1)%n;
				y=(y+1)%n;
			}
			for(int j=0; j<n; j++){
				for(int i=0; i<n; i++){
					print(String.format("%4d", a[j][i]));
				}
				println("");
			}
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int main() {
	string s;
	int i,count=0;
	cin >> s;
	for (i = 0;i < s.size() / 2;i++) {
		if (s[i] != s[s.size()-1 - i]) {
			s[s.size() - i] = s[i];
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define MOD                      998244353
int main()
{
    int l;
    cin>>l;
    double value=l/3.0;
    //cout<<value<<endl;
    cout<<fixed<<setprecision(12)<<pow(value,3)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAX=5005;
vector<int> conn[MAX];
int N,par[MAX],val[MAX];
pii build(int x){
    pii tmp;
    int sum=0;
    bitset<MAX> dp(0);
    dp[0]=1;
    for(int i=0;i<conn[x].size();i++){
        tmp=build(conn[x][i]);
        if(tmp.first==-1){
            return make_pair(-1,-1);
        }
        dp=(dp<<tmp.first)|(dp<<tmp.second);
        sum+=tmp.first+tmp.second;
    }
    for(int i=val[x];i>=0;i--){
        if(dp[i]) return make_pair(val[x],sum-i);
    }
    return make_pair(-1,-1);
}
int main(){
    pii tmp;
    scanf("%d",&N);
    for(int i=2;i<=N;i++) {
        scanf("%d",&par[i]);
        conn[par[i]].push_back(i);
    }
    for(int i=1;i<=N;i++) scanf("%d",&val[i]);
    tmp=build(1);
    if(tmp.first==-1) printf("IMPOSSIBLE\n");
    else printf("POSSIBLE\n");
}


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

int main() {
  int m, d;
  cin >> m >> d;
  int n = 0;
  for (int i = 22; i <= d; ++i) {
    if (i % 10 < 2)
      continue;
    if ((i / 10) * (i % 10) <= m)
      ++n;
  }
  cout << n << "\n";
  return 0;
}



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

int main() {
  int n; cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s; cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    int A, B, C; cin >> A >> B >> C;
    int M = max(A, max(B, C));
    int X;
    for (X = M;; X++) {
        if ((3 * X) % 2 == (A + B + C) % 2) {
            break;
        }
    }
    COUT((3 * X - (A + B + C)) / 2);
}

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

string s;
int main(){
	cin >> s;
	if(s.size() % 2 == 1){
		cout << "No\n";
		return 0;
	}
	for(int i = 0; i < s.size(); i++){
		if(i % 2 == 0){
			if(s[i] != 'h'){
				cout << "No\n";
				return 0;
			}
		}if(i % 2 == 1){
			if(s[i] != 'i'){
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
}


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

int main()
{
	string s;
	char result;
	int i,j;
	while (cin>>s) {
		result = 'd';
		for(i = 0; i < 3; i++) if (s[3*i]==s[3*i+1] && s[3*i]==s[3*i+2] && s[3*i]!='s') result = s[3*i];
		for(i = 0; i < 3; i++) if (s[i]==s[i+3] && s[i]==s[i+6] && s[i]!='s') result = s[i];
		if (s[0]==s[4] && s[0]==s[8] && s[0]!='s') result = s[0];
		if (s[2]==s[4] && s[2]==s[6] && s[2]!='s') result = s[2];
		cout<<result<<endl;
	}
	return 0;
}

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


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

int main(){
	int n,k;
	cin>>n>>k;
	int ans=0;
	while(0<n){
		n/=k;
		ans++;
	}
	cout<<ans<<endl;
}

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

bool check(vector<ll> &vec,ll n,ll mid){
	ll count1=0,count2=0;
	for(ll i=0;i<n;i++){
		if(vec[i]>=mid) count1++;
		else count2++;
	}
	
	return count1==count2;
}

int main()
{
	ll n;
	cin>>n;
	vector<ll> vec(n+1,0);
	map<ll,ll> map;
	for(ll i=1;i<=n;i++){
		cin>>vec[i];
		map[vec[i]]++;
	}
	
	sort(vec.begin(),vec.end());
	cout<<vec[n/2+1]-vec[n/2]<<endl;	
	
}


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

using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  auto t = vector<bool>(n, true);
  auto hs = vector<long>(n, -1);
  for (int i = 0; i < n; i++) cin >> hs[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    if (hs[a] == hs[b]) t[a] = t[b] = false;
    else if (hs[a] > hs[b]) t[b] = false;
    else t[a] = false;
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (t[i]) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 4052
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()

import itertools

def f(n, k):
    return k*(n-k) + 1

N += 1
ans = 0
for k in range(K, N+1):
    ans = (ans + f(N, k)) % mod
print(ans)


Measured memory_bytes: 63708
n = int(input())
x = list(map(int,(input().split())))
hp = 0
ans = []
for j in range(1,100+1):
#  print(j,hp)
  for i in x:
    hp_temp = ( i -j )**2 
#    print(i,j,hp_temp)
    hp +=  hp_temp
  ans.append(hp)
#  print(hp)
  hp = 0
 
print(min(ans))


Measured memory_bytes: 38640
#include<bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto it : x) {cerr << " [" <<  it << "]";} cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18 + 100;
void add_self(int& a, int b){
	a += b;
	a %= mod;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	int H, W;
	cin >> H >> W;
	vector<vector<char>> grid(H, vector<char>(W));
	for(int i = 0;i < H;++i){
		for(int j = 0;j < W;++j){
			cin >> grid[i][j];
		}
	}
	vector<vector<int>> dp(H, vector<int>(W));
	dp[0][0] = 1;
	for(int i = 0;i < H;++i){
		for(int j = 0;j < W;++j){
			if(grid[i][j] == '#'){
				continue;
			}
			if(i - 1 >= 0){
				add_self(dp[i][j], dp[i - 1][j]);
			}
			if(j - 1 >= 0){
				add_self(dp[i][j], dp[i][j - 1]);
			}
		}
	}
	cout << dp[H - 1][W - 1] << '\n';
	return 0;
}


Measured memory_bytes: 5248
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, A, B = MAP()
    print(N//(A+B)*A + min(N%(A+B), A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
import scala.io.StdIn.{readLong, readInt}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val arr = (1 to len).toArray.map(a => readLong)
        println(shellSort(arr, len).mkString("\n"))
    }
    
    def shellSort(arr: Array[Long], len: Int): Array[Long] = {
        val copy = new Array[Long](len)
        arr.copyToArray(copy)
        var cnt = 0
        val groups = genGroups(len).reverse
        println(groups.length + "\n" + groups.mkString(" "))
        for (g <- groups) {
            for (start <- (0 until g)) {
                cnt += insertionSort(copy, start, len, g)
            }
        } 
        println(cnt)
        copy
    }
    
    def insertionSort(arr: Array[Long], start: Int, len: Int, group: Int): Int = {
        var cnt = 0
        def insert(target: Long, ptr: Int): Unit = ptr match {
            case a if (a < 0 || arr(ptr) <= target) => arr(ptr + group) = target
            case a => {
                cnt += 1
                arr(ptr + group) = arr(ptr)
                insert(target, ptr - group)
            }
        }
        for (targetIndex <- Range(start, len, group)) { insert(arr(targetIndex), targetIndex - group)}
        cnt
    }
    
    def genGroups(len: Int): List[Int] =  {
        def go(len: Int, glen: Int, next: Int): List[Int] = next match {
            case a if (a == 1) || (a < len && glen < len) => a :: go(len, glen + 1, a * 3 + 1)
            case a => Nil
        }
        go(len, 0, 1)
    }
}


Measured memory_bytes: 360536
#include <iostream>
using namespace std;
int main(void){
    int N,K,P;
    cin >>N;
    for(int i=0;i<N;i++){
        cin >>K>>P;
        if(K%P==0){
            cout <<P<<endl;
        }
        else{
            cout <<K%P<<endl;
        }
    }
}


Measured memory_bytes: 3104
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest071-B
#  TODO https://atcoder.jp/contests/abc071/tasks/abc071_b

def  firstCharNotFound(givenString):
	# initialize for char
	checkList = [False for _ in range(0,26,+1)]
	stringLength = range(0,len(givenString),+1)
	for pos in stringLength:
		charIntVersion = ord(givenString[pos])
		checkList[charIntVersion-97]=True
	charRange = range(0,26,+1)
	firstPosition = -1
	for pos in charRange:
		if checkList[pos]==False:
			firstPosition = pos
			break
	if firstPosition == -1:
		return "None"
	else :
		return chr(firstPosition+97)

if __name__ == '__main__':
	S = input().strip()
	solution=firstCharNotFound(S)
	print("{}".format(solution))

Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
	char S[100];
	int i, N, x = 0, max = 0;
	scanf("%d%s", &N, &S);
	for (i = 0; i<N; i++) {
		if (S[i] == 73) {
			x += 1;
			if (x>max) {
				max = x;
			}
		}
		if(S[i]==68){
                       x-=1;
               }
	}
	printf("%d", max);
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second 

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
#define fa(i,a,n) for(long long  i=a;i<=b;i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";         

int main()
{
  
   Ezio
   ll t,m,n,x,a,b;
   string s;
   
   cin>>n;
   vector<ll>v(n);
   fr(i,n)cin>>v[i];
   sort(all(v)) ;
   m=0;
   
   for(ll i=0;i<n;i++){
     for(ll j=i+1;j<n;j++){
       for(ll k=j+1;k<n;k++){
         if(v[i]+v[j]>v[k] and v[i]!=v[j] and v[j]!=v[k])
          m++;
       }
     }
   }
   
   cout<<m<<endl;
   return 0;
}
    

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    int n = (int)s.length();
    int res = 0;
    for(int i = 0; i < n / 2; ++i){
        if(s[i] != s[n-1-i])    ++res;
    }
    cout << res << endl;
}

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

int main() {
    int n, q, C;
    std::vector<long int> S, T;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        long int a;
        std::cin >> a;
        S.push_back(a);
    }
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        long int a;
        std::cin >> a;
        T.push_back(a);
    }
    for (int j = 0; j < q; j++) {
        for (int i = 0; i < n; i++) {
            if (S[i] == T[j]) {
                C++;
                break;
            }
        }
    }

    std::cout << C << std::endl;

    return 0;
}


Measured memory_bytes: 3144
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n,m,x;
    cin >> n >> m >> x;
    vector<vector<long long>> array(n,vector<long long>(m+1));
    long long cost=100000009;
    bool flag = false;
    for(int i=0;i<n;i++){
        for(int j=0;j<m+1;j++){
            cin >> array[i][j];
        }
    }
    for(int bit=0; bit < (1<<n); bit++){
        vector<long long> S(n,0);
        for(int i=0;i<n;i++){
            if(bit & (1<<i)){
                S[i]=1;
            }
        }
        bool skflag=true;
        long long excost=0;
        //1つの買い方のパターンについて、スキル要件を調べる
        for(int i=1;i<m+1;i++){
            long long skill=0;
            for(int j=0;j<n;j++){
                skill=skill+array[j][i]*S[j];
            }
            if(skill<x){
                skflag = false;
                break;
            }
        }
        if(skflag==true){
            for(int i=0;i<n;i++){
                excost = excost + array[i][0]*S[i];
            }
            cost = min(cost,excost);
            flag = true;
        }
    }
    if(cost!=100000009){
        cout << cost << endl;
    }else{
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0LL;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define F first
#define S second
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);


void solve()
{
    string v[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    int i;
    rep(i,7)
    {
        if(v[i]==s)
        {
            cout << 7-i ;
            break;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tc=1;
   // cin >> tc;
    while(tc--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

#define run_forrest_run ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define fi first
#define se second
#define si set <int>
#define all(x) (x).begin(),(x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);} 

const int inf = 1e9;	
const int mod = inf + 7;

const int N = 205000;
vector <int> g[N];
vector <bool> visited(N);
vector <int> color(N);
double dp[305][305][305];

int main()
{
	run_forrest_run;
	int n;
	cin >> n;
	int cnt1 = 0, cnt2 = 0, cnt3 = 0;
	for (int i = 0; i < n; i++)
	{
		int temp;
		cin >> temp;
		if (temp == 1)
			cnt1++;
		else if (temp == 2)
			cnt2++;
		else cnt3++;
	}

	for (int k = 0; k < 303; k++)
	{
		for (int j = 0; j + k < 303; j++)
		{
			for (int i = 0; k + j + i < 303; i++)
			{
				if (i + j + k == 0)
					continue;
				if (i + j + k > 303)
					continue;
				double pall = 1.0 * n/(i+j+k);
				double pi = 1.0 * i/(i+j+k);
				double pj = 1.0 * j/(i+j+k);
				double pk = 1.0 * k/(i+j+k);
				if (i)
					dp[i][j][k] += dp[i-1][j][k] * pi;
				if (j)
					dp[i][j][k] += dp[i+1][j-1][k] * pj;
				if (k)
					dp[i][j][k] += dp[i][j+1][k-1] * pk;

				dp[i][j][k] += pall;
			}
		}
	}

	cout  << setprecision(11) << fixed << dp[cnt1][cnt2][cnt3];

}


Measured memory_bytes: 227584
#include <bits/stdc++.h>
using namespace std;
 
int n;
vector<vector<int> > e;
 
vector<int> dp;
 
void dfs(int i,int p)
{
  dp[i]=0;
  bool F=0;
  for(int x=0;x<e[i].size();x++){
    int j=e[i][x];
    if(j==p)continue;
    dfs(j,i);
    dp[i]+=dp[j];
    if(dp[j]==0){
      if(!F)F=1;
      else dp[i]++;
    }
  }
}
 
int main()
{
  scanf("%d",&n);
  e=vector<vector<int> >(n);
  for(int t=0;t<n-1;t++){
    int a,b;
    scanf("%d%d",&a,&b);
    e[a].push_back(b);
    e[b].push_back(a);
  }
  dp=vector<int>(n);
  int r=-1;
  for(int i=0;i<n;i++){
    if(e[i].size()>2){
      r=i;
      break;
    }
  }
  if(r==-1){
    printf("1\n");
    return 0;
  }
  dfs(r,-1);
  printf("%d\n",dp[r]);
  return 0;
}


Measured memory_bytes: 10240
def solve():
    A,B,N = map(int,input().split())
    print(max(express(A,B,N), express(A,B,max(N//B*B-1,0))))

def express(A,B,x):
    return ((A * x) // B) - (A * (x // B))

if __name__ == '__main__':
    solve()

Measured memory_bytes: 61856
//#pragma GCC oplmize(2)
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x+1)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
const double pi=acos(-1.0);
const double eps = 1e-8;
ll ans,ma;
string s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R') ans++;
        else ans=0;
        ma=max(ma,ans);
    }
    pr(ma);
    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int palind(string s)
{
  string r;
  r=s;
  reverse(s.begin(),s.end());
  if(s==r)
    	return 1;
  else
    return 0;
}
int main()
{
  string S,C,D;
  cin>>S;
  //int ans;
  //ans=palind(S);
  for(int i=0;i<( S.size()-1 )/2;i++)
  {
    C.push_back(S[i]);
  }
  for(int i=( S.size()+3)/2-1;i<S.size();i++)
  {
    D.push_back(S[i]);
  }
  if(palind(S) && palind(C) && palind(D) )
    cout<<"Yes";
  else
    cout<<"No";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,n) for (lint i = 0; i < (n); i++)
#define REP1(i,n) for (lint i = 1; i < (n); i++)

lint N ,P;

int main(void){
    lint now_min = 200001;
    lint ans = 0;
    cin >> N;
    REP (i, N) {
        cin >> P;
        if (now_min > P) {
            ans++;
            now_min = P;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
while n = gets do
  ans =0
  n = n.to_i
  for a in 0..9 do
    for b in 0..9 do
      for c in 0..9 do 
        for d in 0..9 do
          if ( a + b + c + d == n)
            ans += 1
          end
        end
      end
    end
end
puts ans
end



Measured memory_bytes: 6844
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC"<<endl;
	}else{
		cout<<"ABC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628