akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i=0;i<N;i++)  cin >> P.at(i);

  int ans=0;
  int mi=1e9;
  for(int i=0;i<N;i++){
    if(P.at(i)<mi){
      ans++;
      mi=P.at(i);
    }
  }
  cout << ans << endl;

	return 0;
}


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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int k = 0;
    cin >> k;
    int a = 0, b = 0;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++) {
        if(i % k == 0) ans = 1; 
    }

    if(ans) cout << "OK\n";
    else cout << "NG\n";


    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=double;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vpll=vector<pll>;
using vvll=vector<vll>;
#define FOR(i,a,b) for(ll i=a;i<(ll)b;++i)
#define ROF(i,a,b) for(ll i=a;i>=(ll)b;--i)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define aa first
#define bb second
#define PB push_back
#define EQ(a,b) (fabs(a-b)<=(fabs(a+b)*EPS))

int main(){
  ios::sync_with_stdio(0);cout.tie(0);cin.tie(0);
  string s, t;
  cin >> s >> t;
  t = t + t;
  if (t.find(s) != string::npos)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <sstream> //stringstream
#include <cstring> // getline
#include <cmath>
#include <unordered_set>
#include <limits>
#include <unordered_map>

#define _CRT_SECURE_NO_WARNINGS
#define ll 				long long int
#define FOR(i, b, e)    for (ll i =(b)-((b)>(e));i!=(e)-((b)>(e));i += 1-2*((b)>(e)))
#define EPS  			1e-9
#define all(v) 			v.begin(),v.end()
#define X 				first 
#define Y 				second
#define IO 				std::ios_base::sync_with_stdio(0);cin.tie(NULL);
#define MAXI 			100005
#define endl 			'\n'
#define re   			return
#define mp				make_pair
#define NumofDigits(n)  ((int)log10(n)+1)
#define fixedpre(n)     fixed<<setprecision(n);

using namespace std;

ll pw(ll b, ll p) { if (!p) re 1; ll sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; re sq; }
ll gcd(ll a, ll b) { re(b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { re((a*b) / gcd(a, b)); }
bool cmp(double a, double b) { re abs(a - b)<EPS; }
bool isint(double a) { re cmp(a, round(a)); }

const double PI = acos(-1);
ll OO = 1e18 + 8;
int oo = 1e9 + 9;

//freopen("input.txt", "r", stdin);
//freopen ("output.txt","w",stdout);

int dx[6] = { 1, -1, 0, 0, 0, 0 }, dy[6] = { 0, 0, 1, -1, 0, 0 }, dz[6] = { 0, 0, 0, 0, 1, -1 };

ll n, W, dp[102][MAXI];
pair<ll, ll> arr[102];

ll maxVal(int idx = 0, ll sum = 0)
{
	if (idx > n) re 0;
	if (sum > W) re -OO;

	ll &ret = dp[idx][sum];
	if (~ret) re ret;
	ret = 0;

	ret = max(maxVal(idx + 1, sum), maxVal(idx + 1, sum + arr[idx].X) + arr[idx].Y);
	re ret;
}

int main()
{
	IO;
	cin >> n >> W;
	FOR(i, 0, n)
		cin >> arr[i].X >> arr[i].Y;
	memset(dp, -1, sizeof dp);

	cout << maxVal() << endl;
	re 0;
}

Measured memory_bytes: 80000
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut a:usize = read!();
    let mut b:usize = read!();
    if a<=b*2 {
        println!("0");
    }
    else {
        println!("{}",a-b*2)
    }
}

Measured memory_bytes: 2104
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

int a[25][25];
ll dp[1 << 21];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

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

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }

    dp[0] = 1;
    for(int S = 0; S < (1 << n); S++)
    {
        int temp = S;
        ll cnt = 0;
        while(temp)
        {
            if(temp % 2)    cnt++;
            temp /= 2;
        }
        for(int i = 1; i <= n; i++)
        {
            if(S & (1 << (i - 1)))  continue;
            dp[S + (1 << (i - 1))] = (dp[S + (1 << (i - 1))] + dp[S] * a[i][cnt + 1] % Mod) % Mod;
        }
    }

    printf("%lld\n", dp[(1 << n) - 1]);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


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

using namespace std;

int main() {
	int H, W;
	while (cin >> H >> W && (H || W)) {
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if ((i + j) % 2 == 0) {
					cout << '#';
				} else {
					cout << '.';
				}
			}
			cout << '\n';
		}
		cout << '\n';
	}
}


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
from itertools import permutations, product
def inpl(): return tuple(map(int, input().split()))
N, M, R = inpl()
inf = float("inf")
G = [[inf for _ in range(N+1)] for _ in range(N+1)]
D = inpl() # destination

for _ in range(M):
    a, b, c = inpl()
    G[a][b] = c
    G[b][a] = c

for n in range(N+1):
    G[n][n] = 0

for i ,j, k in product(range(1, N+1), repeat=3):
    G[j][k] = min(G[j][k], G[j][i] + G[i][k])

res = inf
for C in permutations(D, len(D)):
    res = min(res, sum([G[C[i]][C[i+1]] for i in range(len(D)-1)]))

print(res)

Measured memory_bytes: 67160
n,m=list(map(int,input().split()))
bit=[]
for i in range(2**n):
    h=[0]*n
    for j in range(n):
        if (i>>j & 1):
            h[j]=1
    bit.append(h)

check=[list(map(int,input().split(" "))) for i in range(m)] 
p=list(map(int,input().split()))

ans=0
sum=0
amari=[]
for k in range(len(bit)):
    for i in range(m):
        for j in range(1,len(check[i])):
            sum=sum+bit[k][check[i][j]-1]
        amari.append(sum%2)
        sum=0
    if p==amari:
      ans=ans+1
    amari=[]
    
        

print(ans)
        
            
        




Measured memory_bytes: 3188
from sys import stdin

A,B,C=[int(x) for x in stdin.readline().rstrip().split('/')]
if A <2019:
  print('Heisei')
elif A==2019:
  if B<=4:
  	print('Heisei')
  else:
    print('TBD')
else:
  print('TBD')

Measured memory_bytes: 3060
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a[10];
    int b;
    int c;
    int d;
    c=1;
    d=0;
    scanf("%d",&b);
    for(int i=1;i<=b;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=b;i++){
        if(a[c]<a[i]){
            c=i;
        }
    }
    for(int i=1;i<=b;i++){
        d=d+a[i];
    }
    d=d-a[c];
    if(d<=a[c]){
        printf("No");
    }
    else printf("Yes");
    return 0;
}



Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

dp = [0 for i in range(N)]

dp[1] = abs(H[1]-H[0])

for i in range(2,N):
  dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2]))

#print(dp)
print(dp[N-1])



Measured memory_bytes: 13928
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;

int n;
float h, t, A;

int main(){
    cin >> n;
    cin >> t >> A;
    int ans = -1;
    float minn = 99999;
    for (int i = 0; i < n; i++){
        cin >> h;
        if (minn > fabs(t - h * 0.006 - A)){
            minn = fabs(t - h * 0.006 - A);
            ans = i + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split('\n')
    const h = parseInt(input[0].split(' ')[0])
    const arr = input.slice(1, h + 1)

    arr.forEach(v => {
        console.log(v)
        console.log(v)
    })
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 9264
#include <stdio.h>
int main() {
    char S[10];
    scanf("%s", &S);
    if(S[0] != S[1]) {
        printf("Yes");
    }
    else if (S[1] != S[2]){
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n)                                                              \
    for (int64_t i = 0; i < (int64_t)(n); i++)                                 \
        ;
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;
using namespace std;
int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
# 入力の取得(空白を除く)
s = list(input().split())

# 処理
isPoor = False
if s[0] == s[1] and s[1] != s[2]:
  isPoor = True
if s[1] == s[2] and s[2] != s[0]:
    isPoor = True
if s[2] == s[0] and s[0] != s[1]:
	isPoor = True

if isPoor:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 38444
#include<bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int N = 1e6 + 6,mod = 998244353 ;

ll k = 1e18;

int dig(ll x){
        if(x == 0) return 0;
        int cnt = 0;
        while(x){
                x/=10;
                cnt++;
        }
        return cnt;
}

inline void test_case(){
        ll n;
        string s;
        cin >> n >> s;
        ll x = s[0]-'0';
        ll y = (s[2]-'0')*10+s[3]-'0';
        n = n*x + n*y/100;
        cout << n << endl;
}
int main(){
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

        int T = 1;
        //cin >> T;
        while(T--){
                test_case();
        }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

vector<int> solve(ll n, int alpha) {
	vector<int> res;
	if (n == 0) {
		return res;
	}

	if (n & 1) {
		res.pb(alpha);
		vector<int> add = solve((n - 1) / 2, alpha + 1);
		for (int i = 0; i < add.size() / 2; i++) {
			res.pb(add[i]);
		}
		res.pb(alpha);
		for (int i = add.size() / 2; i < add.size(); i++) {
			res.pb(add[i]);
		}
	}
	else {
		res.pb(alpha);
		vector<int> add = solve((n - 2) / 2, alpha + 2);
		for (int i = 0; i < add.size() / 2; i++) {
			res.pb(add[i]);
		}
		res.pb(alpha + 1);
		res.pb(alpha + 1);
		res.pb(alpha);
		for (int i = add.size() / 2; i < add.size(); i++) {
			res.pb(add[i]);
		}
	}
	return res;
}

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

	ll n;
	cin >> n;
	vector<int> ans = solve(n, 1);;

	cout << ans.size() << endl;
	for (int i : ans) {
		cout << i << ' ';
	}
	cout << endl;
}



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

int main() {
    int n;
    long long int ans = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            for(int k = 1; k <= n; ++k) {
                ans += __gcd(i, __gcd(j, k));
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

signed main() {
    string s;
    cin >> s;
    int ans = s.size();

    rep(i, 26) {
        int cnt = 0;
        int tmp = 0;

        rep(j, s.size()) {

            if(s[j] == i + 'a') {
                tmp = max(tmp, cnt);
                cnt = 0;
            }
            else {
                cnt++;
            }
        }

        tmp = max(tmp, cnt);

        ans = min(ans, tmp);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
string S[50];
int t[50];

int main() {
	cin >> N;
	REP(i, N) cin >> S[i] >> t[i];
	
	string X;
	cin >> X;
	
	int ans = 0;
	REP(i, N) if (S[i] == X) {
		FOR(j, i + 1, N) ans += t[j];
		break;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

namespace ABC096C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int h = input[0];
            int w = input[1];

            char[][] s = new char[h][];
            for(int i = 0; i < h; i++)
            {
                s[i] = Console.ReadLine().ToCharArray();
            }

            bool isYes = true;
            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    if(s[i][j] == '#')
                    {
                        if ((0 < i && s[i - 1][j] == '.')
                            && (i < h - 1 && s[i + 1][j] == '.')
                            && (0 < j && s[i][j - 1] == '.')
                            && (j < w - 1 && s[i][j + 1] == '.'))
                        {
                            isYes = false;
                            break;
                        }
                    }
                    
                }
            }

            if (isYes)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

bool isACGT(char c){
    if(c == 'A' || c == 'C'|| c == 'G'||c == 'T') {
        return true;
    }
    else return false;
}

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

    
    int max = -1;

    rep(i,s.length()) {
        int cnt = 0;
        while(true) {
            if( isACGT(s[i]) ) {
                cnt++;
                i++;         
            }
            else  break;
        }
        if(max < cnt) max = cnt;
    }
    
    printf("%d", max);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int INF = 1e9;

//?????§?????????
const int MAX_N = 510, MAX_K = 510;
const int MAX_V = 110;

struct edge{
    int to, cap, rev;
};

// vector<edge> G[MAX_N];
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

signed main(){
    int v, e;
    cin >> v >> e;
    rep(i, 0, e){
        int u, v, c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }
    cout << max_flow(0, v - 1) << endl;
}

Measured memory_bytes: 3208
N = [int(i) for i in list(input())]
dp = [[0]*2 for _ in range(len(N)+1)]
dp[0][1] = 1
for i in range(1, len(N)+1):
    n = N[i-1]
    dp[i][0] = min(dp[i-1][0]+n, dp[i-1][1]+10-n)
    n += 1
    dp[i][1] = min(dp[i-1][0]+n, dp[i-1][1]+10-n)
print(dp[-1][0])


Measured memory_bytes: 157568
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
//#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 50
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m, a[maxn][maxn], Ans, vis[maxn];
il void check() {
	rep(i, 1, n) {
		rep(j, 1, n) {
			if(a[i][j]==-1) continue;
			if(vis[i] == 1 && vis[j] == 1 && a[i][j] == 0) return;
			if(vis[i] == 1 && vis[j] == 0 && a[i][j] == 1) return; 
		}
	}
	int ans = 0;
	rep(i, 1, n) ans += vis[i];
	Ans = max(Ans, ans);
}
il void dfs(int u) {
	if(u == n + 1) return (void)(check());
	vis[u] = 0, dfs(u + 1), vis[u] = 1, dfs(u + 1);
}
int main() {
	n = read(), mem(a, -1);
	rep(i, 1, n) {
		m = read();
		rep(j, 1, m) {
			int x = read(), y = read();
			a[i][x] = y;
		}
	}
	dfs(1), cout << Ans;
	return 0;
}


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

int main(int argc, char *argv[])
{
  unsigned long n, r;
  std::cin >> n;
  std::vector<unsigned long> d(n);
  for (unsigned long i=0; i<n; ++i) {
    std::cin >> d[i];
  }
  std::sort(d.begin(), d.end());
  std::cout << d[n>>1] - d[(n>>1)-1] << std::endl;
  return 0;
}


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

using namespace std;
int main(void)
{
	int n;
	cin>>n;
	if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9)
		cout<<"hon"<<endl;
	else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8)
		cout<<"pon"<<endl;
	else
		cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3632
import math
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 0
r = a[-1] + 1

while r - l > 1:
    mid = (r + l) // 2
    cnt = 0
    for i in a:
        cnt += (i - 1) // mid
    if cnt <= K:
        r = mid
    else:
        l = mid
print(r)

Measured memory_bytes: 104260
#include "bits/stdc++.h"
using namespace std;

#define M 1046527
#define NIL (-1)
#define L 14
char H[M][L];

//??????????????°????????????
int getChar(char ch){
	if(ch=='A')return 1;
	else if(ch=='C')return 2;
	else if(ch=='G')return 3;
	else if(ch=='T')return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum=0,p=1,i;
	for (int i = 0; i < strlen(str); ++i) {
		sum+=p*(getChar(str[i]));
		p*=5;
	}
	return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
	long long key,i,h;
	key=getKey(str);
	for (int i = 0; ; ++i) {
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0)return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key=getKey(str);
	for (int i = 0; ; ++i) {
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}


int main() {
int i,n,h;
char str[L],com[9];
for (int i = 0; i < M; ++i) {H[i][0]='\0';}
scanf("%d",&n);
for (int i = 0; i < n; ++i) {
	scanf("%s %s",com,str);
	if(com[0]=='i'){
		insert(str);
	}else{
		if(find(str)){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
}
return 0;
}

Measured memory_bytes: 17436
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q, x, sum = 0, y;
    cin >> n;
    int a[100003];
    memset(a, 0, sizeof(a));
    while(n--){
    	cin >> x;
    	sum += x;
    	a[x]++;
    }
    cin >> q;
    while(q--){
    	cin >> x >> y;
    	sum += a[x] * (y - x);
    	a[y] += a[x];
    	a[x] = 0;
    	cout << sum << '\n';
    }
}

Measured memory_bytes: 4396
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>

#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=1;i<=(n);i++)
#define pb push_back
#define VSORT(S) sort(S.begin(), S.end());
using namespace std;

int main(){
	int sx,sy,tx,ty,i,j;
	string S;
	//char U,R,D,L;
	
	cin>>sx; cin>>sy; cin>>tx; cin>>ty;

	REP(i,ty-sy){
		S.pb('U');
	}

	REP(i,tx-sx){
		S.pb('R');
	}

	REP(i,ty-sy){
		S.pb('D');
	}

	REP(i,tx-sx+1){
		S.pb('L');
	}

	REP(i,ty-sy+1){
		S.pb('U');
	}

	REP(i,tx-sx+1){
		S.pb('R');
	}
	
	S.pb('D');
	S.pb('R');

	REP(i,ty-sy+1){
		S.pb('D');
	}

	REP(i,tx-sx+1){
		S.pb('L');
	}

	S.pb('U');

	cout<<S<<endl;
	return 0;
}


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

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
#define mod 1000000007
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}

int main()
{

    ll n,m,k;
    cin>>n>>m>>k;
    vi a(n),b(m);
    rep(i,0,n)cin>>a[i];
ll x;
    rep(i,0,m)cin>>b[i];
    map<ll,ll>c;
    c.insert({b[0],1});
    x=b[0];
    rep(i,1,m)x+=b[i],c.insert({x,i+1});
    ll ans=0;
    ll t=0;
    auto z=c.upper_bound(k);
    if(z!=c.begin()&&z!=c.end())ans=max(ans,z->second-1);
    else if(z==c.end())ans=m;

    rep(i,0,n)
    {   t+=a[i];
        ll r=k-t;
        if(r<0)break;
        //cout<<t<<endl;
        auto itr=c.upper_bound(r);



           if(itr!=c.begin()&&itr!=c.end()) ans=max(ans,i+1+(itr->second-1));
           else if(itr==c.end())ans=max(ans,i+1+m);
           else ans=max(ans,i+1);

         //  cout<<ans<<endl;

    }
    cout<<ans;

}


Measured memory_bytes: 18732
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] ans = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            ans[a[i]-1] = i;
        }

        for(int i=0; i<n; i++){
            System.out.print(ans[i] + 1 + " ");
        }
        System.out.println("");
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 41944
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
       mut p:[(i64,i64);n],
    }

    p.sort();
    for (i, v) in p.iter_mut().enumerate() {
        v.0 = (i + 1) as i64;
        swap(&mut v.0, &mut v.1);
    }
    p.sort();
    let mut l = BIT::<SUM>::new(n);
    let mut r = BIT::<SUM>::new(n);
    for i in 1..=n {
        r.add(i, &1);
    }
    let n = n as i64;
    let mut ans = n as i64 * mod_pow(2, n - 1, MOD);
    for (i, p) in p.iter().enumerate() {
        let i = i as i64;
        let y = p.1 as usize;
        r.add(y, &(-1i64));
        let a = l.sum(y);
        let b = (i - a as i64);
        let c = r.sum(y);
        let d = (n - 1 - i) - c;
        ans += mod_pow(2, n - 1, MOD)
            + mod_pow(2, a, MOD)
            + mod_pow(2, b, MOD)
            + mod_pow(2, c, MOD)
            + mod_pow(2, d, MOD)
            - mod_pow(2, a + b, MOD)
            - mod_pow(2, a + c, MOD)
            - mod_pow(2, b + d, MOD)
            - mod_pow(2, c + d, MOD)
            - 1;
        ans = (ans + MOD * 111) % MOD;
        l.add(y, &1i64);
    }
    println!("{}", ans);
}

const MOD: i64 = 998244353;
pub fn mod_pow(x: i64, n: i64, m: i64) -> i64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
pub trait Monoid {
    type T: Clone;
    fn id() -> Self::T;
    fn op(a: &Self::T, b: &Self::T) -> Self::T;
}
pub struct SUM {}
impl Monoid for SUM {
    type T = i64;
    fn id() -> Self::T {
        0
    }
    fn op(a: &Self::T, b: &Self::T) -> Self::T {
        *a + *b
    }
}
/// Generic Binary Indexed Tree
pub struct BIT<M: Monoid> {
    buf: Vec<M::T>,
}
impl<M: Monoid> BIT<M> {
    pub fn new(n: usize) -> Self {
        Self {
            buf: vec![M::id(); n + 1],
        }
    }
    pub fn sum(&self, i: usize) -> M::T {
        let mut i = i;
        let mut s = M::id();
        while i > 0 {
            s = M::op(&s, &self.buf[i]);
            i &= i - 1;
        }
        s
    }
    pub fn add(&mut self, i: usize, x: &M::T) {
        let mut i = i as i64;
        while i < self.buf.len() as i64 {
            let t = &mut self.buf[i as usize];
            *t = M::op(&t, x);
            i += i & -i;
        }
    }
}


Measured memory_bytes: 13420
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N,K = LI()
h = LI()
dp = [INF for _ in range(N)]
dp[0] = 0
for i in range(N-1):
    for j in range(i+1,i+K+1):
        if j < N:
            dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]))
print(dp[-1])

Measured memory_bytes: 57628
a, b = map(int, input().split())
if b != 0:
    c = input()
    l = c.split()
    cc = [int(s) for s in l]
    ccc =list(cc)
    for i in range(a,102):
        if i in ccc:
            continue
        else:
            x = i
            break
    for i in reversed(range(0, a)):
        if i in ccc:
            continue
        else:
            y = i
            break
    if x-a<a-y:
        print(x)
    else:
        print(y)
else:
    d = input()
    print(a)

Measured memory_bytes: 9204
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
	int N;
	cin >> N;
	long int B[100];

	for (int i = 0; i < N-1 ; ++i) {
		cin >> B[i];
		//cout << B[i] << endl;
	}

	int ans = 0;
	ans += B[0];

	for (int i = 1; i < N-1; ++i) {
		int v = min(B[i - 1], B[i]);
		//cout << "v = " << v << endl;
		ans += v;
	}
	ans += B[N - 2];
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

class UnionFind {
private:
  std::vector<int> data;

  bool isSame(int x, int y) {
    return find(x) == find(y);
  }

  bool doUnite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return (false);
    if (data[x] > data[y]) std::swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int getFind(int k) {
    if (data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int getSize(int k) {
    return (-data[find(k)]);
  }

public:
  UnionFind(int N) {
    data.resize(N, -1);
  }

  int same(int x, int y) { return isSame(x, y); }
  bool unite(int x, int y) { return doUnite(x, y); }
  int find(int k) { return getFind(k); }
  int size(int k) { return getSize(k); }
};

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  i64 N, M;
  std::cin >> N >> M;

  UnionFind uf(N);

  for (usize i = 0; i < M; i++) {
    u64 a, b;
    std::cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
  }

  i64 a = uf.size(0), b = uf.size(1);
  if (a < b) std::swap(a, b);
  a += N - a - b;

  auto c = [&](i64 x) {
    return x * (x - 1) / 2;
  };

  std::cout << c(a) + c(b) - M << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 640
/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.endaa(),0),pop_back()
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/
#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;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

const int N = 1e5+5;
vector<int>g[N];

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

    int n,m;
    cin>>n>>m;
    vector<int>h(n+1);
    for(int i=1;i<=n;i++)
        cin>>h[i];
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    int c=0;
    for(int i=1;i<=n;i++)
    {
        bool f=1;
        for(auto j:g[i])
        {
            if(h[j] >= h[i])
            {
                f=0;
                break;
            }
        }
        if(f==1)
            c++;
    }
    cout<<c;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 1; i <= (ll)(n); ++i)

int main() {

    ll MOD_NUM = 1000000000 + 7;

    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    rep(i, n) {
        ll tmp_pre = 0;
        ll tmp_post = 0;
        rep(j, n) {
            if(a[i] > a[j]) {
                if(i < j) tmp_post++;
                else tmp_pre++;
            }
        }

//        erep(j, k) {
//            ans += (k-j) * tmp_pre;
//            ans %= MOD_NUM;
//        }
//        rep(j, k) {
//            ans += (k-j) * tmp_post;
//            ans %= MOD_NUM;
//        }

        ll tmp = (k*(k-1)/2)%MOD_NUM;
        ans += tmp*tmp_pre%MOD_NUM;
        ans %= MOD_NUM;
        tmp = (k*(k+1)/2)%MOD_NUM;
        ans += tmp*tmp_post%MOD_NUM;
        ans %= MOD_NUM;

    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200000
#define ll long long
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
struct D{int c[2]; D(){} D(int a, int b){c[0]=a,c[1]=b;} inline D operator + (D x){return D(c[0]+x.c[0],c[1]+x.c[1]);}}f[MAXN+5];
inline bool operator < (D a, D b){return 1ll*a.c[1]*b.c[0] < 1ll*b.c[1]*a.c[0];} struct I{int i; I(int _i=0){i=_i;}}; set<I> S;
inline bool operator < (I a, I b){return f[a.i]<f[b.i]?true:f[b.i]<f[a.i]?false:a.i<b.i;} int fa[MAXN+5], _fa[MAXN+5], n; ll Ans;
inline int getf(int x){return x^_fa[x]?_fa[x]=getf(_fa[x]):x;} inline void Union(int x, int y){(x=getf(x))^(y=getf(y))?_fa[x]=y:0;}
int main()
{
	n = read(); for(rint i = 2; i <= n; fa[i++] = read()); for(rint i = 1; i <= n; ++f[i].c[read()], i++);
	_fa[1] = 1; for(rint i = 2; i <= n; _fa[i] = i, S.insert(i++));
	for(rint v, p; S.size(); Ans += 1ll*f[p].c[1]*f[v].c[0], f[p] = f[p]+f[v], p>1?S.insert(p),0:0, Union(v,p))
		v = S.begin()->i, S.erase(S.begin()), (p=getf(fa[v]))>1?S.erase(S.find(p)),0:0; printf("%lld\n",Ans); return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;


int main(void) {

  string s;
  cin >> s;
  int cnt = 0;
  for(int i=0; i<s.size(); i++){
    cnt += s[i]-'0';
  }
  cout << cnt << endl;


  return 0;
}

// EOF


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main(){FIN;
	ll h[2],m[2],k; cin>>h[0]>>m[0]>>h[1]>>m[1]>>k;	
	cout<<60*h[1]+m[1]-60*h[0]-m[0]-k;
	return 0;
}

Measured memory_bytes: 3636
import std.stdio, std.conv, std.string, std.range, std.array, std.algorithm;
import std.bigint;

const char[] c = ['I', 'V', 'X', 'L', 'C', 'D', 'M'];
const int[] a = [1, 5, 10, 50, 100, 500, 1000];

void main()
{
  while (true){
    string s = readln().chomp();
    if (s == "") break;
    int sum, l;
    for (int i = 0; i < s.length; i++){
      for (int j = 0; j < 7; j++){
        if (s[i] == c[j]){
          if (l >= a[j]){
            sum += a[j];
          } else {
            sum += a[j] - l * 2;
          }
          l = a[j];
        }
      }
    }
    writeln(sum);
  }
}

Measured memory_bytes: 2424
#include <iostream>

using namespace std;
int n,m,mat[103][103],v[10003],nr,poz;
int main()
{
    cin>>n>>m;
    cin>>nr;
    for(int i=1;i<=nr;++i) cin>>v[i];
    poz=1;
    for(int i=1;i<=n;++i)
    {
        if(i%2)
        {
            for(int j=1;j<=m;++j)
            {
                mat[i][j]=poz;
                --v[poz];
                if(!v[poz]) ++poz;
            }
        }
        else
        {
            for(int j=m;j>=1;--j)
            {
                mat[i][j]=poz;
                --v[poz];
                if(!v[poz]) ++poz;
            }
        }
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j) cout<<mat[i][j]<<' ';
        cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{	
	int n,h;cin >> n >> h;
	vector<int> a(n),b(n);
	rep(i,n)
	{
		cin>>a[i]>>b[i];
	}
	int amax=0;
	rep(i,n)
		amax=max(amax,a[i]);
	sort(ALL(b),greater<int>());

	int c=0;
	rep(i,n)
	{
		if(b[i]<amax)break;
		h-=b[i];
		c++;
		if(h<=0)
		{
			cout<<c<<endl;
			return 0;
		}
	}
	//cout<<h<<endl;
	c+=(h+(amax-1))/amax;

	cout<<c<<endl;
	return 0;
}

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

using namespace std;

int main(void){
  int N;
  cin >> N;
  long long A[200000];
  long long c[200000] = {0};
  for(int i = 0; i < N; i++){
    cin >> A[i];
    c[A[i]]++;
  }
  long long total = 0;
  for(int i = 0; i < 200000; i++){
    total += c[i] * (c[i] - 1) / 2;
  }
  for(int i = 0; i < N; i++){
    cout << total - c[A[i]] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
using namespace std;
int main()
{
	int n,tot=0,tmp;
	cin>>n;
	tmp=n;
	while(tmp!=0)
	{
		tot=tmp%10+tot;
		tmp=tmp/10;
	}
	if(n%tot==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import Data.Bool
import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.Set as S

main = C.interact $ put . sol . get

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines

put = C.pack . show

sol ([n,_]:es)= f 1 (S.fromList [2..n]) es

f _ vs [] = bool 0 1 $ S.null vs
f p vs es = sum [f c vs' es' | e <- cs, let c = g p e, let vs' = S.delete c vs]
  where
  (cs,es') = partition (\[u,v] -> u==p || v==p) es

g p [u,v]
  | u==p = v
  | v==p = u 

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
int n,m,a[maxn],x,ans,tmp,cnt;
int main() {
//	freopen("1.txt","r",stdin);
	read(n); read(m); n*=2;
	for (int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n/2;i++) tmp=max(tmp,(a[i]+a[n-i+1])%m);
	int pos=1;
	x=0;
	for (int i=n;i>=1;i--) {
		while (pos<=n&&a[pos]+a[i]<m) pos++;
		if (pos>n) break;
		//printf("%d %d\n",i,pos);
		x=max(x,pos-(n-i));
	}
	//printf("%d\n",x);
	//x=max(x,n-cnt*2+1);
	if (x%2==0) x++;
	if (x&&x<n) {
		for (int i=1;i<x;i++) ans=max(ans,(a[i]+a[x-i])%m);
		for (int i=x;i<=n;i++) ans=max(ans,(a[i]+a[n+x-i])%m);
	} else ans=m;
	printf("%d\n",min(ans,tmp));
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
int main()
{
    long int res;
    int K;
    int i, j, l;
    cin >> K;
    // 3つ同じ
    res = K * (K + 1) / 2;

    // 2つ同じ
    for (i = 2; i <= K; i++)
    {
        for (j = 1; j < i; j++)
        {

            res += 6 * gcd(i, j);
        }
    }

    for (i = 3; i <= K; i++)
    {
        for (j = 2; j < i; j++)
        {
            for (l = 1; l < j; l++)
            {
                res += 6 * gcd(gcd(i, j), l);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3644
import math
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

X = I()

for a in range(1,120):
 for b in range(-119,119):
   if a**5-b**5==X:
     print(a,b)
     exit()

Measured memory_bytes: 26864
function Main(input) {
	input = parseInt(input.trim());
  if(input % 2 == 1){
     console.log(Math.floor(input / 2) * Math.ceil(input / 2));
     }else{
     console.log(Math.pow(input / 2,2))  ;
     }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int n, k, a[100010], gcd;
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 1; i <= n; ++ i) cin >> a[i], gcd = __gcd(gcd, a[i]);
	bool flag = 0;
	for (int i = 1; i <= n; ++ i) if (a[i] >= k) {flag = 1; break ;}
	if (!flag || k % gcd) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265

#define MAX 100001


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

    int n;
    cin >> n;
    int tn = n;
    while (tn >= 0) {
        if (tn % 4 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        tn -= 7;
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

//   String nyuA=sc.nextLine();
  // String nyuB=sc.nextLine();
 
     String[] s=sc.nextLine().split(" ");
     String[] e=sc.nextLine().split(" ");

//int n=Integer.parseInt(nyuA);

int N=Integer.parseInt(s[0]);
int K=Integer.parseInt(s[1]);

ArrayList<Integer> list=new ArrayList<>();
for(String temp:e){
list.add(Integer.parseInt(temp));
}
Collections.sort(list);
int res=0;
for(int i=0;i<K;i++){
res+=list.get(list.size()-1-i);
}

System.out.println(res);

//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);


	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;
using P = pair<int, ll>;

int main()
{
  int n, k;
  cin >> n >> k;
  double result = 0.0;
  for(int i = 1; i <= n; i++)
  {
    int count = 0;
    for(int j = i; j < k; j = j * 2)
    {
      count++;
    }
    result += (1.0 / pow(2.0, count)) * (1.0 / n);
  }
  cout << fixed;
  cout << setprecision(10) << result;
}


Measured memory_bytes: 888
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    string s = inp1;
    string t = inp1;
    ll a = inp1, b = inp1;
    string u = inp1;

    (u == s ? a : b)--;
    cout << a << " " << b << endl;
    
}

Measured memory_bytes: 256