akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<String, Integer> map = new HashMap<>();
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            String s = sc.next();
            map.put(s, map.getOrDefault(s, 0) + 1);
        }
        Optional<Map.Entry<String, Integer>> target = map.entrySet().stream().max((e1, e2)-> e1.getValue().compareTo(e2.getValue()));
        int max = target.get().getValue();
        map.entrySet().stream().filter(e->e.getValue() == max).sorted(Map.Entry.comparingByKey()).forEach(e-> System.out.println(e.getKey()));
    }
}


Measured memory_bytes: 87800
#include<cstdio>
#include<cstring>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	if(n % 4 == 0 || n % 7 == 0) {
		printf("Yes\n");
		return 0;
	}
	for(int i = 1; ; i++) {
		n = n - 7;
		if(n < 0) break;
		if(n % 4 == 0) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}

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

int main()
{
 int n;
  cin>>n;
  int x=0,y=0;
  vector<int> c(n),v(n);
  for(int &i:c) cin>>i;
  for(int &i:v) cin>>i;
  for(int i=0;i<n;i++) if(c[i]>v[i]) x+=c[i],y+=v[i];
  cout<<x-y<<"\n";
  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    for (int d, w;;) {
        cin >> d >> w;
        if (d == 0 and w == 0) { break; }
        vector<vector<int>> e(d, vector<int>(w));
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < w; j++) { cin >> e[i][j]; }
        }
        int ans = 0;
        for (int i = 0; i < d; i++) {
            for (int j = i + 2; j < d; j++) {
                for (int k = 0; k < w; k++) {
                    for (int l = k + 2; l < w; l++) {
                        int h = 100;
                        for (int x = k; x <= l; x++) { h = min({h, e[i][x], e[j][x]}); }
                        for (int y = i; y <= j; y++) { h = min({h, e[y][k], e[y][l]}); }
                        int sum = 0;
                        bool ok = true;
                        for (int x = k + 1; x < l; x++) {
                            for (int y = i + 1; y < j; y++) {
                                if (e[y][x] >= h) { ok = false; }
                                sum += h - e[y][x];
                            }
                        }
                        if (ok) { ans = max(ans, sum); }
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define Maxn 1000007
char s[Maxn];
int val[Maxn],sum[Maxn],r[Maxn];
bool flag[Maxn];
int n;
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    memset(flag,false,sizeof(flag));
    int mx=0;
    for (int i=1;i<=n;i++)
    {
        if (s[i]=='1') val[i]=1;
        else if (s[i]=='0') val[i]=-1;
        else
        {
            flag[i]=true;
            val[i]=-1;
        }
        sum[i]=sum[i-1]+val[i];
        mx=max(mx,sum[i]);
    }
    r[n]=sum[n];
    for (int i=n-1;i;i--)
        r[i]=max(sum[i],r[i+1]);
    int tmp=0;
    for (int i=1;i<=n;i++)
        if (flag[i])
        {
            if (r[i]+tmp+2<=mx)
            {
                tmp+=2;
                val[i]=1;
            }
        }
    int mn=0;
    for (int i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+val[i];
        mn=min(mn,sum[i]);
    }
    int ans=mx-mn;
    ++mx;
    for (int i=1;i<=n;i++)
    {
        if (s[i]=='1') val[i]=1;
        else if (s[i]=='0') val[i]=-1;
        else
        {
            flag[i]=true;
            val[i]=-1;
        }
        sum[i]=sum[i-1]+val[i];
    }
    r[n]=sum[n];
    for (int i=n-1;i;i--)
        r[i]=max(sum[i],r[i+1]);
    tmp=0;
    for (int i=1;i<=n;i++)
        if (flag[i])
        {
            if (r[i]+tmp+2<=mx)
            {
                tmp+=2;
                val[i]=1;
            }
        }
    mn=0;
    for (int i=1;i<=n;i++)
    {
        sum[i]=sum[i-1]+val[i];
        mn=min(mn,sum[i]);
    }
    ans=min(ans,mx-mn);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 17432
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

vector<long long> fact(200001,1);
void factorial(int N){
    for(int i=1; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

map<long long, long long> inv_fact;
long long inv_factorial(long long x){
    if (inv_fact.find(x)!=inv_fact.end()){
        return inv_fact[x];
    }
    long long p=MOD-2;
    long long ret=1;
    long long tmp=x;
    while(p>0){
        if(p%2==1)ret=ret*tmp%MOD;
        tmp=tmp*tmp%MOD;
        p/=2;
    }
    inv_fact[x]=ret;
    return ret;
}

pair<int,int> make_key(int x, int p){
    return make_pair(x,p);
}
int cnt=0;
ll dfs(int node, int parent, vector<vector<int>> &edge, map<pair<int,int>,ll> &dic, map<pair<int,int>,ll> &elm){
    cnt++;
    pair<int,int> key=make_key(node, parent);

    if(dic.find(key)!=dic.end()){
        return dic[key];
    }else if(dic.find(make_key(node, -1))!=dic.end()){
        pair<int,int> sub_key=make_key(node,-1);
        pair<int,int> inv_key=make_key(parent,node);
        dic[key]=((((dic[sub_key]*inv_factorial(dic[inv_key]))%MOD*inv_factorial(fact[elm[sub_key]-1]))%MOD*fact[elm[sub_key]-elm[inv_key]-1])%MOD*fact[elm[inv_key]])%MOD;
        elm[key]=elm[sub_key]-elm[inv_key];
        //cout << node << ' ' << parent << ' ' <<  elm[sub_key] << ' ' << fact[elm[inv_key]] << endl;
        return dic[key];
    }

    dic[key]=1;
    elm[key]=1;
    for(auto x:edge[node]){
        if(x==parent){
            continue;
        }
        pair<int,int> sub_key=make_key(x,node);
        dic[key]*=dfs(x, node, edge, dic, elm);
        dic[key]%=MOD;
        dic[key]*=inv_factorial(fact[elm[sub_key]]);
        dic[key]%=MOD;
        elm[key]+=elm[sub_key];
    }
    dic[key]*=fact[elm[key]-1];
    dic[key]%=MOD;
    return dic[key];
}

int main(){
    int N;
    cin >> N;
    vector<vector<int>> edge(N,vector<int>(0));
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    factorial(200000);

    map<pair<int,int>, ll> dp;
    map<pair<int,int>, ll> elm;

    deque<int> que;
    que.push_back(0);

    vector<int> used(N,0);
    int rr=0;
    while((int) que.size()){
        rr++;
        int x=que.front();
        que.pop_front();
        used[x]=1;
        dfs(x, -1, edge, dp, elm);
        for(auto y:edge[x]){
            if(used[y]==1)continue;
            que.push_back(y);
        }
    }
    
    for(int i=0; i<N; i++){
        ll ans=1;
        cout << dp[make_key(i,-1)] << endl;
    }
    //cout << cnt << endl;
}

Measured memory_bytes: 92928
#include<bits/stdc++.h>
using namespace std;
const int Mod=1e9+7,N=1e5+10;
#define pb push_back
#define f first
#define s second
typedef long long ll;
int n,w;
ll dp[N][150],a[N][3];
int main()
{
  cin>>n>>w;
  for(int i=1;i<=n;i++) cin>>a[i][1]>>a[i][2];
  for(int i=1;i<=w;i++)
  {
    for(int j=1;j<=n;j++)
    {
      dp[i][j]=dp[i][j-1];
      if((i-a[j][1])>=0) dp[i][j]=max(dp[i][j],a[j][2]+dp[i-a[j][1]][j-1]);
    }
  }
  cout<<dp[w][n]<<endl;
  return 0;
}


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

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll, ll>    pll;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0;
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'
#define fastio          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define file_io         freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#define ld_io           cout << setprecision(10) << fixed;

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll MAXN  = 1e5 + 10;
const ll INF   = 8e18;
const ll MOD   = 1e9 + 7; // 998244353;
const ll LOG   = 32;      // log2(1e9)
const ll BLOCK = 320;     // sqrt(1e5)

ll n, C[MAXN], mx;
vector<pll> adj[MAXN];

void DFS(ll u, ll p = -1, ll col = -1) {
    ll cnt = 1;
    for (pll e : adj[u]) {
        ll v = e.X;
        if (v == p) continue;
        if (cnt == col) cnt++;
        C[e.Y] = cnt;
        DFS(v, u, cnt);
        mx = max(mx, cnt);
        cnt++;
    }
}

int main() {
    fastio
    cin >> n;
    for (ll i = 1; i < n; i++) {
        ll u, v;
        cin >> u >> v;
        adj[u].push_back({v, i});
        adj[v].push_back({u, i});
    }
    DFS(1);
    cout << mx << endl;
    for (ll i = 1; i < n; i++) {
        cout << C[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N; cin >> N; int B[N], A[N], sum = 0;
    for (int i = 1; i < N; i++) cin >> B[i];
    A[0] = B[1], sum += A[0];
    for (int i = 1; i < N; i++) {
        A[i] = B[i], sum += A[i];
        int MAX = max(A[i], A[i-1]);
        if (B[i] < MAX) sum -= A[i-1], A[i-1] = B[i], sum += B[i];
    }   cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
m,n=len(s),len(t)
dp=[[0]*(n+1)for _ in range(m+1)]
for i in range(m):
    for j in range(n):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            if dp[i+1][j]>dp[i][j+1]:
                dp[i+1][j+1]=dp[i+1][j]
            else:
                dp[i+1][j+1]=dp[i][j+1]
a,b=m,n
tmp=''
while a and b:
    if s[a-1]==t[b-1]:
        a-=1
        b-=1
        tmp+=s[a]
    elif dp[a][b]==dp[a-1][b]:
        a-=1
    else:
        b-=1
print(tmp[::-1])


Measured memory_bytes: 144732
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int n, k; cin >> n >> k;
	vector<int> p(n);rep(i,n)cin>>p[i];
	sort(all(p));
	int ans = 0;
	rep(i, k) {
		ans += p[i];
	}
	cout << ans << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//int t; cin >> t; rep(i, t)
		solve();
	stop
		return 0;
}


Measured memory_bytes: 20012
#include<iostream>
using namespace std;
int main()
{
	int a, b, c;
	
	while (cin >> a >> b >> c)
	{
		int flag = 0;
		for (int i = 1; i <= b; i++)
		{
			if (a*i%b == c)
			{
				flag = 1;
				break;
			}
		}
		if (flag)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
//	system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long int a , b ;
	while (cin >> a >> b){
		int S = a + b;
		int c = 0;
		while (S){
			S /= 10;
			c = c + 1;
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
ll euclidean_gcd(ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
int main() {
  ll s, t;
  cin >> s >> t;
  ll u = euclidean_gcd(s,t);
  ll ans = s*t/u;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a,b;
	scanf ("%d %d",&a,&b);
	if (a+b>a*b && a+b>a-b)
	{
		printf ("%d\n",a+b);
	}
	else if (a*b>a+b && a*b>a-b)
	{
		printf ("%d\n",a*b);
	}
	else printf ("%d\n",a-b);
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
using namespace std;
string S;
char a[27] = {0};
int main()
{
    cin>>S;
    for (int i = 0; i < S.size(); i++)
        a[S[i] - 'a'] = 1;
    for (int i = 0; i < 26; i++)
        if(!a[i])
        {
            printf("%c\n",i+'a');
            return 0;
        }
    cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF (1e+18)
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
typedef struct LIST{
	int to,cost;
	struct LIST *next;
}Edge;
Edge** init(int v){
	Edge **edge=(Edge**)calloc(v,sizeof(Edge*));
	return edge;
}
void add_edge(Edge **edge,int s,int t,int c){
	Edge *tmp=(Edge*)malloc(sizeof(Edge));
	tmp->to=t,tmp->cost=c;
	tmp->next=edge[s];
	edge[s]=tmp;
	return;
}
void delete_edge(Edge **edge,int v){
	int i;
	Edge *e,*tmp;
	FOR(i,0,v){
		e=edge[i];
		while(e!=NULL){
			tmp=e->next;
			free(e);
			e=tmp;
		}
	}
	return;
}
ll d[100000];
Edge **edge;
void dfs(int v,ll dist){
	d[v]=dist;
	for(Edge *e=edge[v];e!=NULL;e=e->next){
		if(d[e->to]==INF) dfs(e->to,dist+e->cost);
	}
	return;
}
int main(void)
{
	int n,a,b,c,q,k,i;
	scanf("%d",&n);
	edge=init(n);
	FOR(i,0,n-1){
		scanf("%d%d%d",&a,&b,&c);
		a--,b--;
		add_edge(edge,a,b,c);
		add_edge(edge,b,a,c);
	}
	FOR(i,0,n) d[i]=INF;
	scanf("%d%d",&q,&k);
	dfs(--k,0LL);
	FOR(i,0,q){
		scanf("%d%d",&a,&b);
		printf("%lld\n",d[--a]+d[--b]);
	}
	delete_edge(edge,n);
	return 0;
}


Measured memory_bytes: 14208
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;
	int ans = 0, tot = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'R') {
			tot++;
			ans = max(ans, tot);
		}
		else {
			tot = 0;
			ans = max(ans, tot);
			
		}
	}
	printf("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 3256
using System;
using System.IO;
using System.Collections.Generic;

namespace MinPro2019C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var K = ss.Next(long.Parse);
            var A = ss.Next(long.Parse);
            var B = ss.Next(long.Parse);

            if (B - A <= 2 || K - A + 1 <= 0)
            {
                sw.WriteLine(K + 1);
                return;
            }

            var ans = A;
            K = K - A + 1;
            ans += (K / 2) * (B - A) + (K % 2);
            sw.WriteLine(ans);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 13268
#Sは最大でも10桁、+が入る場所は9箇所なので計算量は2^9=512程度。
#全探索で余裕か



def tansaku(number,plus_point,sum_temp):
    #print(number,plus_point,sum_temp)
    str_number = str(number)
    if len(str_number) -1 <= plus_point :
        return number + sum_temp
    else:
        next_number = int(str(number)[plus_point+1:])
        a1 = int(tansaku(next_number,0,sum_temp + int(str(number)[:plus_point+1])))
        #print(a1)

        a2 = tansaku(number,plus_point+1,sum_temp)
        #print(a2)


        return a1 + a2
 


if __name__ == "__main__":
    s = int(input())
    print(tansaku(s,0,0))

Measured memory_bytes: 38256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<pair<ll, ll>> a(n); // pair of <value, id>
  rep(i, n) {
    cin >> a[i].first;
    a[i].second = i + 1; // 1-indexed
  }
  sort(all(a));
  reverse(all(a));
  // For Debug
  // rep(i, n) {
  //   cout << a[i].first << " " << a[i].second << endl;
  // }

  vector<vector<ll>> dp(n+1, vector<ll>(n+1)); // dp[x][y] .. max score when selecting x as left and y as right.
  rep(x, n) rep(y, n) {
    ll now = x + y;
    if (now >= n) { continue; }
    ll px = x+1; // 1, 2, ...
    ll py = n-y; // n, n-1, ...
    chmax(dp[x+1][y], dp[x][y] + a[now].first * abs(a[now].second - px));
    chmax(dp[x][y+1], dp[x][y] + a[now].first * abs((py - a[now].second)));
  }

  ll ans = 0;
  rep(i, n+1) {
    chmax(ans, dp[i][n-i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 34572
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;
    int[][] a;
    for (int i = 0; i < n; i++) {
        a ~= readints;
    }

    auto dp = new int[][](n, 3);
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) { // 前日の行動
            for (int k = 0; k < 3; k++) { // 今日の行動
                if (j == k) continue; // 2 日連続で同じ活動はできない
                dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i][k]);
            }
        }
    }
    writeln(dp[n - 1].reduce!max);
}


Measured memory_bytes: 18684
def main():
    n = int(input())
    balls = list(map(int,input().split()))
    vals = {}
    for i in balls:
        if i not in vals.keys():
            vals[i] = 0

        vals[i] += 1

    total = 0
    for i in vals.keys():
        total += vals[i]*(vals[i]-1)//2

        
    for i in balls:
        val = vals[i]
        total -= val*(val-1)//2
        val -= 1
        val = max(val,0)
        total += val*(val-1)//2
        print(total)
        total -= val*(val-1)//2
        val += 1
        total += val*(val-1)//2


main()


Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++) 

using namespace std;

int main() {
  int n;
  cin>>n;
  vector<char> s(n);
  rep(i,n)cin>>s[i];
  rep(i,n){
    if(s[i]=='Y'){
      cout<<"Four"<<endl;
      return 0;
    }
  }
    cout<<"Three"<<endl;
  }

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	ans := mod
	for i := 0; i < len(s)-2; i++ {
		ans = smaller(ans, abs(stringToInt(s[i:i+3])-753))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template<typename T>
class SegTree{
    int n;
    vector<T> data;
    T def;
    function<T(T,T)> operation;
    function<T(T,T)> update;

    T _query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;

        if(a <= l && r <= b) return data[k];
        else{
            T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
            T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
            return operation(c1, c2);
        }
    }

    public:

    SegTree(int _n, T _def, function<T(T,T)> _operation,
        function<T(T,T)> _update) : def(_def), operation(_operation), update(_update){
            n = 1;
            while(n < _n){
                n *= 2;
            }
            data = vector<T>(2*n-1, def);
    }

    void change(int i, T x){
        i += n-1;
        data[i] = update(data[i], x);
        while(i > 0){
            i = (i-1)/2;
            data[i] = operation(data[i*2+1], data[i*2+2]);
        }
    }

    T query(int a, int b){
        return _query(a, b, 0, 0, n);
    }

    T operator[](int i){
        return data[i+n-1];
    }
     
    T get(int i){
        return data[i+n-1];
    }
};

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    SegTree<int> st(300100,0,[](int a, int b){return max(a,b);}, [](int a, int b){return b;});
    int a[300100];
    rep(i,0,n) cin >> a[i];
    rep(i,0,n){
        int l = max(0, a[i]-k);
        int r = min(300100, a[i]+k+1);
        int tmp = st.query(l, r);
        if(st.get(a[i]) < tmp+1){
            st.change(a[i], tmp+1);
        }
    }

    int ans = st.query(0,300100);
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define ll long long 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
 
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
  
}

Measured memory_bytes: 256
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let (a, b, c): (usize, usize, usize);
    input!(a);
    input!(b);
    input!(c);
    p((c * (a + b)) / 2);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int a,b,c,k;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>a>>b>>c>>k;
	for(;k&&a>=b;k--)b*=2;
	for(;k&&b>=c;k--)c*=2;
	cout<<(a<b&&b<c?"Yes":"No");
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

template<typename T>
void trace(T *a, int s, int n) {
    for (int i=s; i<n; i++) {
	cout<<a[i]<<" ";
    }
    cout<<endl;
}



typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

ll bsum;
ll lower_sum, upper_sum;
priority_queue<ll> lower;
priority_queue<ll,vector<ll>,greater<ll>> upper;


void insert(ll x) {
    if (lower.empty() || lower.top() >= x) {
	lower.push(x);
	lower_sum += x;
    } else {
	upper.push(x);
	upper_sum += x;
    }


    while (lower.size() < upper.size()) {
	ll take = upper.top();
	upper_sum -= take;
	upper.pop();
	lower_sum += take;
	lower.push(take);
    }



    while (lower.size() > upper.size() + 1) {
	ll take = lower.top();
	lower_sum -= take;
	lower.pop();
	upper_sum += take;
	upper.push(take);
    }

    assert(lower.size() >= upper.size());
    if (lower.size() && upper.size()) assert(lower.top() <= upper.top());
}


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

    int q; cin>>q;

    while (q--) {

	int typ; cin>>typ;

	if (typ == 1) {
	    ll a,b; cin>>a>>b;
	    bsum += b;
	    insert(a);
	} else {
	    ll x = lower.top();
	    ll ans = bsum + (1LL*lower.size()*x - lower_sum) + (upper_sum - 1LL*upper.size()*x);
	    cout<<x<<" "<<ans<<"\n";
	}
    }
  

    return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<math.h>
using namespace std;

void a(){
    int n;
    cin >>n;
    n = n%10;
    if(n==3)
    {
        cout<<"bon";
    }
    else if(n==0 ||n==1 ||n==6 ||n==8)
    {
        cout<<"pon";
    }
    else cout<<"hon";
    return;
}

void b(){
    int n,k;
    cin >> n >> k;
    vector<int>vec(n,0);
    for(int i=0;i<k;i++)
    {
        int d;
        cin >>d;
        for(int j=0;j<d;j++)
        {
            int a;
            cin >>a;
            vec[a-1]++;
        }
    }
    int count = 0;
    for(int i=0;i<n;i++)
    {
        if(vec[i]==0)count++;
    }
    cout<<count;
    return;
}

void c(){
   int n,m;
   cin>>n>>m;
   vector<int>h;
   for(int i=0;i<n;i++)
   {
       int t;
       cin >> t;
       h.push_back(t);
   }
   vector<int>f(n,0);
   for(int j=0;j<m;j++)
   {
       int a,b;
       cin >> a>>b;
       if(h[a-1]>h[b-1])
       {
           f[b-1]=1;
       }
       else if(h[a-1]<h[b-1])
       {
           f[a-1]=1;
       }
       else
       {
           f[a-1]=1;
           f[b-1]=1;
       }
   }
   int count=0;
   for(int i=0;i<n;i++)
   {
       if(f[i]==0)count++;
   }
   cout<<count;
   return;
}

void d(){
    int x;
    cin >>x;
    int vmax = ceil( pow(x,1/5));

    
}
void e(){
    int n;
    cin >>n;
    vector<int>a;
    a.push_back(0);
    map<int,int>c;
    int vmin = INT32_MAX;
    int vmax = INT32_MIN;
    for(int i=0;i<n;i++)
    {
        int ai;
        cin >>ai;
        a.push_back(ai);
    }
    long long int pcount=0;
    
    for(int i=n-1;i>0;i--)
    {
        if(c.count(-(a[i+1]-(i+1)))==0){
            c[-(a[i+1]-(i+1))]=1;
        }
        else{
            c[-(a[i+1]-(i+1))]=c[-(a[i+1]-(i+1))]+1;
        }
        if(c.count(i+a[i])!=0)
        pcount+= c[i+a[i]];
    }
    cout << pcount;
    return;

}
int main(void){
    a();
    //b();
    //c();
    //d();
    //e();

}

Measured memory_bytes: 3636
/**
 * Created by hiramekun at 20:55 on 2019-09-07.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll n;
    cin >> n;
    vl p(n);
    unordered_map<ll, ll> mp;
    set<ll> s;
    rep(i, n) {
        cin >> p[i];
        mp[p[i]] = i;
        s.insert(p[i]);
    }

    set<ll> idx;
    ll ans = 0;
    while (!s.empty()) {
        ll now = *s.rbegin();
        s.erase(now);

        ll i = mp[now];
        vl l(2, -1), r(2, n);
        {
            auto itr = idx.lower_bound(i);
            rep(j, 2) { // r
                if (itr == idx.end()) break;
                r[j] = *itr;
                itr++;
            }
        }
        {
            auto itr = idx.lower_bound(i);
            rep(j, 2) { // l
                if (itr == idx.begin()) break;
                itr--;
                l[j] = *itr;
            }
        }

        ll l1 = i - l[0], l2 = l[0] - l[1];
        ll r1 = r[0] - i, r2 = r[1] - r[0];
        ans += (l1 * r2 + l2 * r1) * now;

        idx.insert(i);
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 9764
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

const int INF = 1e9 + 4;

struct Data {
    int node, cost, state;

    bool operator< (const Data &other) const {
        if(cost == other.cost) {
            if(node == other.node)
                return state < other.state;
            return node < other.node;
        }
        return cost < other.cost;
    }
};

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n + 1);
    for(int i = 1; i <= m; i ++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    int f, t;
    cin >> f >> t;

    vector<vector<int>> dp(n + 1, vector<int> (3, INF));
    dp[f][2] = 0;

    set<Data> s;
    s.insert({f, 0, 2});
    while(s.size()) {
        auto from = *s.begin();
        s.erase(from);

        //cout << from.node << " " << from.cost << " " << from.state << endl;

        int nextstate = (from.state + 1) % 3;
        for(auto it : g[from.node])
            if(dp[it][nextstate] > dp[from.node][from.state]) {
                s.erase({it, dp[it][nextstate], nextstate});

                dp[it][nextstate] = dp[from.node][from.state];
                if(nextstate == 2)
                    dp[it][nextstate] ++;
                s.insert({it, dp[it][nextstate], nextstate});
            }
    }

    if(dp[t][2] == INF)
        cout << -1;
    else
        cout << dp[t][2];

    return 0;
}


Measured memory_bytes: 12156
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Yahoo2019
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[][] paths = new int[3][];
            paths[0] = ReadInts();
            paths[1] = ReadInts();
            paths[2] = ReadInts();
            int[] cnts = new int[4];
            for(int i = 0; i < 3; i++)
            {
                cnts[paths[i][0] - 1]++;
                cnts[paths[i][1] - 1]++;
            }
            Array.Sort(cnts);
            if(cnts[0]==1&& cnts[1] == 1
                && cnts[2] == 2&& cnts[3] == 2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	string S, T;	cin >> S >> T;
	vector<int> n1,n2;
	sort(S.begin(), S.end());
	sort(T.begin(), T.end());
	n1.push_back(1);
	n2.push_back(1);
	for (int i = 1; i < S.size(); ++i) {
		if (S[i - 1] == S[i]) {
			n1[n1.size() - 1] += 1;
		}
		else {
			n1.push_back(1);
		}
		if (T[i - 1] == T[i]) {
			n2[n2.size() - 1]++;
		}
		else {
			n2.push_back(1);
		}
	}
	sort(n1.begin(), n1.end());
	sort(n2.begin(), n2.end());
	for (int i = 0; i < n1.size(); ++i) {
		if (n1[i] != n2[i]) {
			cout << "No" << endl;
			cin >> S;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <stdio.h>
 
int main (){
	int i;
	scanf ("%d", &i);
	
	int num1 = i / 100;
	int num2 = (i / 10) % 10;
	int num3 = i % 10;
	
	while (i > 0){
		if (num1 == 7) {
			printf ("Yes");
			break;
		}
		else if (num2 == 7){
			printf ("Yes");
			break;
		}
		else if (num3 == 7){
			printf ("Yes");
			break;
		}
		else{
			printf ("No");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1660
import Control.Applicative

fairness :: Int -> Int -> Int -> Int
fairness k a b = (fairness_sign k) * (a - b)
    where
        fairness_sign n = if n `mod` 2 == 0 then 1 else -1

main :: IO ()
main = do
    [a, b, c, k] <- map read . words <$> getLine
    putStrLn $ show $ fairness k a b


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b);
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c);
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n";
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define state tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define Z 505  //check the limits, man
#define N 100001
const ll INF = 1e10;
int main()
{
    int n,i,j,f;
    in(n);
    f=0;
    lp(i,1,n+1)
    {
        if(n%i==0)
        {
            j=(n/i);
            if(i<10 && j<10)
                f=1;
        }
    }
    if(f)
        printf("Yes");
    else
        printf("No");
}









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

namespace ABC060_C_Sentou
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int n = int.Parse(input[0]);
			long t = long.Parse(input[1]);
			input = Console.ReadLine().Split(' ');
			List<long> tList = new List<long>(n);
			for(int i = 0; i < n; i++)
				tList.Add(long.Parse(input[i]));

			long time = 0;
			int timeStartIndex = 0; //このインデックスからお湯が出続けている
			for (int i = 0; i < n - 1; i++)
			{
				//この場合途中でお湯が止まっている
				if (tList[i + 1] - tList[i] > t)
				{
					time += tList[i] - tList[timeStartIndex] + t;
					timeStartIndex = i + 1;
				}
			}
			time += tList[n - 1] - tList[timeStartIndex] + t;
			
			Console.WriteLine(time);
		}
	}
}

Measured memory_bytes: 26592
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int[] a=new int[n];
		int ans=0;
		for(int i=0;i<n;i++){
			a[i]=scan.nextInt();
		}
		
		Arrays.sort(a);
		
		for(int i=0;i<n;i++){
			if(a[i]>=n-i){
				ans=n-i;
				break;
			}
		}
		System.out.println(ans);
	}
}



Measured memory_bytes: 26380
#include <stdio.h>

int main(void) {
    int n, k, i, ans=1;
    scanf("%d", &n);
    scanf("%d", &k);
    
    for(i=1; i<=n; i++) {
        if(ans<=k)
            ans *= 2;
        else
            ans += k;
    }
    
    printf("%d", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N;
long long L[105];



int main(){
	cin >> N;
	rep(i, N) cin >> L[i];


	long long ans = 0;
	for(long long i = 0; i < N; i++) {
		for(long long j = i + 1; j < N; j++) {
			for(long long k = j + 1; k < N; k++) {
				if(L[i] == L[j] || L[j] == L[k] || L[i] == L[k]) continue;
				if(abs(L[i] - L[j]) < L[k] && L[k] < L[i] + L[j]) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3592
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define IOS ios_base :: sync_with_stdio(0)
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    vector < int > s;
    for (int i = 0;i < 3;++i)
    {
        int x;
        fi>>x;
        s.push_back(x);
    }
    sort(s.begin(),s.end());
    fo << (s[0] == 5 && s[1] == 5 && s[2] == 7 ? "YES":"NO") << '\n';
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,b,f,r,v,i,j,k;
	char ch;
	int s[4][3][10]={0,};
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		s[b-1][f-1][r-1]+=v;
	}
	for(i=0;i<4;i++){
		if(i!=0) printf("####################\n");
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",s[i][j][k]);
			}
			printf("\n");
		}

	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
 
int main(){
    ll n, k;
    cin >> n >> k;

    vector<int> h(n);
    rep(i,n) cin >> h[i];

    ll ans = 0;
    
    sort(h.begin(), h.end());
    rep(i,n-k) ans += (ll)h[i];
    
    cout << ans << endl;
   
    return 0;
    
}

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

int main () {
  int K;
  cin >> K;
  int odd = 0;
  int even = 0;
  for (int i = 1; i <= K; i++) {
    if (i % 2 == 0) {
      even++;  
    }    
    else {
      odd++;  
    }
  }  
  cout << even * odd << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
// #define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

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

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


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



signed main() {
    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    vector<int> a(m), b(m);

    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        uf.unite(a[i], b[i]);
    }

    set<int> s;

    for(int i = 1; i <= n; i++) {
        s.insert(uf.root(i));
    }

    cout << s.size() - 1 << endl;


    return 0;
}

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

MOD = 10**9 + 7
def main():
    S = input()
    N = len(S)-1

    if S[0] == '?':
        dp = [1,1,1,1,1,1,1,1,1,1,0,0,0]
    else:
        dp = [0,0,0,0,0,0,0,0,0,0,0,0,0]
        dp[int(S[0])] = 1

    for i in range(1,N):
        dppre = dp
        dp = [0] * 13

        if S[i] == '?':
            for j in range(13):
                for k in range(10):
                    dp[(j * 10 + k) % 13 ] += dppre[j]
        else:
            for j in range(13):
                dp[(j * 10 + int(S[i])) % 13 ] += dppre[j]

        for j in range(13):
            dp[j] %= MOD

    print(dp[5])
if __name__ == '__main__':
    main()

Measured memory_bytes: 42860
package main

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

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func numDigits(x int) int {
	var ans int
	for x > 0 {
		x /= 10
		ans++
	}
	return ans
}

func main() {
	input := bufio.NewReader(os.Stdin)

	var N int
	fmt.Fscanf(input, "%d\n", &N)
	var ans int
	for n := 1; n <= N; n++ {
		if numDigits(n)%2 == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640