akhauriyash/Code-Regression huggingface dataset:
S=set()
n=int(input())
for i in range(n):
    q,x=map(int,input().split())
    if q==0:
        if x in S:
            print(len(S))
        else:
            S.add(x)
            print(len(S))
    else:
        x={x}
        if S>=x:
            print(1)
        else:
            print(0)


Measured memory_bytes: 23360
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){
  ll N, tmp;
  cin >> N;
  vector<ll> A(N);
  
  for(ll i = 0; i < N-1; i++){
    cin >> tmp;
    A[tmp-1]++;
  }

  cerr << "Answer:" << endl;
  for(ll i = 0; i < N; i++){
    cout << A[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4844
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int N;

  unused = scanf("%d", &N);
  N = N%10;
  if(N==2 || N==4 || N==5 || N==7 || N==9) printf("hon");
  else if(N==0 || N==1 || N==6 || N==8) printf("pon");
  else printf("bon");
  return 0;
}

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

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		Main main = new Main();
		main.solv();
	}
	private void solv() {
		int n = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
			b[i] = a[i];
		}
		Arrays.sort(b);
		Bit bit = new Bit(n);
		long cnt = 0; 
		for (int i = 1; i <= n; i++) {
			int v = a[i-1];

			int l = 0, r = n - 1;
			while (l < r) {
				int m = (l + r) / 2;
				if (b[m] < v) {
					l = m + 1;
				} else {
					r = m;
				}
			}

			cnt += i - bit.sum(l+1) - 1;
			bit.add(l+1, 1);
		}
		out.println(cnt);
	}

	private static class Bit {
		int n;
		int[] bit;
		Bit(int n) {
			this.n = n;
			this.bit = new int[n+1];
		}
		public void add(int a, int w) {
			for (int x = a; x <= n; x += x & -x) {
				bit[x] += w;
			}
		}
		public int sum(int a) {
			int ret = 0;
			for (int x = a; x > 0; x -= x & -x) {
				ret += bit[x];
			}
			return ret;
		}
	}
}

Measured memory_bytes: 98660
#include <cmath>
#include <iostream>
int main(){
	for (double a,b,c,d,e,f,g,h;std::cin>>a>>b>>c>>d>>e>>f>>g>>h;)
		std::cout<<((std::abs((c-a)*(g-e)+(d-b)*(h-f))<1e-10)?"YES":"NO")<<"\n";
}

Measured memory_bytes: 1188
N, M, X = map(int, input().split())
books = []
for i in range(N):
    book = list(map(int, input().split()))
    books.append(book)

min_cost = -1
for i in range(2 ** N):
    cost = 0
    skills = [0] * M
    for j in range(N):
        if i & (2 ** j) != 0:
            cost += books[j][0]
            for s in range(M):
                skills[s] += books[j][s + 1]
    if min(skills) >= X and (min_cost < 0 or cost < min_cost):
        min_cost = cost

print(min_cost)


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

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++) {
		int mi = 1e9;
		for(int j = 1; j <= k; j++) {
			if(i - j >= 0) {
			    mi = min(dp[i - j] + abs(h[i] - h[i - j]), mi);
		    }
		}
		dp[i] = mi;
	}
	printf("%d\n", dp[n - 1]);
}

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

using namespace std;

int main() {

	long n;
	cin >> n;

	vector<long> a(n + 1);
	for (long i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	long ans = 0;
	for (long i = 2; i <= n; i++) {
		ans+=a[i]-a[i-1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
chomp (my ($n, $m) = split / /, <STDIN>);
my @a;
for my $i (1..$m) {
  chomp (my $in = <STDIN>);
  $a[$i] = $in;
}
push @a, $n + 1;
$a[0] = -1;
my @b;
for my $i (1..$m+1) {
  if ($i != 1 && $a[$i] - $a[$i - 1] == 1) {
    print "0\n";
    exit;
  }
  push @b, $a[$i] - $a[$i - 1] - 1;
}
$b[0] = $n + 1 if $m == 0;
my @memo;
$memo[1] = 1;
$memo[2] = 1;
for my $i (3..$n+1) {
  $memo[$i] = $memo[$i - 1] + $memo[$i - 2];
  $memo[$i] %= 1e9 + 7;
}
my $ans = 1;
for my $i (@b) {
  $ans *= $memo[$i];
  $ans %= 1e9 + 7;
}
print "$ans\n";

Measured memory_bytes: 10368
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGE
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
      ll k;
      cin>>k;
      ll ans=0;
      for(ll i=1;i<=k;i++)
        for(ll j=1;j<=k;j++)
            for(ll l=1;l<=k;l++)
                ans+=__gcd(__gcd(i,j),l);
            cout<<ans;
} 

Measured memory_bytes: 3652
#include <iostream>
#include <set>
#include <vector>

using namespace std;
using ll = long long;
using ld = long double;

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

  vector<int> v(200001,0);
  ll cnt{};
  int a;
  for (auto i = 0; i != n; ++i) {
    cin >> a;
    if (i+a < 200001) ++v[i+a];

    if (i-a>0) cnt += v[i-a];
  }

  cout << cnt << endl;
  return 0;
}


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

using namespace std;
typedef long long int ll;

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    for(int i=0;i<N;i++){
        cin >> h[i];
    }

    //Processing
    vector<int> dp;
    dp.emplace_back(0);
    dp.emplace_back(abs(h[1]-h[0]));

    for(int i=2;i<N;i++){
        int x=abs(h[i]-h[i-2])+dp[i-2];
        int y=abs(h[i]-h[i-1])+dp[i-1];
        if(x<y){
            dp.emplace_back(x);
        }else{
            dp.emplace_back(y);
        }
    }

    cout << dp[N-1] << endl;

}

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

int main() {
	int x,y;
	cin >> x >> y;
	if(2*x <= y && y <= 4*x && y%2 == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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

int main(){
  long double d, n, m;
  cin >> n >> m >> d;
  
  long double ans;
  if(d == 0) ans = 1 / n * (m-1);
  else ans = 2 * (n-d) / n / n * (m-1);
  
  cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#define INF 2100000000
using namespace std;
int absint(int a)
{
	return max(a , - a);
}
int main()
{
	int n, h[100010], i, j;
	int cost[100010];
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> h[i];
		cost[i]= INF;
	}
	cost[1]= 0;
	for (i = 1; i <= n - 2; i++)
	{
		cost[i + 1] = min(cost[i+1],cost[i] + absint(h[i + 1] - h[i]));
		cost[i + 2] = min(cost[i+2],cost[i] + absint(h[i + 2] - h[i]));
	}
	cout << min(cost[n], cost[n - 1] + absint(h[n] - h[n - 1])) << endl;
	return 0;
}

Measured memory_bytes: 1024
S=str(input())
if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]) or (S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]) or (S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]):
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 3060
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli> > graph;

lli n;
graph g;
lli u,k,v,c;
priority_queue<pll,vector<pll>,greater<pll> > q;
vbl vis;
vll ans;

int main(){
    cin >> n;
    g = graph(n);
    for(lli i = 0;i < n;i++){
        cin >> u >> k;
        for(lli i = 0;i < k;i++){
            cin >> v >> c;
            g[u][v] = c;
        }
    }
    vis = vbl(n);
    ans = vll(n);
    q.push(pll(0,0));
    while(!q.empty()){
        lli d = q.top().first;
        lli p = q.top().second;
        q.pop();
        if(vis[p]) continue;
        vis[p] = true;
        ans[p] = d;
        for(auto itr = g[p].begin();itr != g[p].end();itr++){
            if(!vis[itr->first]) q.push(pll(d+itr->second,itr->first));
        }
    }
    for(lli i = 0;i < n;i++) cout << i << " " << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3496
from decimal import Decimal
import sys
input = sys.stdin.readline


def dist(x1, x2, y1, y2):
    return (y1-y2)*(y1-y2)+(x1-x2)*(x1-x2)


def farthest(x, y):
    ret = 0
    point = (-1, -1)
    for u, v in X:
        d = dist(x, u, y, v)
        if d > ret:
            ret = d
            point = u, v
    return ret, point


N = int(input())
X = []
for _ in [0]*N:
    x, y = map(int, input().split())
    X.append((x, y))

x = (max(x for x, y in X) - min(x for x, y in X))/2
y = (max(y for x, y in X) - min(y for x, y in X))/2
x = Decimal(str(x))
y = Decimal(str(y))
step = Decimal('0.5')
o = 1
eps = Decimal('0.00000000000001')
while o > eps:
    _, (u, v) = farthest(x, y)
    x += (u-x)*step
    y += (v-y)*step
    step *= Decimal('0.999')
    o = (abs(u-x)+abs(x-y))*step

ans, _ = farthest(x, y)
ans **= Decimal('0.5')
print(ans)

Measured memory_bytes: 9916
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur=nil->next;
  while (cur!=nil && cur->key!=key) {
    cur=cur->next;
  }
  return cur;
}
void init() {
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}
void printList() {
  Node *cur=nil->next;
  int isf=0;
  while (true) {
    if (cur==nil) {
      break;
    }
    if (isf++>0) {
      cout<<" "<<flush;
    }
    cout<<cur->key<<flush;
    cur=cur->next;
  }
  cout<<endl;
}
void deleteNode(Node *t) {
  if (t==nil) {
    return;
  }
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}
void deleteFirst() {
  deleteNode(nil->next);
}
void deleteLast() {
  deleteNode(nil->prev);
}
void deleteKey(int key) {
  deleteNode(listSearch(key));
}
void insert(int key) {
  Node *x=(Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
int main() {
  int n;
  cin>>n;
  init();
  char s[20];
  int key;
  for (int i=0; i<n; i++) {
    scanf("%s",s);
    if (!strcmp(s,"insert")) {
      scanf("%d",&key);
      insert(key);
    } else if (!strcmp(s,"delete")) {
      scanf("%d",&key);
      deleteKey(key);
    } else if (!strcmp(s,"deleteFirst")) {
      deleteFirst();
    } else {
      deleteLast();
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 34380
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let p: usize = iterator.next().unwrap().parse().unwrap();

    let mut even: usize = 0;
    let mut odd: usize = 0;
    for _ in 0..n {
        let a: usize = iterator.next().unwrap().parse().unwrap();
        if a % 2 == 0 {
            even += 1;
        } else {
            odd += 1;
        }
    }

    let ans: u64 = if p == 0 {
        let mut combinations = 1;

        let mut r = 2;
        while r <= odd {
            combinations += comb(odd, r);
            r += 2;
        }

        2_u64.pow(even as u32) * combinations as u64
    } else {
        let mut combinations = 0;

        let mut r = 1;
        while r <= odd {
            combinations += comb(odd, r);
            r += 2;
        }

        2_u64.pow(even as u32) * combinations as u64
    };

    return ans.to_string();
}

fn comb(mut n: usize, mut r: usize) -> usize {
    if r > n / 2 {
        r = n - r;
    }

    let mut numerator: usize = 1;
    let mut denominator: usize = 1;
    while r > 0 {
        numerator *= n;
        denominator *= r;
        n -= 1;
        r -= 1;
    }
    numerator / denominator
}


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

using namespace std;

const int N=1e4+10;
vector<int> G[N];
bool used[N];
stack<int> order;

void add(int s,int t)
{
    G[s].push_back(t);
}

void dfs(int v)
{
    used[v]=true;
    for(int i=0;i<G[v].size();i++)
    {
        int t=G[v][i];
        if(!used[t])
        {
            dfs(t);
        }
    }
    order.push(v);
}

int main()
{
    int v,e;
    cin>>v>>e;

    for(int i=0;i<e;i++)
    {
        int s,t;
        cin>>s>>t;
        add(s,t);
    }

    for(int i=0;i<v;i++)
    {
        if(!used[i])
        {
            dfs(i);
        }
    }

    while(!order.empty())
    {
        cout<<order.top()<<endl;
        order.pop();
    }

    return 0;
}



Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;

#define INF ((i64)(1e18))
#define MOD ((i64)(1e9+7))
#define REP(i, n) for(i64 i = 0; i < (n); i++)
#define RREP(i, n) for(i64 i = (n)-1; i >= 0; i--)
#define RANGE(i, a, b) for(i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for(i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

int main() {
  i64 n;
  cin >> n;
  vector<i64> a(n);
  REP(i, n) cin >> a.at(i);
  i64 ans = 0;
  REP(i, n) {
    if ((i+1)%2 == 1 && a[i]%2 == 1) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

#define fi first
#define se second

typedef long long ll;


using namespace std;

void solve(){
  string S;
  cin >> S;
  int s = 0, st = S.size();
  for(int i=0;i<S.size();i++){
    if(S[i] == 'S')s++;
    else{
      if(s > 0){
        s -= 1;
        st -= 2;
      }
    }
  }
  cout << st;
}

int main(){
  int tt = 1;
  while(tt--){
    solve();
  }

return 0;
}


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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl
#define ll long long


template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int M = 10000003;

void solve()
{
	int n;
	cin >> n;
	map<int, int>mp;
	while (n % 2 == 0)
	{
		mp[2]++;
		n /= 2;
	}

	for (int i = 3; i * i <= n; i += 2)
	{
		while (n % i == 0)
		{
			mp[i]++;
			n /= i;
		}
	}

	if (n > 2) mp[n]++;


	vi a(1000005, 0);
	int sum = 0;
	loop(i, 1, 1000005)
	{
		sum += i;
		a[i] = sum;

	}


	int ans = 0;
	for (auto i : mp)
	{
		int no = i.ff;
		int cnt = i.ss;
		int c = lower_bound(all(a), cnt) - a.begin();
		if (a[c] == cnt) ans += c;
		else ans += (c - 1 >= 0) ? c - 1 : 0;


	}
	cout << ans << endl;


	return;

}

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


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

	return 0;
}

Measured memory_bytes: 11120
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <cmath>
#include <utility>
#include <queue>

using namespace std;
using ll = long long;

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

    vector<int> s(N);
    vector<int> t(N);
    vector<int> c(N);

    int T = 0;

    for (int i = 0; i < N; ++i) {
        cin >> s[i] >> t[i] >> c[i];
        --c[i];

        T = max(T, t[i]+1);
    }

    vector<vector<int>> v(
        C, vector<int>(T+1, 0)
    );

    for (int nc = 0; nc < C; ++nc) {
        for (int i = 0; i < N; ++i) {
            if (c[i] == nc) {
                for (int j = s[i]; j <= t[i]; ++j) {
                    v[nc][j] = 1;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i <= T; ++i) {
        int count = 0;
        for (int nc = 0; nc < C; ++nc) {
            count += v[nc][i];
        }
        ans = max(ans, count);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;++i)
#define REP(i, k, n) for(int i=k; i<=n; ++i)
#define REPR(i, k, n) for(int i=k; i>=n; --i)
#define MAX 2001
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define r return
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int long long uill;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);

	int A, B, C;

	cin >> A >> B >> C;

	int arr[3];

	/*
     577
     555
     777
     557
	*/

	arr[0] = A;
	arr[1] = B;
	arr[2] = C;

	sort(arr, arr+3);

	if(arr[1] == arr[2]) {
		cout << "NO";
	}else {
		cout << "YES";
	}

	r 0;
}

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

int main() {
    int n, count;
    count = 1;
    cin >> n;
    vector<int> vec(n);

    for(int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());

    for(int j = 0; j < n-1; j++) {
        if(vec.at(j) != vec.at(j+1)) {
            count++;
        }
    }
    cout << count << endl;
}

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

int main() {
  int N; cin >> N;
  vector<long long> D(64, 0);
  rep(i, N) {
    long long A; cin >> A;
    int cnt = 0;
    while (A != 0) {
      if (A & 1) D[cnt]++;
      cnt++; A /= 2;
    }
  }

  const int MOD = 1e9 + 7;

  long long ans = 0;
  long long k = 1;
  rep(i, 64) {
    long long c = (D[i] * (N - D[i])) % MOD;
    ans = (ans + (k * c)) % MOD;
    k = (k * 2) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val (N, i) = listOfInt()
    println(N-i+1)
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 35672
package main

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

func main() {
	var k int
	fmt.Scan(&k)
	t := readi()
	a := atoi(readSlice())
	sort.Ints(a)
	max := a[t-1]
	for i := 0; i < t-1; i++ {
		max -= a[i]
	}
	if max < 0 {
		fmt.Println("0")
	} else {
		fmt.Println(max - 1)
	}
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>
#include<map>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int x;
	cin >> x;
	int a = x / 100;
	int b = x % 100;
	int ans = 0;
	
	if (b <= a * 5) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

    for (int i = 0; i < b.size(); i++) {
        if (b[i] == 'A') {
            cout << 'T';
        } else if (b[i] == 'C') {
            cout << 'G';
        } else if (b[i] == 'G') {
            cout << 'C';
        } else {
            cout << 'A';
        }
    }
    cout << endl;
    return 0;
}

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

ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}

int main() {
  int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll x=1;
  ll y;
  ll cur;
  for(int i=0;i<n;i++){
    y=a[i];
    cur=x/gcd(x,y)*y;
    x=cur;
  }
  cout<<cur<<endl;
}

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

int w,h,map[20][20],ans;
int dx[]={0,1,0,-1}; int dy[]={-1,0,1,0};

void solve(int nx,int ny,int sum){
  if(sum>=ans) return;
  for(int i=0;i<4;i++){
    int x=nx,y=ny;
    x+=dx[i]; y+=dy[i];
    if(x<0||x>=w||y<0||y>=h||map[y][x]==1) continue;
    for(;;){
      if(map[y][x]==3){
	ans=sum; return;
      }
      x+=dx[i]; y+=dy[i];
      if(x<0||x>=w||y<0||y>=h) break;
      if(map[y][x]==1){
	map[y][x]=0;
	solve(x-dx[i],y-dy[i],sum+1);
	map[y][x]=1;
	break;
      }
    }
  }
}

int main(){
  int sx,sy;  
  for(;;){
    cin>>w>>h;
    if(w==0&&h==0) break;
    ans=11;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	cin>>map[i][j];
	if(map[i][j]==2){
	  sx=j; sy=i;
	}
      }
    solve(sx,sy,1);
    if(ans>10) ans=-1;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 1156
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        int amax = Y/10000;
        int bmax = Y/5000;
        for(int i = 0; i<=amax && i<=N; i++) {
            for(int j = 0; j<=bmax && j<=N; j++) {
                int sum = 10000*i + 5000*j;
                int rest = N - i - j;
                if((Y-sum  == rest*1000) && (rest>=0)) {
                    System.out.println(i + " " + j + " " + rest);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


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

typedef long long ll;
typedef pair<int,int> P;

int h,w;
queue<P>q;
char c[25][25];
int si,sj,ans=0;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
bool seen[25][25];

void f(){
        for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                        seen[i][j]=false;
                }
        }
}

void bfs(int x,int y){
        q.push(P(x,y));
        ans++;
        seen[x][y]=true;
        while(q.size()){
                P p=q.front();q.pop();
                for(int i=0;i<4;i++){
                        int nx=p.first+dx[i],ny=p.second+dy[i];
                        if(0<=nx&&nx<h&&0<=ny&&ny<w&&c[nx][ny]!='#'){
                                if(!seen[nx][ny]){
                                        seen[nx][ny]=true;
                                        q.push(P(nx,ny));
                                        ans++;
                                }
                        }
                }
        }
        return;
}

int main(){
        while(cin>>w>>h||w,h){
                ans=0;
                f();
                for(int i=0;i<h;i++){
                        for(int j=0;j<w;j++){
                                cin>>c[i][j];
                                if(c[i][j]=='@')si=i,sj=j;
                        }
                }
                bfs(si,sj);
                cout<<ans<<endl;
        }
        return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=2e5+5;
int a[N],b[N],c[N],dp[N][3],n,k;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i]>>b[i]>>c[i];
	dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
	for(int i=2;i<=n;++i)
		{	
        dp[i][1]+=max(dp[i-1][2],dp[i-1][3])+a[i];
        dp[i][2]+=max(dp[i-1][1],dp[i-1][3])+b[i];
        dp[i][3]+=max(dp[i-1][1],dp[i-1][2])+c[i];
		}	
		cout<<max(dp[n][3],max(dp[n][1],dp[n][2]));
	return 0;
} 

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
char c[100005];
char use[100005];
int main(){
	int n,k;
	cin>>n>>k;
	int r,s,p;
	cin>>r>>s>>p;
	for(int i=1;i<=n;i++){
		cin>>c[i];
	}
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(i>k){
			if(c[i]=='s'&&use[i-k]=='r'){
//				use[i]='s';
				ans=ans;
			}else if(c[i]=='s'&&use[i-k]!='r'){
				use[i]='r';
				ans+=r;
//				cout<<"r"<<endl;
			}
			if(c[i]=='r'&&use[i-k]=='p'){
//				use[i]='r';
				ans=ans;
			}else if(c[i]=='r'&&use[i-k]!='p'){
				use[i]='p';
				ans+=p;
//				cout<<"p"<<endl;
			}
			if(c[i]=='p'&&use[i-k]=='s'){
//				use[i]='p';
				ans=ans;
			}else if(c[i]=='p'&&use[i-k]!='s'){
				use[i]='s';
				ans+=s;
//				cout<<"s"<<endl;
			}
		}else{
			if(c[i]=='s'){
				use[i]='r';
				ans+=r;
//				cout<<"R"<<endl;
			}else if(c[i]=='r'){
				use[i]='p';
				ans+=p;
//				cout<<"P"<<endl;
			}else if(c[i]=='p'){
				use[i]='s';
				ans+=s;
//				cout<<"S"<<endl;
			}
		}
//		cout<<ans<<endl;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
gets
a = gets.chomp.split.map(&:to_i)

alice = 0
bob   = 0

a.size.times do |n|
  if n.even?
    alice += a.max
  else
    bob += a.max
  end
  a.delete_at(a.find_index(a.max))
end

puts alice - bob


Measured memory_bytes: 1788
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt=0
margin=0
for i in range(n):
  x=a[i]
  y=b[i]
  if x>y:
    cnt+=x-y
  elif x<y:
    margin+=(y-x)//2

print('Yes' if margin>=cnt else 'No')

Measured memory_bytes: 4596
a=input()
a_i=int(a[0:2])
b_i=int(a[2:4])
if 0<a_i<=12 and 0<b_i<=12:
    print('AMBIGUOUS')
elif 0<b_i<=12:
    print("YYMM")
elif 0<a_i<=12:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
import std.stdio, std.string, std.algorithm, std.conv, std.array, std.math;

void main()
{
    auto wab = readln.chomp.split(" ").map!(to!int);
    auto w = wab[0];
    auto a = wab[1];
    auto b = wab[2];

    auto d = a < b ? (b-a-w) : (a-b-w);
    writeln(d < 0 ? 0 : d);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int arr[11];
int main(){

int r , d ;
cin>> r>>d >>arr[0];

for(int i=1; i<11; ++i){
   arr[i]=r*arr[i-1]-d;
}

for(int i=1; i<11; ++i){
   cout<<arr[i]<<endl;
}
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll M=1e9+7;
const int N=2e3+10;

ll myPow(ll a,ll n)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1)
        {
            ans=ans*a%M;
        }
        a=a*a%M;
        n>>=1;
    }
    return ans;
}

ll fac[N],inv[N];

void init()
{
    fac[0]=1;
    for(int i=1;i<N;i++)
    {
        fac[i]=fac[i-1]*i%M;
    }
    inv[N-1]=myPow(fac[N-1],M-2);
    for(int i=N-2;i>=0;i--)
    {
        inv[i]=inv[i+1]*(i+1)%M;
    }
}

ll C(int n,int m)
{
    if(n<m) return 0;
    return fac[n]*inv[n-m]%M*inv[m]%M;
}

int main()
{
    init();
    int n,k;
    while(cin>>n>>k)
    {
        cout<<C(k,n)<<endl;
    }

    return 0;
}



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

int main() {
  string s;
  cin >> s;
  int k, d = s.size();
  cin >> k;
  vector<int> n(d);
  for (int i = 0; i < d; i++) n.at(i) = s.at(i) - '0';
  vector<vector<int>> dp_exact(d + 1, vector<int>(k + 1)),
    dp_under(d + 1, vector<int>(k + 1));
  dp_exact.at(0).at(0) = 1;
  for (int i = 0; i < d; i++) {
    for (int j = 0; j <= k; j++) {
      if (n.at(i) && j < k) {
        dp_exact.at(i + 1).at(j + 1) += dp_exact.at(i).at(j);
        dp_under.at(i + 1).at(j + 1) += dp_exact.at(i).at(j) * (n.at(i) - 1);
      }
      if (n.at(i) == 0) dp_exact.at(i + 1).at(j) += dp_exact.at(i).at(j);
      if (n.at(i)) dp_under.at(i + 1).at(j) += dp_exact.at(i).at(j);
      if (j < k) dp_under.at(i + 1).at(j + 1) += dp_under.at(i).at(j) * 9;
      dp_under.at(i + 1).at(j) += dp_under.at(i).at(j);
    }
  }
  cout << dp_exact.at(d).at(k) + dp_under.at(d).at(k) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int n,k,dp[100009],a[100009];
int xg(int a){
	if(a>0)
		return a;
	return -a;
}
int main(){
	memset(a,0x3f,sizeof(a));
	a[0]=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>dp[i];
	}
	for(int i=1;i<k;i++)
		a[i]=xg(dp[i]-dp[0]);
	for(int i=k;i<n;i++){
		for(int j=1;j<=k;j++)
			a[i]=min(a[i],a[i-j]+xg(dp[i]-dp[i-j]));
	}
//	for(int i=0;i<n;i++)
//		cout<<a[i]<<' ';
	if(a[n-1]==0x3f3f3f3f)
		cout<<0<<endl;
	else
		cout<<a[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int H, W;
    while (cin >> H >> W) {
        if (H==0&& W==0) {
            break;
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
double tarea(double x1, double y1,double x2, double y2,double x3, double y3);
int main(void) {
	double x1,x2,x3,y1,y2,y3,xp,yp,area,area1,area2,area3;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp)!=EOF){
		//area = tarea(x1,y1,x2,y2,x3,y3);
		area1 = tarea(x1,y1,x2,y2,xp,yp); 
		area2 = tarea(x3,y3,x1,y1,xp,yp);
		area3 = tarea(x2,y2,x3,y3,xp,yp);
		if((area1>=0 && area2>=0 && area3>=0)||(area1<0 && area2<0 && area3<0))
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
double tarea(double x1, double y1,double x2, double y2,double x3, double y3){
	double do_area;
	do_area = ((x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))*(0.5));
	return do_area;
}

Measured memory_bytes: 612
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int X;
	vector <int> v;
	cin >> X;

	for (int i = 1;i <= 40; i++) {
		for (int j = 2; j <= 10; j++) {
			if (pow(i, j) <= X) v.push_back((int)pow(i, j));
			else break;
		}
	}

	sort(v.begin(), v.end());

	int& x = v.back();

	cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5+100;
int n, q, s[N];
V<char> v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  v.pb('.');
  FOR(i, 0, n){
    char c;
    cin >> c;
    v.pb(c);
    s[i+1] = s[i] + (c=='C'&&v[i]=='A');
  }
  FOR(_, 0, q){
    int l, r;
    cin >> l >> r;
    cout << s[r] - s[l] << endl;
  }
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

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

    int not_ordered_num = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != i + 1) {
            not_ordered_num++;
            if (not_ordered_num > 2) {
                puts("NO");
                return 0;
            }
        }
    }
    puts("YES");
    return 0;
}


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

using namespace std;

#define MAX_N 110
#define MAX_V 310
#define INF 1e9

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

vector<Edge> G[MAX_V];
int level[MAX_V],iter[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((Edge){to,cap,G[to].size()});
  G[to].push_back((Edge){from,0,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(int i = 0 ; i < (int)G[v].size() ; i++){
      Edge &e = G[v][i];
      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 < (int)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 max_flow(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,INF)) > 0){
      flow += f;
    }
  }
}

int main(){
  int N,M,L,a,b,c;
  while(cin >> N >> M >> L){
    for(int i = 0 ; i < MAX_V ; i++){
      G[i].clear();
    }
    int d[MAX_N][MAX_N];
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        if(i == j){ d[i][j] = 0; }
        else{ d[i][j] = INF; }
      }
    }
    for(int i = 0 ; i < M ; i++){
      cin >> a >> b >> c; a--; b--;
      d[a][b] = d[b][a] = c;
    }
    for(int k = 0 ; k < N ; k++){
      for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
          d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
        }
      }
    }
    int P[MAX_N],K[MAX_N];
    for(int i = 0 ; i < N ; i++){
      cin >> P[i];
    }
    for(int i = 0 ; i < N ; i++){
      cin >> K[i];
    }
    int S = N*2,T = S+1;
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        if(d[i][j] < L){
          add_edge(i,j+N,P[i]);
        }
      }
    }
    for(int i = 0 ; i < N ; i++){
      add_edge(S,i,P[i]);
      add_edge(i+N,T,K[i]);
    }
    cout << max_flow(S,T) << endl;
  }
  return 0;
}

Measured memory_bytes: 1580
#include<bits/stdc++.h>
#define IOFAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long


#define vec vector<int>

#define pb push_back  
#define f first
#define s second


int main(){
    int n;
    cin>>n;
    long long int c=0;
    for(int i=1;i<=n;i++){
        if(i%3==0 && i%5==0){
            continue;
        }
        else if(i%3==0){
            continue;
        }
        else if(i%5==0){
            continue;
            
        }
        else{
            c+=i;
        }
    }
    cout<<c<<endl;

}

Measured memory_bytes: 3628
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b&&b<=c){
        printf("%d %d %d\n",a,b,c);
    }else if(a<=c&&c<=b){
        printf("%d %d %d\n",a,c,b);
    }else if(b<=a&&a<=c){
        printf("%d %d %d\n",b,a,c);
    }else if(b<=c&&c<=a){
        printf("%d %d %d\n",b,c,a);
    }else if(c<=a&&a<=b){
        printf("%d %d %d\n",c,a,b);
    }else if(c<=b&&b<=a){
        printf("%d %d %d\n",c,b,a);
    }
    return 0;
}

Measured memory_bytes: 2692
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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

int main() {
	int n;
	cin >> n;
	vi(v, n);
	rep(i, n)
		cin >> v[i];
	
	ll tmp = 0;
	rep(i, n)
		tmp += v[i] - 1;
	cout << tmp << endl;

}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
char str[100005];
int main()
{
	cin>>str;
	int len=strlen(str);
	int ans=len;
	for(int i=1;i<len;i++)
	{
		if(str[i]==str[i-1])
		ans--;
	}
	cout<<ans-1<<endl;
return 0;
}

Measured memory_bytes: 384
N,M = [ int(it) for it in input().split() ]


import math
sM = int( math.sqrt(M) + 1 )

ma = 0
for i in range(1,sM):
  if (M%i)==0:
    a,b=i,M//i
    if ( a * N <= M ):
      ma = max(a,ma)
    if ( b * N <= M ):
      ma = max(b,ma)
print (ma)
  
  
      

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

int checkMcxi(char c){
    if(c == 'm')
        return 1000;
    if(c == 'c')
        return  100;
    if(c == 'x')
        return   10;
    if(c == 'i')
        return    1;
    else
        return 0;
}

int main(void){
    int n; cin >> n;
    while(n--){
        int dec[] = {0, 0};
        string str[2]; cin >> str[0] >> str[1];
        for(int s = 0; s < 2; s++){
            int multipled = 1;
            for(int i=0; i < str[s].length(); i++){
                int d = checkMcxi(str[s][i]);
                if(d){
                    dec[s] += multipled * d;
                    multipled = 1;
                }else{
                    multipled = str[s][i] - '0';
                }
            }
        }

        stringstream s;
        string ans_dec;
        s << dec[0] + dec[1];
        s >> ans_dec;

        /*DEBUG*/// cout << ans_dec << endl;

        string ans;
        int ind = 0; char mcxi[] = {'i', 'x', 'c', 'm'};
        for(int i=ans_dec.length()-1; i >= 0; i--){
            if(!(ans_dec[i] - '0')){
                ind++;
            }else if(!(ans_dec[i] - '1')){
                ans = mcxi[ind] + ans;
                ind++;
            }else{
                ans = string(1, ans_dec[i]) + mcxi[ind] + ans;
                ind++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 105;
const int MAX_W = 100005;
ll w[MAX_N],v[MAX_N];
ll dp[MAX_N][MAX_W];



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

	rep(i,N)
	{
		rep(j,W+1)
		{
			if (j-w[i] >= 0)
			{
				dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
			}
			else
			{
				dp[i+1][j] = dp[i][j];
			}
		}
	}

	/*
	rep(i,N+1)
	{
		rep(j,W+1)
		{
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	*/
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 79360
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const ll mod=1000*1000*1000+7;

int n;
int tab[nax];

ll dp[nax];

ll wsz[nax];

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		scanf("%d", &tab[i]);
		if (tab[i]==tab[i-1])
		{
			i--;
			n--;
		}
	}
	dp[0]=1;
	for (int i=1; i<=n; i++)
	{
		wsz[tab[i]]=(wsz[tab[i]]+dp[i-1])%mod;
		dp[i]=wsz[tab[i]];
	}
	
	printf("%lld\n", dp[n]);
	return 0;
}


Measured memory_bytes: 9984
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[110];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read(),sum=0;
    for(int i=1;i<=n;i++)a[i]=read(),sum+=a[i];
    sum=ceil(1.0*sum/(4*m));
    for(int i=1;i<=n;i++)if(a[i]>=sum)m--;
    if(m>0)puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 128
n = int(input())
S = input()
W = 0
E = 0
T = [0 for i in range(n)]  
for i in range(n-1):
    if S[i] == "W": W+=1
    if i > 0:
        T[i+1] += W 

for i in range(n-1,0,-1):
    if S[i] == "E": E+=1
    if i < n-1:
        T[i-1] += E
print(min(T))

Measured memory_bytes: 15520
h, w = gets.split.map(&:to_i)
s = h.times.map { gets.chomp }

(0...h).each do |hh|
  (0...w).each do |ww|
    next if s[hh][ww] == '#'
    n = [[hh-1, ww], [hh-1, ww+1], [hh, ww+1], [hh+1, ww+1], [hh+1, ww], [hh+1, ww-1], [hh, ww-1], [hh-1, ww-1]].select {|(nh, nw)|
      nh.between?(0, h-1) && nw.between?(0, w-1)
    }.map {|(nh, nw)| s[nh][nw]}.count('#')
    s[hh][ww] = n.to_s
  end
end

s.each(&method(:puts))

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if(N%2==0) cout << N << endl;
    else cout << N*2 << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np

k, n = map(int, input().split())
a = np.array(input().split(), dtype='int')

b = np.zeros((n), dtype='int')

for i in range(n):
    if i == n - 1:
        b[i] = a[0] + k - a[i]
    else:
        b[i] = a[i + 1] - a[i]

ans = k - np.max(b)

print(ans)

Measured memory_bytes: 42692
s = input()

n = len(s)

ans = 0
for i in range(2**n):
	l = []
	op = [""]*n
	for j in range(n):
		if i & (1 << j):
			op[j] = '+'
	#print(op)
	res = ""
	for a,b in zip(op+[""],s):
		res += a+b

	ans += eval(res)

print(ans//2)


Measured memory_bytes: 3060
n, m = map(int, input().split())
h = list(map(int,input().split()))
m_list = [list(map(int,input().split())) for _ in range(m)]

n_set = set()
for i in range(1,n+1):
    n_set.add(i)

for ele in m_list:
    if h[ele[0]-1] - h[ele[1]-1] > 0:
        n_set -= {ele[1]}
    elif h[ele[0]-1] == h[ele[1]-1]:
        n_set -= {ele[0], ele[1]}
    else:
        n_set -= {ele[0]}

print(len(n_set))


Measured memory_bytes: 40496