akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll a[200005],vis[200005];
vector<ll>fin,v;
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;
	cin >> n >> k;
	for(i=1;i<=n;i++)
		cin >> a[i];

	x=1;
	while(1)
	{
		if(vis[x])
			break;
		v.pb(x),vis[x]=1;
		x=a[x];
	}
	ll f=0;
	for(i=0;i<sz(v);i++)
	{
		if(v[i]==x)
			f=1;
		if(f)
			fin.pb(v[i]);
	}

	// for(auto it:v)
	// 	cout<<it<<" ";
	// cout<<endl;

	// cout<<k<<endl;

	if(k<sz(v))
		cout<<v[k]<<endl;
	else
	{
		k-=(sz(v)-1);
		// cout<<k<<" "<<sz(fin)<<endl;
		k%=(sz(fin));
		k--;
		if(k<0)
			k=sz(fin)-1;
		cout<<fin[k]<<endl;
	}
}

Measured memory_bytes: 10628
#include<stdio.h>

int main(void)
{
	char c;

	scanf("%c",&c);

	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
		printf("vowel\n");
	else
		printf("consonant\n");

	return 0;
}

Measured memory_bytes: 128
package main
import "fmt"
const mod int64 = 1000000007
func main() {
  var l string
  fmt.Scan(&l)
  var s,d int64 = 2,1
  for i:=1;i<len(l);i++ {
    if l[i:i+1] == "1" {
      s,d = (2*s)%mod,(3*d+s)%mod
    } else {
      d = (3*d)%mod
    }
  }
  fmt.Println((s+d)%mod)
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>> G(H + 2, vector<int>(W + 2, -1));
	int white_num = 0;
 	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			char a;
			cin >> a;
			if (a == '.') {
				G[i][j] = 1;
				white_num++;
			}
		}
	}

	if (G[1][1] == -1 || G[H][W] == -1) {
		cout << -1 << endl;
		return 0;
	}


	queue<pair<int, int>> que;
	vector<vector<int>> dist(H + 2, vector<int>(W + 2, -1));
	que.push(make_pair(1, 1));
	dist[1][1] = 1;

	while (!que.empty()) {
		pair<int, int> p =que.front();
		que.pop();
		int _x = p.first;
		int _y = p.second;
		if (G[_x + 1][_y] == 1 && dist[_x + 1][_y] == -1) {
			que.push(make_pair(_x + 1, _y));
			dist[_x + 1][_y] = dist[_x][_y] + 1;
		}
		if (G[_x - 1][_y] == 1 && dist[_x - 1][_y] == -1) {
			que.push(make_pair(_x - 1, _y));
			dist[_x - 1][_y] = dist[_x][_y] + 1;
		}
		int u = G[_x][_y + 1];
		if (G[_x][_y + 1] == 1 && dist[_x][_y+1] == -1) {
			que.push(make_pair(_x, _y + 1));
			dist[_x][_y + 1] = dist[_x][_y] + 1;
		}
		if (G[_x][_y - 1] == 1 && dist[_x][_y-1] == -1) {
			que.push(make_pair(_x, _y - 1));
			dist[_x][_y - 1] = dist[_x][_y] + 1;
		}
	}
	int temp = dist[H][W];
	if (temp == -1) {
		cout << -1 << endl;
		return 0;
	}
	int ans = white_num - temp;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#if 0
date +%Y.%m.%d

假设所有点都是关键点，记 f(u, k) 表示集合 {x | dis(u, x) < k} 。
问题相当于求所有本质不同的 f(u, k) 数量。

点的全集比较特殊，单独考虑。
对于点 u ，设其作为根时的树深度为 d ，那么满足 k < d 的 f(u, k) 都可以被计入答案。
但是这样会算重，因为存在 f(u, k1) = f(v, k2) 且 u != v 。
对于每个可行的点集，能表示出来的 f(u, k) 中一定存在一个 k 最小的唯一的 u ，
如果仅在 k 最小的 u 上统计该点集就不会算重，

考虑每个 f(u, k) 的 k 需要满足什么条件才能满足上述条件，
设 u 的深度最大的儿子为 v ，如果 f(v, k - 1) = f(u, k) 那么 k 不可行，
也就是说 k 还需要满足 k - 1 <= d2 ，其中 d2 是除去 v 子树后的树深度。
综上，答案为 1 + sum(min(d - 1, d2 + 1)) 。

现在考虑存在非关键点的情况。
一个 naive 的想法是只对关键点统计上述贡献，
但可能有一个合法点集应在 f(u, k) 处被统计，而 u 现在成了非关键点，这样就漏记了。

考虑非关键点 u 作为根时，k 要额外满足什么条件才能统计 f(u, k) 。
事实上当 f(u, k) 包含了任一包含关键点的 v 的子树时才能被统计，其中 v 是 u 的儿子。
也就是说需要满足 k >= bd ，其中 bd 是所有包含关键点的 v 子树的深度的最小值。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 200005;
int head[maxn], nxt[maxn << 1], to[maxn << 1], hp = 1;
char s[maxn];

inline void add(int u, int v) {
	nxt[++ hp] = head[u];
	head[u] = hp;
	to[hp] = v;
}

struct Data {
	int d, d2, bd, c;

	inline void update(Data an) {
		if(an.d + 1 > d) {
			d2 = d;
			d = an.d + 1;
		} else
			d2 = std::max(d2, an.d + 1);
		if(an.c)
			bd = std::min(bd, an.d);
		c += an.c;
	}

	inline void undo(Data an) { // only need "d" and "c" to update
		if(an.d + 1 == d)
			d = d2;
		c -= an.c;
	}
};
Data f[maxn];

void dfs1(int u, int fa) {
	f[u] = {1, 1, maxn, s[u] == '1'};

	for(int i = head[u]; i; i = nxt[i]) {
		int v = to[i];
		if(v != fa) {
			dfs1(v, u);
			f[u].update(f[v]);
		}
	}

	/* debug("%d : %d %d %d\n", u, f[u].d, f[u].d2, f[u].bd); */
}

ll ans = 1;
void dfs2(int u, int fa, Data ff) {
	Data g = f[u];
	g.update(ff);

	int L = s[u] == '1' ? 1 : g.bd + 1;
	int R = std::min(g.d - 1, g.d2 + 1);
	if(L <= R) ans += R - L + 1;

/* 	debug("%d : %d %d %d\n", u, g.d, g.d2, g.bd); */
/* 	debug("from %d %d\n", ff.d, ff.bd); */
/* 	debug("ans %d-%d\n", L, R); */

	for(int i = head[u]; i; i = nxt[i]) {
		int v = to[i];
		if(v != fa) {
			Data vff = g;
			vff.undo(f[v]);
			dfs2(v, u, vff);
		}
	}
}

int main() {
	int n = read;
	for(int i = 1; i < n; i ++) {
		int u = read, v = read;
		add(u, v);
		add(v, u);
	}
	scanf("%s", s + 1);

	dfs1(1, 0);
	dfs2(1, 0, {0, 0, maxn, 0});

	printf("%lld\n", ans);
}


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

using namespace std;

typedef long long ll;

const ll MAX_N = 1e5+10;

int main(int argc, char const *argv[])
{
    ll n, q;
    string s;
    cin >> n >> q;
    cin >> s;
    ll dp[MAX_N]={0};
    vector<ll> vec;
    dp[0] = 0;
    for (ll i = 1; i < s.size(); ++i) {
        dp[i] += dp[i-1];
        if (s[i]=='C' && s[i-1]=='A') dp[i]++;
    }
    for (ll i = 0; i < q; ++i) {
        ll l, r;
        scanf("%lld %lld", &l, &r);
        l--;
        r--;
        ll res = 0;
        res += dp[r] - dp[l];
        vec.emplace_back(res);
    }

    for (int i = 0; i < vec.size(); ++i) {
        printf("%lld\n", vec[i]);
    }

    return 0;
}

Measured memory_bytes: 2676
N = int(input())

X = [list(map(int, input().split())) for i in range(N)]

X.sort(key = lambda item: item[2] ,reverse = True)

for i in range(101):
    for j in range(101):
        h = X[0][2] + abs(X[0][0] - i) + abs(X[0][1] - j)

        ok = True
        for k in range(N):
            if X[k][2] != max((h - abs(X[k][0] - i) - abs(X[k][1] - j)), 0):
                ok = False

        if ok:
            print(i, j, h)
            exit()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int x,a,b;
    cin >>x>>a>>b;
    string ans;
    if(a>=b) ans = "delicious";
    else if(x>=(b-a)) ans = "safe";
    else ans = "dangerous";
    cout << ans << endl;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    if(s.size()==a+b+1){
        for(int i=0;i<s.size();i++){
            if((s[i]=='-' && i!=a)||(s[i]!='-' && i==a)){
                cout<<"No"<<endl;
                break;
            }
            if(i==s.size()-1) cout<<"Yes"<<endl;
        }
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin>>a>>b>>c;
    
    if(a > b) swap (a, b);
    if(b > c) swap (b,c);
    if(a > b) swap (a, b);
    cout<<a<<" "<<b<<" "<<c<<endl;

}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <complex>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,a) FOR(i,0,a)
#define X real() 
#define Y imag()
using namespace std;
typedef long long ll;
typedef int useType;
typedef pair<useType,useType> pr;
typedef vector<useType> VI;
const int INF=1<<30;
const int SIZE=1<<19;
const int p=100000;
int DP[2][2][2][SIZE];//times beforeJ goodFlag true or false
char maps[22][22]={};
int main(){
	int n,m;
	string s;
	cin >> m >> n;
	REP(i,m){
		cin >> s;
		REP(j,n)
			maps[i][j]=s[j];

	}
	DP[0][0][0][0]=1;
	int now=1;
	REP(i,m)
		REP(j,n){
			if(maps[i][j]=='J' || maps[i][j]=='?')
				REP(gF,2)
					REP(bJ,2)
						REP(k,SIZE)
							DP[now][1][gF][k&(~(1<<j))]+=DP[now^1][bJ][gF][k]%p;
			if(maps[i][j]=='O' || maps[i][j]=='?')
				REP(gF,2)
					REP(bJ,2)
						REP(k,SIZE)
							if(bJ && j) 
								DP[now][0][gF][(k&(~(1<<j)))|(1<<(j-1))]+=DP[now^1][bJ][gF][k]%p;
							else
								DP[now][0][gF][k&(~(1<<j))]+=DP[now^1][bJ][gF][k]%p;
			if(maps[i][j]=='I' || maps[i][j]=='?')
				REP(gF,2)
					REP(bJ,2)
						REP(k,SIZE)
							{
							//	if(DP[now^1][bJ][gF][k])
							//		cout << bJ << "  " << gF << " " << k <<" " << DP[now^1][bJ][gF][k]<< endl;
							DP[now][0][((1<<j)&k) || gF][k&(~(1<<j))]+=DP[now^1][bJ][gF][k]%p;
							}
						
			now ^=1;
			REP(j,2)
				REP(k,2)
					REP(l,SIZE)
						DP[now][j][k][l]=0;

	
		}
	int sum=0;
	now^=1;
	REP(bJ,2)
		REP(k,SIZE)
			sum=(sum+DP[now][bJ][1][k])%p;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 17592
from collections import defaultdict, deque
d = defaultdict(list)
n = int(input())
for i in range(n-1):
    u, v = map(int, input().split())
    u-=1
    v-=1
    d[u].append(v)
    d[v].append(u)
c = list(map(int, input().split()))
c.sort(reverse = True)
vis = [0 for i in range(n)]
q = deque([])
q.append(0)
vis[0] = c[0]
ind = 1
while(q):
    f = q.popleft()
    for i in d[f]:
        if not vis[i]:
            vis[i] = c[ind]
            ind+=1
            q.append(i)
print(sum(vis) - c[0])
print(*vis)

Measured memory_bytes: 6472
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, j, k, sum;
	scanf("%d", &n);
	int arr[n];
	for(int i=0; i<n; i++)
		scanf("%d", arr+i);
	for(j=0, k=n-1; ; )
	{
		if(arr[j]==arr[k])
		{
			sum=0;
			j++;
			k--;
		}
		else if(arr[j]<arr[k])
		{
			arr[k]=arr[k]-arr[j];
			sum=arr[k];
			j++;
		}
		else
		{
			arr[j]=arr[j]-arr[k];
			sum=arr[j];
			k--;
		}
		if(j>=k)
			break;
	}
	printf("%d\n", sum);
	return 0;
}

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

int main() {
    int q;
    std::cin >> q;

    std::multimap<std::string, int> M;
    for (int i = 0; i < q; i++) {
        int op;
        std::string key;
        std::cin >> op;
        
        if (op == 0) {
            int x;
            std::cin >> key >> x;
            M.insert(std::make_pair(key, x));
        } else if (op == 1) {
            std::cin >> key;
            auto range = M.equal_range(key);
            for (auto it = range.first; it != range.second; it++) {
                std::cout << it->second << std::endl;
            }
        } else if (op == 2) {
            std::cin >> key;
            M.erase(key);
        } else if (op == 3) {
            std::string L, R;
            std::cin >> L >> R;
            auto begin = M.lower_bound(L);
            auto end = M.upper_bound(R);
            for (auto it = begin; it != end; it++) {
                std::cout << it->first << " " << it->second << std::endl;
            }
        }
    }
}



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

if N<=2:
    print(0)
    exit()
count=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            a=L[i]
            b=L[j]
            c=L[k]
            if a!=b and b!=c and c!=a:
                if a+b>c and b+c>a and c+a>b:
                    count+=1

print(count)

Measured memory_bytes: 73660
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
using namespace std;
typedef pair<int, int> P;

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

int main(void) {
	string s, t, u = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", x;
	cin >> s >> t;
	x = s;
	if (s.length()<t.length()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	if (s.length() == t.length()) {
		for (int i = 0;i < s.length();i++) {
			if (s[i] == '?')s[i] = t[i];
			else {
				if (s[i] != t[i]) {
					cout << "UNRESTORABLE"<< endl;
					return 0;
				}
			}
		}
	}
	bool flag = false, can = false;
	for (int i = 0;i <= s.length() - t.length();i++) {
		flag = false;
		x = s;
		for (int j = i;j < t.length() + i;j++) {
			if (s[j] != '?') {
				if (s[j] != t[j-i]) {
					flag = true;
				}
			}
		}
		if (!flag) {
			for (int j = i;j < t.length() + i;j++) {
				if (s[j] == '?')x[j] = t[j-i];
			}
			for (int i = 0;i < s.length();i++) {
				if ((s[i] == '?')&&(x[i]=='?'))x[i] = 'a';
			}
			can = true;
			if (x < u)u = x;
		}
	}
	if (can)cout << u << endl;
	else cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int A = sc.nextInt(), B = sc.nextInt();
        if (A == B) {
            System.out.println("Draw");
        } else if (A == 1 || (B != 1 && A > B)) {
            System.out.println("Alice");
        } else {
            System.out.println("Bob");
        }
    }
}


Measured memory_bytes: 9800
/*
_____________________$$o____________________o$$$$$o__
___________________o$o_$$o____oo$$$$$$$oo______o$$$$o
______________$o________o$$$$$o___oo$$$$$$$o______$$$
______________$$$ooo________o$$$$o______o$$$$$o_____o
____________oo_____oo_____oo___o$$$$$______$$$$$$____
_________ooooo___$$o_$___oooooo___o$$$$o__o__o$$$$___
_______ooo__ooo$$$$o_$$ooooooooooo__o$$$o__oo_oo$$$o_
______oo_o$$o_$$_o$o_o$o__oooooooooo__o$$$o_oo__o$$$o
____oooooo$$$$o___oo__$$o_ooo_oooooooo__o$$o_ooo_o$$$
___ooooooo__o___oooo__$$ooooo$_oooooooo__o$$__ooo_$$$
_$$o_ooooo___o$$$$$o__o$o__o_$o__oooooooo_o$$o_oo__$$
_$$$o_ooo_________o$$_$$o____$$o_ooooooooo_$$$o_oo_$$
__oo________o$$o____o_$$o____o$ooooooooooo_o$$o_oo_o$
___o$$$$$$$$$$$$$o___$$$o____$$o_oooooooooo_$$$o_o_o$
________o__oo$$$$$o__$$$o____$$o____oooooo__$$$o_o_o$
_________$$$$$$$$$o__$$_____$$$o___________$$$oooooo_
__________o$$$$$$$o_________$$___________o$o___oooooo
___________o$$$$o_______________ooooo__oo$__ooo__oooo
________________________________ooo_$$oo___oooo$o____
________________________________oooo_$$$$$o___oo$$$o_
________________________________ooooo_o$$$$$o_____$$$
________________________________oooooo_o$$$$$$ooo___o
________________________________ooooooo__o$$$$$o_____
*/
#include<bits/stdc++.h>
#define ll long long
#define ft first
#define sd second
#define HageBaIO_KPOCCbI int LOL;scanf("%d", &LOL);for(int i = 0; i < LOL; i++)
#define Terrorist ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
//BY |3 |<
const int dx[] = {1, 0, -1,  0};
const int dy[] = {0, 1,  0, -1};
//Where I am?
const ll N = 1e5 + 5;
const ll NN = 1e3 + 3;
const ll MOD = (1e9 + 7);
const ll MOD1 = 998244353;
const double PI = 3.14159265;
const int INF32 = 2e9;
const ll INF64 = 2e18;
//Don`t believe!!!//
ll n, ans;
void KEK(){
	cin>>n;
	ans += n / 500 * 1000;
	n %= 500;
	ans += (n / 5) * 5;
	cout<<ans;
}
int main(){
	Terrorist
	//HageBaIO_KPOCCbI
	KEK();
	return 0;
}
//TAUMAC, 9| BbIWEJI 3A TObOU!!!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

public class Main {
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        int n = sc.nextInt();
        int ps[] = new int[n];
        for (int i = 0; i < n; i++) {
            ps[i] = sc.nextInt();
        }
        Arrays.sort(ps);
        int ans = Arrays.stream(ps).sum();
        int count = 0;
        for (int i = 0; i < n && ans % 10 == 0; i++) {
            if (ps[i] % 10 == 0) {
                count++;
                continue;
            }
            ans -= ps[i];
        }
        if (count == n) {
            System.out.println(0);
        }
        else
            System.out.println(ans);
    }
}


Measured memory_bytes: 28748
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
int main()
{
    // 文字列の入力
    long long N;
	cin >> N;
	
	string name = "";
	
	long long rest = N;
	char alpha[2] = {0};
	
	if(rest > 26) N--; 
	
	while (rest > 26) {
		long long surplus = (rest - 1) % 26;
		rest = (rest - surplus) / 26;
		
		//name = (char)(surplus + 'a' - 1) + name;
		alpha[0] = (char)(surplus + 'a');
		name.insert(0, alpha);
	} 

	alpha[0] = (char)(rest + 'a' - 1);
	name.insert(0, alpha);
	
	cout << name << endl;
	
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1000000007
#define maxn 1000000009
signed main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    priority_queue<pair<int, int>> CB;
    for (int i = 0; i < M; i++)
    {
        int b, c;
        cin >> b >> c;
        CB.push(make_pair(c, b));
    }
    bool lavel = true;
    for (int i = 0; i < N && lavel && !CB.empty(); i++)
    {
        pair<int, int> p = CB.top();
        CB.pop();
        for (; i < N; i++)
        {
            if (A[i] > p.first)
            {
                lavel = false;
                break;
            }
            A[i] = p.first;
            p.second--;
            if (p.second == 0)
                break;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;
  cin >> a >> b;
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  if(s==a) n--;
  if(s==b) m--;
  cout << n << ' ' << m << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll high[100005];
ll mid[100005];
ll low[100005];
ll psum[100005];
ll ret = 0;
int main(){
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>high[i];
	for(int i=1; i<=n; i++) cin>>mid[i];
	for(int i=1; i<=n; i++) cin>>low[i];
	sort(high+1,high+n+1);
	sort(mid+1,mid+n+1);
	sort(low+1,low+n+1);
	for(int i=1; i<=n; i++){
		psum[i] = (n+1)-(upper_bound(low+1,low+n+1,mid[i])-low);
	}
	for(int i=n-1; i>=1; i--){
		psum[i]+=psum[i+1];
	}
	for(int i=1; i<=n; i++){
		int index = upper_bound(mid+1,mid+n+1,high[i])-mid;
		ret+=psum[index];
	}
	cout<<ret;
}

Measured memory_bytes: 6740
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re
import heapq


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    n = ii()
    d = li()

    if not  d[0] == 0:
        print(0)
        exit()
    else:
        cnt = [0 for i in range(n+1)]
        for i in d:
            cnt[i]+=1
        if not cnt[0] == 1:
            print(0)
            exit()
        for i in range(1,n):
            if cnt[i-1] == 0 and (not cnt[i] ==0):
                print(0)
                exit()
        ans = 1
        for i in range(1,n):
            if cnt[i] == 0:
                break
            
            ans = (ans*(cnt[i-1]**cnt[i]))%998244353

        print(ans)


main()


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


public class Main {
	
	boolean[] getPrime(final int n){
		boolean[] list = new boolean[n+1];
		for(int i=2; i<=n; ++i){ list[i] = true; }
		for(int i=2; i*i<=n; ++i){
			if(list[i]){
				for(int j=i*2; j<=n; j+=i){
					list[j] = false;
				}
			}
		}
		return list;
	}
	
	int countPrime(final boolean[] list){
		int c=0;
		for(int i=1; i<list.length; ++i){
			if(list[i])++c;
		}
		return c;
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			final int n = sc.nextInt();
			System.out.println(countPrime(getPrime(n)));
		}
	}
	
	public static void main(String[] args) {
		new Main().io();
	}
	
	void debug(Object... os){
		System.out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 16000
#include <stdio.h>
#include <string.h>

char input[10001];

int main(void)
{
    int i, len, j, joi = 0, ioi = 0;
    while (scanf("%s",input) != EOF) {
        joi = 0;
        ioi = 0;
        len = strlen(input);
        for (i = 0; i < len-2; i++) {
            if (strncmp("JOI", &input[i], 3) == 0) {
                joi++;
            }
        }
        for (i = 0; i < len-2; i++) {
            if (strncmp("IOI", &input[i], 3) == 0) {
                ioi++;
            }
        }
        printf("%d\n%d\n",joi, ioi);
    }
    return 0;
}

Measured memory_bytes: 548
N, C = map(int, input().split())

tt = [[0] * (10 ** 5 + 1) for _ in range(30)]
for _ in range(N):
    s, t, c = map(int, input().split())
    ttc = tt[c - 1]
    for i in range(s - 1, t):
        ttc[i] = 1

ct = [0] * (10 ** 5 + 1)
for i in range(30):
    tti = tt[i]
    for j in range(10 ** 5 + 1):
        ct[j] += tti[j]

print(max(ct))


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

class BIT{
public:
  typedef long long ll;
  ll n;
  vector<ll> bit;
  BIT():n(-1){};
  BIT(ll n_){
    n=1;
    while(n < n_+2) n *= 2;
    bit.resize(n+1, 0);
  }
  
  //[0, i]までの総和を得る
  ll sum(ll i){
    assert( i >= 0 && i <= n );
    i++;
    
    ll s=0;
    while(i>0){
      s = (s + bit[i]);
      i -= i & -i;
    }
    return s;
  }

  //i番目の要素にx加算(0 オリジン)
  void add(ll i,ll x){
    assert( i >= 0 && i <= n );
    i+=2;
    
    while(i <= n){
      bit[i] = (bit[i] + x);
      i += i & -i;
    }
  }
  
  ll sum(int l,int r){ //[l, r) 0オリジン
    assert(l <= r);
    assert( 0 <= l && l <= n);
    assert( 0 <= r && r <= n);
    return sum(r) - sum(l);
  }
};

int N, W[2005], B[2005];
int memo[2005][2005], used[2005][2005];

int dfs(int wnum, int bnum, BIT &bitw, BIT &bitb){
  
  if( used[wnum][bnum] ) return memo[wnum][bnum];
  
  used[wnum][bnum] = 1;
  
  if( wnum == N + 1 && bnum == N + 1 ) return 0;
  
  int res = 1e9;
  
  if( wnum <= N ){
    int cnt = bitw.sum( 0, W[wnum] ) + bitb.sum( 0, W[wnum] );
    bitw.add( W[wnum], -1 );
    res = min( res, cnt + dfs( wnum + 1, bnum, bitw, bitb ) );
    bitw.add( W[wnum], 1 );
  }

  if( bnum <= N ){
    int cnt = bitb.sum( 0, B[bnum] ) + bitw.sum( 0, B[bnum] );
    bitb.add( B[bnum], -1 );
    res = min( res, cnt + dfs( wnum, bnum + 1, bitw, bitb ) );
    bitb.add( B[bnum], 1 );
  }
  
  return memo[wnum][bnum] = res;
}

signed main(){
  
  cin>>N;
  
  BIT bitw(2*N), bitb(2*N);
  
  for(int i=0;i<2*N;i++){
    
    char c;
    int a;
    
    cin>>c>>a;
    
    if( c == 'W' ){
      W[a] = i;
      bitw.add( i, 1 );
    }else{
      B[a] = i;
      bitb.add( i, 1 );
    }
    
  }
  
  cout << dfs( 1, 1, bitw, bitb ) << endl;
  
  return 0;
}


Measured memory_bytes: 63488
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        double reversedSum = 0;
        for (int i = 0; i < n; i++) {
            reversedSum += 1.0 / a[i];
        }
        System.out.println(1.0 / reversedSum);
    }

}


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

using ll = long long;

#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SQR(x) (x) * (x)

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d){
        cout << "Yes";
    }
    else if(abs(a - b) <= d && abs(b - c) <= d){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
n=input()
p=list(map(int, input().strip().split()))
k=0
kai=0
for i in range(1,int(n)-1):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        k=k+1
    elif p[i-1]>p[i] and p[i]>p[i+1]:
        k=k+1
print(k)

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

int main()
{
    int N;
    cin >> N;

    vector<int> p(N+1);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        p[i]--;
    }

    int moves = 0;
    for (int i = 0; i < N; i++)
        if (p[i] == i)
        {
            swap(p[i], p[i+1]);
            moves++;
        }

    cout << moves << endl;
}


Measured memory_bytes: 640
import random

random.seed(1)

def calc_point(point_list, interval, choice):
    point = 0

    for i, day in enumerate(interval):
        point -= c[i] * day

    point += point_list[choice - 1]

    return point

d = int(input())

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

s = []

for _ in range(d):
    temp = list(map(int,input().split()))

    s.append(temp)

choices = []

for i in range(d):
    choices.append(s[i].index(max(s[i])) + 1)

interval = [0] * 26
result = 0

for i in range(d):
    choice = choices[i]

    interval = [x + 1 for x in interval]

    interval[choice - 1] = 0

    result += calc_point(s[i], interval, choice)

for _ in range(10000):
    temp_choices = choices.copy()
    temp_result = 0

    temp_choices[random.randint(0, d - 1)] = random.randint(1, 26)

    interval = [0] * 26
    
    for i in range(d):
        choice = temp_choices[i]

        interval = [x + 1 for x in interval]

        interval[choice - 1] = 0

        temp_result += calc_point(s[i], interval, choice)

    if temp_result > result:
        choices = temp_choices
        result = temp_result

for choice in choices:
    print(choice)


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


public class hello
{
    public static void Main()
    {
        var lst = new HashSet<string>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            switch (line[0])
            {
                case "insert":
                    lst.Add(line[1]);
                    break;
                case "find":
                    if (lst.Contains(line[1]) )Console.WriteLine("yes");
                    else Console.WriteLine("no");
                    break;
            }
        }
    }
}

Measured memory_bytes: 39824
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import Data.Int

main :: IO ()
main = putStrLn =<< show . solve <$> readLn

solve :: Int64 -> Int64
solve x
    | q == 0 = p * 2
    | q <= 6 = p * 2 + 1
    | otherwise = p * 2 + 2
    where (p, q) = x `divMod` 11


Measured memory_bytes: 508
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;

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

	cin >> W >> H >> N;
	int sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	vector<vector<int>>tate(H + 2, vector<int>(W + 2));
	vector<vector<int>>yoko(H + 2, vector<int>(W + 2));
	for (int i = 0; i < N; i++) {
		int y, x;
		cin >> x >> y;
		cin >> K;
		string s;
		cin >> s;
		while (K--) {
			for (auto j : s) {
//				cout << y << " " << x << endl;
				if (j == 'R') {
					if (x + 1 != W) {
						tate[y][x+1] ++;
						x++;
					}
				}
				else if (j == 'L') {
					if (x) {
						x--;
						tate[y][x+1]++;
					}
				}
				else if (j == 'D') {
					if (y + 1 != H) {
						yoko[y+1][x]++;
						y++;
					}
				}
				else {
					if (y) {
						y--;
						yoko[y+1][x]++;
					}
				}
			}
		}
	}
	vector<vector<int>>dis(H + 2, vector<int>(W + 2, MOD));
	dis[sy][sx] = 0;
	priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>>PQ;
	PQ.push({ 0,{sy,sx} });
	while (!PQ.empty()) {
		int c = PQ.top().first;
	//	cout << c << endl;
		int cy, cx;
		tie(cy, cx) = PQ.top().second;
//		cout << cy << " " << cx << endl;
		PQ.pop();
		if (cy <= H) {
			if (dis[cy + 1][cx] > c + tate[cy][cx]) {
				dis[cy + 1][cx] = c + tate[cy][cx];
				PQ.push({ dis[cy + 1][cx],{cy + 1,cx} });
			}
		}
		if (cy > 0) {
			if (dis[cy - 1][cx] > c + tate[cy - 1][cx]) {
				dis[cy - 1][cx] = c + tate[cy - 1][cx];
				PQ.push({ dis[cy - 1][cx],{ cy - 1,cx } });
			}
		}
		if (cx <= W) {
			if (dis[cy][cx + 1] > c + yoko[cy][cx]) {
				dis[cy][cx + 1] = c + yoko[cy][cx];
				PQ.push({ dis[cy][cx + 1],{cy,cx + 1} });
			}
		}
		if (cx > 0) {
			if (dis[cy][cx - 1] > c + yoko[cy][cx - 1]) {
				dis[cy][cx - 1] = c + yoko[cy][cx - 1];
				PQ.push({ dis[cy][cx - 1],{ cy,cx - 1 } });
			}
		}
	}
	cout << dis[gy][gx] << endl;
}


Measured memory_bytes: 8956
using System;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            n %= 10;
            string str;
            switch(n) {
                case 3:
                str = "bon";
                break;
                case 0:
                case 1:
                case 6:
                case 8:
                str = "pon";
                break;
                default:
                str = "hon";
                break;
            }
            Console.WriteLine(str);
        }
    }
    //2回位使ったら追加する
    class MyLibrary
    {
        public static int[] ToIntArray(string[] stringArray)
        {
            int length = stringArray.Length;
            int[] intArray = new int[length];
            for (int i = 0; i < length; i++)
            {
                intArray[i] = int.Parse(stringArray[i]);
            }
            return intArray;
        }
    }
}


Measured memory_bytes: 27540
#include <map>
#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
using namespace std;
typedef priority_queue< int,vector<int>,greater<int> > myqueue;

int main()
{
	myqueue que;
	map< string,myqueue > index;
	map< string,myqueue >::iterator it;
	int paz;
	char in[1001];
	string word;

	while( scanf("%s %d",in,&paz) != EOF ){
		word.append(in);
		
		if( index.find(word) == index.end() ){
			que.push(paz);
			index.insert( make_pair(word,que) );
			que.pop();
		}
		
		else{
			index[word].push(paz);
		}

		word.erase( word.begin(),word.end() );
	}

	for(it = index.begin(); it != index.end(); it++){
		cout << it->first << endl;
		while( !it->second.empty() ){
			printf("%d",it->second.top());
			it->second.pop();
			if(it->second.empty()){
				printf("\n");
			}
			else{
				printf(" ");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1280
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    C = Counter(A)

    ans = 0
    if len(C) <= K:
        print(0)
        return
    else:
        mc = C.most_common()
        for i in range(len(C) - K):
            ans += mc[-i - 1][1]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39524
import numpy as np

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

ans = 0

for i in range(n):
    tmp_x, tmp_y = map(int, input().split())
    distance = np.sqrt(np.square(tmp_x) + np.square(tmp_y))
    if distance <= d:
        ans += 1

print(ans)

Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
using tpl = tuple<ll, ll, ll>;
typedef pair<ll,ll> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

ll N;
ll A[310][310];

int main(){

    cin >> N;

    ll sum = 0;
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            cin >> A[i][j];
            sum += A[i][j];
        }
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            bool flag = false;
            for(int k = 0; k < N; k++){
                if(A[i][k] + A[k][j] <= A[i][j]){
                    if(A[i][k] + A[k][j] != A[i][j]){
                        cout << -1 << endl;
                        return 0;
                    }
                    if(k==j||k==i){
                    }
                    else{
                        flag = true;
                    }
                }
            }
            if(flag) {
                sum -= A[i][j];
            }
        }
    }

    cout << sum / 2 << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
    ci(n);
  vll B(n-1);
  FOR(i,0,n-1){
    ci(B[i])
  }
  vll A(n);
  FOR(i,1,n-1){
    A[i]=min(B[i-1],B[i]);
  }
  A[0]=B[0];
  A[n-1]=B[n-2];
  ll ans=0;
  FOR(i,0,n){
    ans+=A[i];
  }
  co(ans)
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String in = sc.nextLine();
        int a = in.codePointAt(0) - '0';
        int b = in.codePointAt(1) - '0';
        int c = in.codePointAt(2) - '0';
        int d = in.codePointAt(3) - '0';

        for (int i = 0; i < 8; i++) {
            int result = a;
            result += ((i & 0x01) != 0) ? b : -b ;
            result += ((i & 0x02) != 0) ? c : -c ;
            result += ((i & 0x04) != 0) ? d : -d ;
            if (result == 7) {
                System.out.println(String.format("%d%c%d%c%d%c%d=7",a,((i & 0x01) != 0) ? '+' : '-',b,((i & 0x02) != 0) ? '+' : '-',c,((i & 0x04) != 0) ? '+' : '-',d));
                System.exit(0);
            }
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  v(string) s(N);
  rep(i,N) {
    cin >> s[i];
  }
  int M;
  cin >> M;
  v(string) t(M);
  rep(i,M) {
    cin >> t[i];
  }
  int ans = 0;
  rep(i,N) {
    int tmp = 0;
    string a = s[i];
    rep(j,N) {
      if(a == s[j]) tmp++;
    }
    rep(j,M) {
      if(a == t[j]) tmp--;
    }
    ans = max(ans,tmp);
  }
  cout << ans << endl;
}

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

#define int long long

struct edge { 
        int to, cap, rev;
};
vector<edge> g[101010];
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
int level[101010];
int iter[101010];
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 });
}
void bfs(int s) {
        memset(level, -1, sizeof level);
        queue<int> q;
        level[s] = 0;
        q.push(s);
        while (!q.empty()) {
                int v = q.front();
                q.pop();
                for (edge &e : g[v]) {
                        if (e.cap > 0 && level[e.to] < 0) {
                                level[e.to] = level[v] + 1;
                                q.push(e.to);
                        }
                }
        }
}
int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < g[v].size(); i ++) {
                edge &e = g[v][i];
                if (e.cap > 0 && level[v] < level[e.to]) {
                        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 MaxFlow(int s, int t) {
        int flow = 0;
        for (;;) {
                bfs(s);
                if (level[t] < 0) return flow;
                memset(iter, 0, sizeof iter);
                int f;
                while ((f = dfs(s, t, INFL)) > 0) {
                        flow += f;
                }
        }
}

signed main() {
        int n;
        scanf("%lld", &n);
        vector<int> a(n);
        for (int i = 0; i < n; i ++) scanf("%lld", &a[i]);
        int sum = 0;
        for (int i = 0; i < n; i ++) if (a[i] > 0) sum += a[i];
        int s = n, t = n + 1;
        for (int i = 0; i < n; i ++) {
                if (a[i] <= 0) add_edge(n, i, -a[i]);
                else add_edge(i, n + 1, a[i]);
        }
        for (int i = 0; i < n; i ++) {
                for (int j = i; j < n; j ++) {
                        if ((j + 1) % (i + 1) == 0) add_edge(i, j, INFL);
                }
        }
        printf("%lld\n", sum - MaxFlow(s, t));
        return 0;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define rep(i,n)for(urs(n)i=0;i<(n);++i

int main(){
	
int a,b;
cin >> a >> b;
if(b>=a)
cout << "unsafe";
else cout << "safe";

    return 0;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
 
int n;
char s[MAX_N];
bool t[11][(1<<10)];
bool dp[11][(1<<10)];
 
bool check(int S){
  memset(dp,false,sizeof(dp));
  dp[0][0]=true;
  int a=1;
  for(int i=0;i<10;i++){
    if(~S>>i&1)continue;
    for(int j=0;j<(1<<10);j++){
      if(!t[i][j])continue;
      int k=(1<<10)-1-j;
      while(1){
        dp[a][j+k]|=dp[a-1][k];
        if(dp[a][j+k] && ((j+k)&S)==S )return true;
        if(k==0)break;
        k=(k-1)&(~j);
      }
    }
    a++;
  }
  return false;
}
 
bool solve(){
  for(int bit=0;bit<(1<<10);bit++)
    if(check(bit))return true;
  return false;
}
 
int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    memset(t,false,sizeof(t));
    scanf("%s",s);
    int bit=0;
    for(int i=0;i<n;i++){
      if(s[i]=='u')bit=0;
      if('0'<=s[i]&&s[i]<='9'){
        int num=s[i]-'0';
        t[ num ][ bit ] = true;
        bit|=(1<<num);
      }
    }
    if(solve())printf("UNSAFE\n");
    else printf("SAFE\n");
  }


  return 0;
}

Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Long a = scanner.nextLong(),b = scanner.nextLong(),x = scanner.nextLong();
		Long count = (long) 0;
		if(a % x == 0){
			count = b/x - a/x + 1;
		}else{
			count = b/x - a/x;
		}
		System.out.println(count);
	}

}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

const int INF = 1001001001;

int main()
{   
    int N, W;
    cin >> N >> W;
    vi w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vvll dp(N+1, vll(W+1, 0));
    rep(i, N) rep(j, W+1) {
        chmax(dp[i+1][j], dp[i][j]);
        if(j+w[i] <= W) chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
    }

    ll ans = 0;
    rep(i, W+1) chmax(ans, dp[N][i]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 83164
#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) {

  int a;
  while(cin >> a){
    a %= 39;
    if( a == 0 ) cout << "3C39" << endl;
    else cout << "3C" << (a < 10 ? "0":"") << a << endl;
  }


  return 0;
}

// EOF

Measured memory_bytes: 3048
#include "iostream"
#include "algorithm"
using namespace std;
int a[1000001];
int main(){
	int x,sum=0;
	cin>>x;
	for(int i=0;i<x*2;i++){
		cin>>a[i];
	}
	sort(a,a+(2*x));
	for(int i=0;i<2*x;i+=2){
		sum+=a[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> A;
  while (n--) {
    int t;
    cin >> t;
    A.insert(t);
  }
  int m;
  cin >> m;
  while (m--) {
    int t;
    cin >> t;
    A.insert(t);
  }
  for (auto x : A)
    cout << x << endl;
  return 0;
}


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

int N;
vector<int> A;
vector<vector<int> > V;
vector<int> ANS;
vector<int> NOW;

void DFS(int P, int Q) {
	ANS[P] = NOW.size();
	for (int NP : V[P]) {
		if (NP == Q) continue;
		if (NOW[NOW.size() - 1] < A[NP]) {
			NOW.push_back(A[NP]);
			DFS(NP, P);
			NOW.pop_back();
		}
		else {
			int X = lower_bound(NOW.begin(), NOW.end(), A[NP]) - NOW.begin();
			int Y = NOW[X];
			NOW[X] = A[NP];
			DFS(NP, P);
			NOW[X] = Y;
		}
	}
}

int main() {
	cin >> N;
	A.resize(N);
	V.resize(N);
	ANS.resize(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N - 1; i++) {
		int S, T;
		cin >> S >> T;
		S--, T--;
		V[S].push_back(T);
		V[T].push_back(S);
	}
	NOW.push_back(A[0]);
	DFS(0, -1);
	for (int i = 0; i < N; i++) {
		cout << ANS[i] << endl;
	}
}

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

int N, M, c;
map<string, int> mp;
vector<string> T;

string solve(string s) {
  if (!mp[s]) return "Unknown " + s;
  return ( (++c % 2) ? "Opened by " : "Closed by " ) + s;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    string U; cin >> U;
    ++mp[U];
  }
  cin >> M;
  T = vector<string>(M);
  for (int i = 0; i < M; ++i) cin >> T[i];

  for (auto&& s : T) cout << solve(s) << endl;
  return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	ll n,k;
	cin>>n>>k;
	ll ans=n%k;
	if(ans>abs(ans-k))
		ans=abs(ans-k);
	cout<<ans;
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int S,h,m,s;
	scanf("%d" ,&S);
	 h=S/3600;
	 m=(S-3600*h)/60;
	 s=S-(3600*h+60*m); /*S%(S-3600*h)/60??§???????????????*/
	printf("%d:%d:%d\n",h,m,s);

	return 0;

}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
using namespace std;
 
int main() {
  // input
  long h,w; cin >> h >> w;
  
  // compute
  long c1,ans;
  c1 = (h / 2) + (h % 2);
  ans = (w / 2) * h + (w % 2) * c1 ;
  
   if(h == 1 || w == 1){
    ans = 1;
  }
 
  // output  

  cout << ans << endl;
  
}

Measured memory_bytes: 3568