akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
#include <numeric>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

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

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

	vector<vector<int>> dp(n, vector<int>(h + 1, INF));
	// 初期条件の設定
	for (int i = 0; i < n; i++) dp[i][0] = 0;
	for (int j = a[0]; j < h + a[0]; j++) {
		int nj = min(j, h);
		if (dp[0][j - a[0]] != INF) dp[0][nj] = dp[0][j - a[0]] + b[0];
	}
	
	// DPメインループ
	for (int i = 1; i < n; i++) {
		for (int j = a[i]; j < h + a[i]; j++) {
			int nj = min(j, h);
			dp[i][j - a[i]] = min(dp[i][j - a[i]], dp[i - 1][j - a[i]]);
			dp[i][nj] = min(dp[i][nj], dp[i][j - a[i]] + b[i]);
			dp[i][nj] = min(dp[i][nj], dp[i - 1][nj]);
		}
	}
	cout << dp[n - 1][h] << endl;
}

Measured memory_bytes: 39424
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, m;
        cin >> n >> m;
        int a[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            sum += a[i];
        }
        double val = 1.0 * sum / (4 * m);
        int cnt = 0;
        for(int i = 0; i < n; i++){
            if(a[i] >= val){
                cnt++;
            }
        }
        cout << (cnt >= m ? "Yes\n" : "No\n");
    }
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mk make_pair
#define mod 1000000007
using namespace std;

int gcd(int a,int b){
    if(b==0)
     return a;
    return gcd(b,a%b);
}
ll find(int n,vector<ll> &dp){
    if(n==0)
     return 1;
    if(dp[n]!=-1)
     return dp[n];
    ll count=0;
    for(int i=3;i<=n;i++){
        if((n-i)==0)
         count++;
        if((n-i)>=3){
            count=(count+find(n-i,dp))%mod;
        }
    }
    dp[n]=(count)%mod;
    return dp[n];
}
 
int main(){
   int n;
   cin>>n;
   if(n<3){
        cout<<0;
        return 0;
   }
   vector<ll> dp(n+1,-1);
   ll p=find(n,dp);
   cout<<dp[n];
}

Measured memory_bytes: 3664
#include <iostream>
#include<string>
#include<string.h>

using namespace std;

int main()
{
	int n;
	string s;
	int counter = 1;
	cin >> n >> s;
	for (int i = 1; i < n; i++)
	{
		if (s[i] != s[i - 1])
		{
			counter++;
		}
	}
	cout << counter;
	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sum_of_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> results = new List<int>();

            while (true)
            {
                string input = Console.ReadLine();
                if (input.Equals("0"))
                {
                    break;
                }

                int sum = 0;
                foreach (char item in input)
                {                    
                    sum += int.Parse(item.ToString());
                }

                results.Add(sum);
            }

            foreach (int item in results)
            {
                Console.WriteLine(item);
            }
        }
    }
}



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

int main(){

int n,i,j=0;
cin>>n;
vector<int> d;
vector<int> :: iterator it;
int c[n];

for(i=0;i<n;i++)
{
  cin>>c[i];
  if(c[i]%2==0){
    d.push_back(c[i]);
  }

}
for(it=d.begin();it!=d.end();it++){
  if(*it%3==0||*it%5==0){
    j++;
  }

}
if(j==d.size()){
  cout<<"APPROVED"<<endl;
}

else{
  cout<<"DENIED"<<endl;
}
return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define sqr(x) (x)*(x)
#define mod 1000000007
#define pi acos(-1.0)

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    double r;
    cin>>r;
    cout<<2*pi*r<<endl;
    return 0;
}


Measured memory_bytes: 3804
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int ma = -1,mai;
int d[100],n;
vi G[100];

void dfs(int v,int par){
	for(int to : G[v]){
		if(to != par){
			d[to] = d[v] + 1;
			dfs(to,v);
		}
	}
}

int calc(int c1,int c2){
	d[c1] = 0;
	d[c2] = 0;
	dfs(c1,c2);
	dfs(c2,c1);
	int cnt[110][110] = {};
	for(int i = 0;i < n;i++){
		cnt[d[i]][G[i].size()]++;
	}
	for(int i = 0;i < ma / 2;i++){
		int m = 0;
		for(int j = 0;j < n;j++){
			if(cnt[i][j]) chmax(m,j);
		}
		for(int j = 0;j < n;j++){
			cnt[i + 1][1] += (m - j) * cnt[i][j];
		}
	}
	return cnt[ma / 2][1];
}

signed main(){
	cin >> n;
	for(int i = 0;i < n - 1;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	dfs(0,-1);
	for(int i = 0;i < n;i++){
		if(d[i] > ma){
			mai = i;
			ma = d[i];
		}
	}
	d[mai] = 0;
	dfs(mai,-1);
	ma = -1;
	for(int i = 0;i < n;i++) chmax(ma,d[i]);
	int c1 = -1,c2 = -1;
	for(int i = 0;i < n;i++){
		int t = 0;
		d[i] = 0;
		dfs(i,-1);
		for(int j = 0;j < n;j++) chmax(t,d[j]);
		if(t <= (ma + 1) / 2){
			if(c1 == -1) c1 = i;
			else c2 = i;
		}
	}
	int ans = INF;
	if(c2 == -1){
		ans = calc(c1,c1);
		for(int to : G[c1]) chmin(ans,calc(c1,to));
	}else ans = calc(c1,c2);
	cout << ma / 2 + 1 << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

vector<vector<int>> to(205);
const int INF = 1001001001;
int vis[300];
int n;
bool dfs(int v,int c){
    vis[v]=c;
    for(auto u:to[v]){
        if(vis[u]==c) return false;
        if(vis[u]==0 && !dfs(u,-c)) return false;
    }
    return true;
}
int main(){
    cin >> n;
    rep(i,n){
        string s; cin >> s;
        rep(j,n){
            if(s[j]=='1' && i>j){
                to[i].push_back(j);
                to[j].push_back(i);
            }
        }
    }
    //二部グラフの判定
    if(!dfs(0,1)){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    rep(s,n){
        queue<int> q;
        vector<int> d(n);
        rep(i,n) d[i]=INF;
        q.push(s);
        d[s]=0;
        while(!q.empty()){
            int v = q.front();
            q.pop();
            for(auto u:to[v]){
                if(d[u]!=INF) continue;
                d[u]=d[v]+1;
                q.push(u);
            }
        }
        rep(i,n) if(d[i]!=INF) chmax(ans,d[i]);

    }
    cout << ans+1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool arr[10001];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    arr[0]=1;
    for(int i=0;i<n;i++){
        int s;
        cin>>s;
        stack<int> v;
        for(int j=0;j+s<=10000;j++){
            if(arr[j]==1){
                v.push(j+s);
            }
        }
        while(!v.empty()){
            int u=v.top();
            v.pop();
            arr[u]=1;
        }
    }
    for(int j=9999;j>=0;j--){
        if(j!=0){
            if(arr[j]==1 && j%10!=0){
                cout<<j<<endl;
                break;
            }
        }
        else{
            cout<<j<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, w, weight[110], value[110];
ll dp[110][100100];

int main() {
    cin >> n >> w;
    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i];

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            if(j - weight[i] >= 0) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j - weight[i]] + value[i]);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[n][w] << endl;
}

Measured memory_bytes: 79360
# -*- coding: utf-8 -*-
"""
Input Candidates
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0242

"""
import sys


from string import ascii_lowercase
from collections import defaultdict

def solve(n):
    d = {ch: defaultdict(int) for ch in ascii_lowercase}
    for _ in range(n):
        for word in input().split():
            d[word[0]][word] += 1
    k = input()
    return [a for _, a in sorted([(-v, k) for k, v in d[k].items()])[:5]] \
        if d[k] else ['NA']


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        ans = solve(n)
        print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 6740
#include <stdio.h>
#include <stdlib.h>

int solve(int *array, int n, int i, int m) 
{
    int ret;

    if(m == 0) 
        return 1;
    if(i >= n)
        return 0;
    ret = solve(array, n, i + 1, m) || solve(array, n, i + 1, m - array[i]);

    return ret;
}

int main(void) 
{
    int i, n, q, A, m;
    int *array;

    scanf("%d", &n);
    array = malloc(sizeof(int) * n);
    for(i = 0; i < n; i++) {
        scanf("%d", &A);
        array[i] = A;
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++) {
        scanf("%d", &m);
        if(solve(array, n, 0, m)) 
            printf("yes\n");
        else 
            printf("no\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
int read();
int n, m;
int col(int x) { return (x - 1) / m + 1; }
int a[202][202], b[202][202];
vector<int> c[202][202];
void pop(int x, int i, int j) { b[i][j] = c[i][x].back(), c[i][x].pop_back(); }

struct Flow {
    int s, t;
    int hd[1003], nx[100005], to[100005], c[100005], cnt;
    void add(int f, int t, int cap) {
        nx[++cnt] = hd[f], hd[f] = cnt, to[cnt] = t, c[cnt] = cap;
    }
    void fadd(int f, int t) { add(f, t, 1), add(t, f, 0); }
    void init() { t = (s = (n << 1) + 1) + 1, cnt = 1; }

    queue<int> q;
    int dep[1003];
    bool bfs() {
        for (int i = 1; i <= t; ++i) dep[i] = 0;
        dep[s] = 1, q.push(s);
        while (!q.empty()) {
            int u = q.front();
            q.pop();
            for (int i = hd[u], v; i; i = nx[i])
                if (!dep[v = to[i]] && c[i] > 0) dep[v] = dep[u] + 1, q.push(v);
        }
        return dep[t];
    }

    int iter[1003];
    int dfs(int u, int dist) {
        if (u == t) return dist;
        for (int &i = iter[u], v; i; i = nx[i]) {
            if (c[i] < 1 || dep[v = to[i]] != dep[u] + 1) continue;
            int d = dfs(v, min(dist, c[i]));
            if (d) return c[i] -= d, c[i ^ 1] += d, d;
        }
        return 0;
    }

    void Dinic() {
        while (bfs()) {
            for (int i = 1; i <= t; ++i) iter[i] = hd[i];
            while (dfs(s, 1000)) void();
        }
    }
    void work(int id) {
        for (int i = 1; i <= n; ++i) fadd(s, i), fadd(i + n, t);
        Dinic();
        for (int i = n + 1; i <= n + n; ++i)
            for (int j = hd[i]; j; j = nx[j])
                if (c[j]) c[j] = 0, pop(i - n, to[j], id);
    }
} flow;
void ins(int i, int x) { c[i][col(x)].push_back(x), flow.fadd(i, n + col(x)); }

int main() {
    n = read(), m = read(), flow.init();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) a[i][j] = read(), ins(i, a[i][j]);
    for (int i = 1; i <= m; ++i) flow.work(i);
    for (int i = 1; i <= n; ++i, puts(""))
        for (int j = 1; j <= m; ++j)
            printf("%d ", a[col(b[i][j])][j] = b[i][j]);
    for (int i = 1; i <= n; ++i, puts(""))
        for (int j = 1; j <= m; ++j) printf("%d ", a[i][j]);
    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n,mid,i,a[500000],sum=0,l=0,ta,ans;
	cin>>n;
	for(i=0;i<n;i++) {
		cin>>a[i];
		sum+=a[i];
	}
	ans=sum;
	for(i=0;i<n;i++) {
		l+=a[i];
		sum-=a[i];
		ta=abs(sum-l);
		if(ta<ans) ans=ta;
	}
	cout<<ans;
}

Measured memory_bytes: 3712
X= int(input().strip())
tmp = 1
endflag = 10000
for j in range(2,X):
    for i in range(1,X):
        if i**j<=X and tmp<i**j and (i+1)**j>X:
            tmp = i**j
            endflag = i
            break
        elif i >= endflag:
            break
print(tmp)

Measured memory_bytes: 3064
def main():
    n = int(input())
    l = list(map(int, input().split()))
    count = 0
    if n < 3:
        return 0
    else:
        for i in range(n-2):
            for j in range(i+1, n):
                for k in range(j+1, n):
                    select = [l[i], l[j], l[k]]
                    # len1 = len(select)
                    # len2 = len(set(select))
                    # maxans = max(select)
                    # sumans = sum(select)
                    # case1 = len(select) == len(set(select))
                    # case2 = max(select)*2 < sum(select)
                    if (len(select) == len(set(select))) and (max(select)*2 < sum(select)):
                        count += 1
        return count


if __name__ == "__main__":
    print(main())


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
int main(){
int a,b,q;
cin>>a>>b;
if(b<10)
q=10*a+b;
else if(b<100)
 q=100*a+b;
else
{
 q=1000*a+b;
}


for(int i=1;i<1000000;i++){
  if(i*i==q){
    cout<<"Yes"<<endl;
    return 0;
  }
}
cout<<"No"<<endl;
//cout<<q<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/


int main(){
    //freopen(".txt", "w", stdout
    //IO;
    ll n;
    cin>>n;
    ll A[n];
    ll o = 0;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin>>A[i];
        if(A[i] < 0){
            o++;

        }
        A[i] = abs(A[i]);
        sum += A[i];
    }
    sort(A,A+n);
    reverse(A,A+n);
    if(o % 2 == 0){
        cout<<sum;
        return 0;
    }else
        cout<<sum - 2* A[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int D=365;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26));

ll calc(const vector<int>& t, int d, int q){
  ll res = 0;
  vector<int> lst(26,-1);
  rep(i,D){
    if(i!=d){
      if(t[i]!=-1){
        res += s[i][t[i]];
        lst[t[i]] = i;
      }
    }
    else{
      res += s[i][q];
      lst[q]=i;
    }
    rep(j,26){
      res -= c[j]*(i-lst[j]);
    }
  }
  //cerr << res << '\n';
  return res;
}

ll calc2(const vector<int>& t, int d1, int d2){
  ll res = 0;
  vector<int> lst(26,-1);
  rep(i,D){
    if(i!=d1 && i!=d2){
      res += s[i][t[i]];
      lst[t[i]] = i;
    }
    else if(i==d1){
      res += s[i][t[d2]];
      lst[t[d2]]=i;
    }
    else if(i==d2){
      res += s[i][t[d1]];
      lst[t[d1]]=i;
    }
    rep(j,26){
      res -= c[j]*(i-lst[j]);
    }
  }
  //cerr << res << '\n';
  return res;
}

int main(){
  /*
  ifstream in("input.in");
  cin.rdbuf(in.rdbuf());
  ofstream ofs("output.txt");
  cout.rdbuf(ofs.rdbuf());
  //*/
  chrono::system_clock::time_point start, end;
  start = chrono::system_clock::now();
  mt19937 mt(184);
  cin >> D;
  rep(i,26) cin >> c[i];
  rep(y,D) rep(x,26) cin >> s[y][x];
  vector<int> t(D,-1);
  ll now = calc(t, -1, -1);
  rep(d,D){
    int k=-1;
    ll prenow=-1;
    rep(q,26){
      if(c[q]<1 && s[d][q]<10000) continue;
      if(c[q]<10 && s[d][q]<1000) continue;
      ll pre = calc(t,d,q);
      if(now < pre){
        if(mt()&1 || mt()&1 || mt()&1) {
          now = pre;
          t[d] = q;
        }
        if(k==-1) {k=q; prenow = pre;}
      }
      if(chmax(now,calc(t,d,q))){
        t[d]=q;
      }
      end = chrono::system_clock::now();
      double ela = chrono::duration_cast<chrono::milliseconds> (end-start).count();
      if(ela>1900) break;
    }
    if(t[d]==-1) {
      t[d]=k;
      now = prenow;
    }
    // timer
    end = chrono::system_clock::now();
    double ela = chrono::duration_cast<chrono::milliseconds> (end-start).count();
    if(ela>1900) break;
  }
  while(1){
    int d1=mt()%365, d2=mt()%365;
    if(d1==d2) continue;
    if(chmax(now,calc2(t,d1,d2))){
      int tmp = t[d1];
      t[d1]=t[d2];
      t[d2]=tmp;
    }
    end = chrono::system_clock::now();
    double ela = chrono::duration_cast<chrono::milliseconds> (end-start).count();
    if(ela>1970) break;
  }
  rep(i,D) cout << t[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int g,nt,re[100007]={0};
    string q;
    cin>>q;
    for(g=nt=0;q[g];g++){
        if(q[g]=='R')nt++;
        else if(nt)re[g-1]=(nt+1)/2,re[g]=nt/2,nt=0;
    }
    for(g=q.length()-1,nt=0;g>=0;g--){
        if(q[g]=='L')nt++;
        else if(nt)re[g+1]+=(nt+1)/2,re[g]+=nt/2,nt=0;
    }
    for(g=0;g<q.length()-1;g++)
        printf("%d ",re[g]);
    printf("%d\n",re[g]);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+50;
ll x,y,n;
double d,ans;
int main()
{
    cin>>n>>d;
    ll sum=0;
    while(n--)
    {
        cin>>x>>y;
        ans=sqrt(x*x+y*y);
        if(ans<=d) sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3684
{-# LANGUAGE BangPatterns #-}


import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import System.IO

main :: IO ()
main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  hs <- unfoldr (BS.readInt . BS.dropWhile (=='\n')) <$> BS.getContents
  let sorted = sort hs
      zipped = zipWith (-) (drop (k-1) sorted) sorted
      minn = minimum zipped
  print minn


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

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

signed main(){
	int n; cin>>n;
	double cnt = 0.0;
	reps(i,n){
		if(i%2) cnt += 1.0;
	}
	cout << cnt/(double)n; 


  return 0;
}


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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> X(M), Y(M), Z(M);
    rep(i, M) cin >> X[i] >> Y[i] >> Z[i];

    vector<unordered_set<ll>> g(N);
    rep(i, M) {
        g[X[i] - 1].insert(Y[i] - 1);
        g[Y[i] - 1].insert(X[i] - 1);
    }

    ll ans = 0;
    vector<bool> visited(N, false);
    rep(i, N) {
        if (visited[i]) continue;
        stack<ll> to;
        to.push(i);
        visited[i] = true;
        while (to.size() > 0) {
            ll pwd = to.top();
            to.pop();
            for (auto t : g[pwd]) {
                if (visited[t]) continue;
                to.push(t);
                visited[t] = true;
            }
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19236
N, M = map(int, input().split())
cake = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 18
dp = [[[-INF] * 8 for _ in range(M + 1)] for _ in range(N + 1)]
for i in range(N + 1):
    for msk in range(8):
        dp[i][0][msk] = 0

for i in range(1, N + 1):
    x, y, z = cake[i - 1]
    for j in range(1, M + 1):
        for msk in range(8):
            mx = x * (1 - 2 * (msk >> 2 & 1))
            my = y * (1 - 2 * (msk >> 1 & 1))
            mz = z * (1 - 2 * (msk >> 0 & 1))
            dp[i][j][msk] = max(dp[i - 1][j][msk],
                                dp[i - 1][j - 1][msk] + mx + my + mz)

print(max(dp[N][M][i] for i in range(8)))

Measured memory_bytes: 167388
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7; 
int n,i,j,k,l,dp[55][105],c[55][55];
int main(){
	cin>>n;
	dp[1][n]=dp[1][n-1]=n;
	c[0][0]=1;
	for(i=1;i<=n;i++){
		c[i][0]=1;
		for(j=1;j<=i;j++){
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
		}
	}
	for(i=1;i<=n;i++){
		for(j=-n;j<=n;j++){
			if(dp[i][j+n]){
				for(k=max(1,abs(j));k<=n-i;k++){
					if(!((j+k)&1)){
						for(l=0;l<=k;l++){
							int t=(j+k)/2-l;
							if(-n<=t&&t<=n){
								dp[i+k][t+n]=(dp[i+k][t+n]+1ll*dp[i][j+n]*c[n-i][k]%mod*c[k][l])%mod;
							}
						}
					}
				}
			}
		}
	}
	cout<<dp[n][n]<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
nowmin = a[0]
nowmax = max(a[1:])
ans = nowmax - nowmin
for i in range(n-1):
  if a[i] == nowmax:
    nowmax = max(a[i+1:])
  if a[i] < nowmin:
    k = nowmax - a[i]
    if k > ans:
      ans =  k
      nowmin = a[i]


print(ans)



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

using namespace std;

inline int sqd(int x, int y)
{
    return x * x + y * y;
}

int main()
{
    int h, w;
    while(cin >> h >> w, h|w)
    {
        int d = sqd(h, w);
        int rt = int(sqrt(d));
        int td = 100000000;
        int tx, ty;
        for(int y=rt; y>0; y--)
        {
            int x = y+1;
            while(sqd(x, y)<(y>h ? d : d+1)) x++;
            if(sqd(x, y)<=td)
            {
                tx = x;
                ty = y;
                td = sqd(x, y);
            }
        }
        cout << ty << " " << tx << endl;

    }
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch ForbiddenList | diff ForbiddenList.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ForbiddenList.cpp && ./a.out

/*

 6/14/2020

 5:05-

 */

const int MAX_N=1e6+1;
int P[MAX_N];
int N,X;

void solve() {
  set<int> S(P,P+N);
  //dumpc(S);
  int res=-200;
  FOR(a,-200,200) if(!S.count(a)) {
    if(abs(X-a)<abs(X-res)) res=a;
    //dump(a,abs(X-a),res,abs(X-a),abs(X-res));
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>X>>N;
  REP(i,N) cin>>P[i];
  solve();

  return 0;
}


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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 200000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    long long N,K,S;
    cin>>N>>K>>S;
    long long A[N];
    for(int i=0;i<N;i++){
        if(i<K){
            A[i]=S;
        }else{
            if(S==1000000000){
            A[i]=S-1;}else{
                A[i]=S+1;
            }
        }

    }
    for(int i=0;i<N;i++){
        if(i!=N-1){
           cout<<A[i];
           cout<<" ";
        }else{
            cout<<A[i]<<endl;
        }
    }






}

Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0033
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            int[] A1s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] A2s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int result = 0;

            for (int i = 0; i < A1s.Length; i++)
            {
                var t = 0;

                for (int k = 0; k <= i; k++)
                {
                    t += A1s[k];
                }
              
                for (int j = i; j < A2s.Length; j++)
                {
                    t += A2s[j];
                }

                if (result < t)
                {
                    result = t;
                }
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 28280
#include <iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	
	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}

	return 0;
}

Measured memory_bytes: 1128
#include <stdio.h>
int n, m, f, x;
char a[50][51];
char b[50][51];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf(" %s", a[i]);
	}
	for (int i = 0; i < m; i++) {
		scanf(" %s", b[i]);
	}
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			x = 1;
			for (int k = 0; k < m; k++) {
				for (int l = 0; l < m; l++) {
					if (a[i + k][j + l] != b[k][l])x = 0;
				}
			}
			if (x)f = 1;
		}
	}
	if (f)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 1620
# -*- coding: utf-8 -*-

n,y = map(int,input().split())

is_searched = False

for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        if k < 0:
            continue
        if i * 10000 + j * 5000 + k * 1000 == y :
            print(i,j,k)
            is_searched = True
            break
    if is_searched:
        break
else:
    print(-1,-1,-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long
const int N = 1e5 + 10;
int n;
int a[N];
int dp[N];

int calc(int pos){

    if(pos < 0)
        return 1e10;
    if(pos==0)
        return 0;

    int &ans = dp[pos];

    if(ans!=-1)
        return ans;

    ans = min(abs(a[pos] - a[pos-1]) + calc(pos-1) , abs(a[pos] - a[pos-2]) + calc(pos-2));

    return ans;


}

void solve(){

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

    memset(dp , -1,sizeof dp);

    int ans = calc(n-1);

    cout<<ans<<endl;
}
signed main(){

    fast;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 3328
import java.util.Scanner;

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

    int sx = scanner.nextInt();
    int sy = scanner.nextInt();
    int tx = scanner.nextInt();
    int ty = scanner.nextInt();

    int x = ((tx - sx) >> 31) | 1;
    int y = ((ty - sy) >> 31) | 1;
    int nx = (tx - sx) * x;
    int ny = (ty - sy) * y;

    //System.out.printf("x = %d, y = %d, nx = %d, ny = %d\n", x, y, nx, ny);

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < ny; i++) sb.append(y > 0 ? 'U' : 'D');
    y *= -1;
    for (int i = 0; i < nx + 1; i++) sb.append(x > 0 ? 'R' : 'L');
    x *= -1;
    for (int i = 0; i < ny + 1; i++) sb.append(y > 0 ? 'U' : 'D');
    y *= -1;
    for (int i = 0; i < nx + 1; i++) sb.append(x > 0 ? 'R' : 'L');
    sb.append(y > 0 ? 'U' : 'D');
    sb.append(x > 0 ? 'R' : 'L');
    x *= -1;
    for (int i = 0; i < ny + 1; i++) sb.append(y > 0 ? 'U' : 'D');
    y *= -1;
    for (int i = 0; i < nx + 1; i++) sb.append(x > 0 ? 'R' : 'L');
    x *= -1;
    for (int i = 0; i < ny + 1; i++) sb.append(y > 0 ? 'U' : 'D');
    for (int i = 0; i < nx; i++) sb.append(x > 0 ? 'R' : 'L');

    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 21844
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n = input()
    ans = []
    for i in range(3):
        if n[i] == '1':
            ans.append('9')
        else:
            ans.append('1')
    print(''.join(ans))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

void solve(vecint&& p, string& s, vecint& res, int offset, int base) {
  vecint even;
  vecint odd;
  int n = p.size();
  if (n == 1) {
    res[offset] = p.front();
    return;
  }
  REP(i,n/2) {
    int p0 = p[2*i];
    int p1 = p[2*i+1];
    int p2 = p[(2*i+2)%n];
    int ep0 = min(p0, p1);
    int ep1 = max(p0, p1);
    if (s[ep1-ep0-1] == '1') even.push_back(ep1);
    else even.push_back(ep0);
    int op0 = min(p1, p2);
    int op1 = max(p1, p2);
    if (s[op1-op0-1] == '1') odd.push_back(op1);
    else odd.push_back(op0);
  }
  solve(std::move(even), s, res, offset, base*2);
  solve(std::move(odd), s, res, offset+base, base*2);
}

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  int p2 = 1<<n;
  vecint p(p2);
  for(auto&& e:p) cin>>e;
  vecint result(p2);
  solve(std::move(p),s,result,0,1);
  for(auto&& e:result){
    cout<<e<<'\n';
  }
  cout<<flush;
  return 0;
}



Measured memory_bytes: 7360
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int n;
vector<ll>l;
ll solve(){
   ll ans=0;
   sort(all(l));
   rep(i,n)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++)
   {
       if(l[i]+l[j]>l[k]&&l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]){
           ans++;
       }
       //cout<<i<<" "<<j<<" "<<k<<endl;}
   }

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

    cin>>n;
    l.resize(n);
    rep(i,n)cin>>l[i];
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <array>
#include <string>

using namespace std;

void fire( array<array<bool, 8>, 8>& f, int i, int j )
{
    if ( i < 0 || j < 0 || i >= 8 || j >= 8 )
        return;

    if ( f[i][j] ) {
        f[i][j] = false;

        for( int ii=-3; ii<=3; ++ii )
            if ( ii != 0 )
                fire( f, i + ii, j );

         for( int jj=-3; jj<=3; ++jj )
            if ( jj != 0 )
                fire( f, i, j + jj );           
    }
}

int main()
{
    int n;
    cin >> n;
    for( int iii=0; iii<n; ++iii ) {
        array<array<bool, 8>, 8> f;
        for( int i=0; i<8; ++i ) {
            string s;
            cin >> s;
            for( int j=0; j<8; ++j )
                f[i][j] = s[j] == '1';
        }
        int x, y;
        cin >> x >> y;
        fire( f, y-1, x-1 );

        cout << "Data " << iii+1 << ":" << endl;
        for( int i=0; i<8; ++i ) {
            for( int j=0; j<8; ++j ) 
                cout << f[i][j];
            cout << endl;
        }
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int mx = 0;
  for(int i=0;i<n;i++){
      cin>>a[i];        //vectorにi個格納する
  }
  for(int i=0;i<n;i++){
      mx=max(mx,a[i]);  //0とAiを全て比較してmaxを取る
  }
 
  vector<int> c(mx+1);
  for(int i=0;i<n;i++) {
    for(int j=1; j * a[i] <= mx; j++) {
      if(c[j*a[i]]>1) {}
     else  c[j*a[i]]++;
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++){
      ans += (c[a[i]]==1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 7796
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp96 {
    class Program {
        static long mod = 1000000007;

        static long[] factorialMod;
        static long[] factorialModInv;

        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long H = st[0];
            long W = st[1];
            long A = st[2];
            long B = st[3];

            long ans = 0;

            factorialMod = new long[200010];
            factorialModInv = new long[200010];

            for (int i = 0; i < 200000; i++) {
                if (i <= 1) {
                    factorialMod[i] = 1;
                    continue;
                }

                factorialMod[i] = i * factorialMod[i - 1] % mod;
            }

            for (int i = 0; i < 200000; i++) {
                if (i <= 1) {
                    factorialModInv[i] = 1;
                    continue;
                }

                factorialModInv[i] = ModInv(i) * factorialModInv[i - 1] % mod;
            }


            for (long i = 0; B + i < W; i++) {
                //Console.WriteLine(i);
                //Console.WriteLine(CalculateCMod(H - A, B + i + 1));
                //Console.WriteLine(CalculateCMod(A, W - B - i));

                ans += CalculateCMod(H - A, B + i + 1) % mod * CalculateCMod(A, W - B - i) % mod;
                ans %= mod;
            }
            Console.WriteLine(ans % mod);
        }

        //aマス×bマスの行き方の合計のmod
        static long CalculateCMod(long a, long b) {
            return factorialMod[a + b - 2] % mod * (factorialModInv[a - 1]) % mod * (factorialModInv[b - 1]) % mod;

            //return FactoricalMod(a + b - 2) % mod * (FactoricalModInv(a - 1)) % mod * (FactoricalModInv(b - 1)) % mod;
        }

        static long FactoricalMod(long a) {
            if (a <= 1) {
                return 1;
            }
            return a * FactoricalMod(a - 1) % mod;
        }

        static long ModInv(long a) {
            if (a <= 1) {
                return 1;
            }

            long ret = -(ModInv(mod % a) * (mod / a)) % mod;
            if (ret < 0) {
                ret += mod;
            }
            return ret;
        }

        static long FactoricalModInv(long a) {
            if (a <= 1) {
                return 1;
            }

            return ModInv(a) * FactoricalModInv(a - 1) % mod;
        }
    }
}


Measured memory_bytes: 16468
import java.util.Scanner;
	class Main{
//PCK2006 0136
		public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int kaisu;
	double date;
	int count[]=new int[6];
	
	kaisu=sc.nextInt();
	for(int i=0;i<kaisu;i++){
		date=sc.nextDouble();
		int ff;
	Math.floor(date);
	if(date<165){
		count[0]++;
	}else if(date<170){
		count[1]++;
	}else if(date<175){
		count[2]++;
	}else if(date<180){
		count[3]++;
	}else if(date<185){
		count[4]++;
	}else if(date>=185){
		count[5]++;
	}
	}
	String moji;
	String moji1 = "";
	moji="*";
for(int i=0;i<6;i++){
	int su;
	su=i+1;
	for(int t=0;t!=count[i];t++){
	moji1=moji1+"*";
	}

	System.out.println(su+":"+moji1);
	moji1="";
}

	

	
	}
	}

Measured memory_bytes: 28208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main()
{
    int r0,w0,c,r;
    while(cin >>r0 >>w0 >>c >>r,r)
    {
        int x = 0;
        while(1)
        {
            if(r0+x*r-c*w0>=0) break; 
            ++x;
        }
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 2984
def main():
    buf = input()
    S = buf
    K = len(S) // 2
    center_char = S[K]
    while K < len(S):
        if S[K] == center_char and S[-K - 1] == center_char:
            K += 1
        else:
            break
    print(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//Micro Futures scalping to get my tendies
vector<int> adj[200200];
int dp[200200];
int arr[200200]; int h[200200];
int sum = 0;
int dfs(int root){ 
	int sum = 0;
	for(auto xx : adj[root]){
		sum += dfs(xx);
	}
	return sum+arr[root-1];
}
int main(){
	double n,d; cin>>n>>d; int cc = 0;
	for(int i = 0; i < n; i++){
		double x,y; cin>>x>>y; 
		double dist = sqrt(pow(x,2)+pow(y,2));
		if(d - dist >= 0) cc++; 
	}
	cout<<cc<<"\n";
}

Measured memory_bytes: 8536
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,i,l,x;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	i=a;
	if(b<i){
		i=b;
	}
	if(c<i){
		i=c;
	}
	l=d;
	if(e<l){
		l=e;
	}
	x=i+l-50;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 2684
N, A, B = map(int, input().split())

if N-B+1 < A or A < (N + B-1) // B:
    print(-1)
    exit(0)

res = []
r = []
cnt = 0
for i in range(N):
    r.append(N-i)
    if N-i <= A-cnt or len(r) == B:
        res.append(r)
        r = []
        cnt += 1

if r:
    res.append(r)
ans = []
for r in reversed(res):
    ans.extend(r)
print(*ans)

Measured memory_bytes: 51308