akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;

int ar[ms];
int n,k;

int peil(int a,int b)
{
    if(a%b)return a/b+1;
    return a/b;
}

int check(int tt)
{
    ll p=0;

    for(int i=1;i<=n;i++)
    {
        p+=peil(ar[i],tt);
        p--;
    }
    if(p<=k)return 1;
    return 0;
}

int main()
{
    idfc;

    cin>>n>>k;
    int i;
    for(i=1;i<=n;i++)cin>>ar[i];
    int l=1;
    int r=1e9;
    int mid;
    int ans=r;
    while(l<=r)
    {
        mid=(l+r)>>1;

        if(check(mid))
        {
            ans=min(ans,mid);
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ans;


    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p_s;
  vector<int> p;
  rep(i, n){
    ll x;
    cin >> x;
    p_s.emplace_back(x);
    p.emplace_back(x);
  }
  sort(p_s.begin(),p_s.end());
  ll l = p_s[n / 2 - 1];
  ll r = p_s[n / 2];
  // cout << "l " << l << endl;
  // cout << "r " << r << endl;
  rep(i, n){
    if(p[i] <= l) cout << r << endl;
    else cout << l << endl;
  }
}


Measured memory_bytes: 3948
(let ((n (read))
      (s (concatenate 'list (read-line))))


  (defun most (lst)
    (labels ((f (l acc)
                (if (null l)
                  acc
                  (if (char= (car l) #\I)
                    (f (cdr l) (cons (1+ (car acc)) acc))
                    (f (cdr l) (cons (1- (car acc)) acc))))))
      (apply #'max (f lst '(0)))))

  (format t "~A~%"
          (most s)))


Measured memory_bytes: 24432
// inputに入力データ全体が入る
function Main(input) {
	tmp = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	var c = parseInt(tmp[2], 10);
	//出力
  if((a > 4 && b > 4 && c > 4) && (a < 8 && b < 8 && c < 8)){
     	if(a + b + c == 17 ){
     	console.log("YES");
    	 }else {
    	   console.log("NO");
    	 }
     }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7496
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<ll, ll>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}
bool is_hor_vert(ll x, ll y, ll x1, ll y1)
{
    if((x1-x) == 0 && (y1-y) == 1)
    {
        return true;
    }
    else if((x1-x) == 0 && (y1 - y) == -1)
    {
        return true;
    }
    else if((y1 - y) == 0 && (x1 - x) == 1)
    {
        return true;
    }
    else if((y1 - y) == 0 && (x1 - x) == -1)
    {
        return true;
    }
    return false;
}
bool check(ll x, ll y, ll h, ll w)
{
    if(x >=1 && x<=h && y>=1 && y<=w)
        return true;
    return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll h,w;
    cin>>h>>w;
    ll c_h,c_w;
    cin>>c_h>>c_w;
    ll d_h, d_w;
    cin>>d_h>>d_w;
    vector<string> S;
    for (ll i = 0; i < h; i++)
    {
        string s;
        cin>>s;
        S.push_back(s);
    }
    deque<pi> q;
    q.push_front(make_pair(c_h, c_w));
    // vector< vector<bool> > visit(h + 1, vector<bool>(w + 1, false) );
    vector< vector<ll> > d(h + 1, vector<ll>(w + 1, ll_MAX) );
    // visit[c_h][c_w] = true;
    d[c_h][c_w] = 0;
    ll dx[] = {0, 0, 1, -1};
    ll dy[] = {1, -1, 0, 0};
    while(!q.empty())
    {
        ll x = q.front().first;
        ll y = q.front().second;
        // cout<<x<<" "<<y<<'\n';
        // cout<<d[x][y]<<'\n';
        q.pop_front();
        for(ll i=-2; i<=2; i++)
        {
            for(ll j=-2; j<=2; j++)
            {
                ll x1 = x + i;
                ll y1 = y + j;
                if(check(x1, y1, h, w))
                {
                    if( S[x1 - 1][y1 - 1] == '.')
                    {
                        // visit[x1][y1] = true;
                        if(!is_hor_vert(x, y, x1, y1) && d[x1][y1] > (d[x][y] + 1) )
                        {
                            d[x1][y1] = d[x][y] + 1;
                            q.push_back(make_pair(x1, y1));
                        }
                        else if( is_hor_vert(x, y, x1, y1) && d[x1][y1] > d[x][y])
                        {
                            d[x1][y1] = d[x][y];
                            q.push_front(make_pair(x1, y1));
                        }
                    }
                }
            }
        }
    }
    if(d[d_h][d_w] != ll_MAX)
    {
        cout<<d[d_h][d_w]<<'\n';
    }
    else
    {
        cout<<-1<<'\n';
    }
    
}

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

int n,ans=-1000000000;
int a[20],shift[100][10],interest[100][11];
void func(){
  int score=0;
  for(int i=0;i<n;i++){
    int count=0;
    for(int j=0;j<10;j++){
      if(shift[i][j]==1&&a[j]==1)  count++;
    }score+=interest[i][count];
  }
  ans=max(ans,score);
}

void dfs(int k){
  if(k==10){
    int check=0;
    for(int i=0;i<10;i++){
      check+=a[i];
    }
    if(check==0){
      return;
    }func();
    return;
  }else{
    a[k]=0; dfs(k+1);
    a[k]=1; dfs(k+1);
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>shift[i][j];
    }
  }for(int i=0;i<n;i++){
    for(int j=0;j<11;j++){
      cin>>interest[i][j];
    }
  }dfs(0);
  cout<<ans<<endl;
}

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

int main() {
	int N;
	cin >> N;
	string ans = "YES";
	vector<int> A(N);
	for(int& e:A)cin >> e;
	sort(begin(A),end(A));
    for(int i=0;i+1<N;i++){
      if(A[i]==A[i+1]){
        ans="NO";
        break;
      }
    }
    cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 1024
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){var e=t.in(),n=t.in(),r=t.in();if(r>=e*e*n/2){var i=r/(e*e),s=180*Math.atan((n-i)/(e/2))/Math.PI;console.log(s)}else{var o=90-180*Math.atan(2*r/(e*n*n))/Math.PI;console.log(o)}}}]);

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repc(i, t, n) for(int i = t; i < (n); ++i)

using namespace std;
using ll = long long;

int main(){
	int n, m; cin >> n >> m;
	vector<int> a(m);
	rep(i, m) cin >> a[i];

	int hw = 0;
	rep(i, m) hw += a[i];

	if(hw > n)
		cout << -1 << endl;
	else
		cout << n - hw << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
#define V vector
signed main(){
  ll K,A,B,ans;cin>>K>>A>>B;
  if(B-1<=A||A-1>=K)ans=K+1;
  else ans=(K-A+1)/2*(B-A)+(K-A+1)%2+A;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 1000005;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
struct Trie {
    struct Node {
        bool f;
    };
    int ch[MAXN][26];
    int root;
    int tot;
    Node nodes[MAXN];
    ll ans;
    int insert(int x, int u, const string& str) {
        int c = str[x] - 'a';
        if (!ch[u][c]) ch[u][c] = ++tot;
        if (x == str.size() - 1) {
            nodes[ch[u][c]].f = true;
            return 1 << c;
        }
        int cnts = insert(x + 1, ch[u][c], str);
        cnts |= (1 << c);
        for (int i = 0; i < 26; i++) {
            if (((cnts >> i) & 1) && ch[u][i] && nodes[ch[u][i]].f) {
                ans++;
            }
        }
        return cnts;
    }
};
Trie trie;
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    vector<string> strs;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        strs.push_back(s);
    }
    sort(strs.begin(), strs.end(),
         [](const string& a, const string& b) { return a.size() < b.size(); });
    for (auto a : strs) {
        trie.insert(0, trie.root, a);
    }
    printf("%lld", trie.ans);
    return 0;
}

Measured memory_bytes: 136504
//2019/3/14
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int s = sc.nextInt();

		int n = 1;

		int Fn = s;

		ArrayList<Integer> array = new ArrayList<>();

		array.add(s);

		while(true) {

			if(Fn%2==0) Fn /= 2;

			else Fn = 3*Fn+1;

			if(array.contains(Fn)) {

				System.out.println(n+1);

				break;
			}

			array.add(Fn);

			n++;
		}
	}

}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	string v;
	cin >> s;

	for(int i=0; i<s.size(); i++){
		if(s[i] == 'B'){
			if(v.size() != 0){
				v.pop_back();
			}
		}
		else{
			v.push_back(s[i]);
		}
	}

	printf("%s\n", v.c_str());
	return 0;
}

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

int main() {
    int H1, H2, M1, M2;
    int K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int start = H1 * 60 + M1;
    int end = H2 * 60 + M2;
    int least_start_time = end - K;
    cout << least_start_time - start;

    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
 
#define MAX 20050
#define INF 1e9
 
int pos,len;
char st[MAX];
void push(char ch){
  st[pos++]=ch;
}
char pop(){
  if(pos==0){
    return '#';
  }
  return st[--pos];
}
int main(){
  double sum=0;
  int depth[MAX],Min[MAX],mini;
  int i,S[MAX],pool=0,ans=0;
  char str[MAX],ch;
 
  scanf("%s" ,str);
  len=(int)strlen(str); pos=0;
 
  for(i=0;i<len;i++){
    if(str[i]=='\\'){
      depth[i]=++pool;
    }else if(str[i]=='/'){
      depth[i]=--pool;
    }else{
      depth[i]=pool;
    }
  }
   
  mini=INF;
  for(i=len-1;i>=0;i--){
    if(depth[i]<mini){
      mini=depth[i];
    }
    Min[i]=mini;
  }
 
  pool=0;
  for(i=0;i<len ; i++){
    if(str[i]=='\\'){
      if(i!=len-1 && depth[i]==Min[i]) continue;
      push(str[i]);
    }else if(str[i]=='/'){
      ch=pop();
      if(ch!='#'){
	sum+=((pos+1)-0.5)*2;
      }
    }else{
      sum+=pos; 
    }
 
    if(sum>0 && (pos==0)){
      S[pool++]=sum;
      ans+=sum;
      sum=0;
    }
  }
 
  printf("%d\n%d" ,ans ,pool);
  for(i=0;i<pool;i++){
    printf(" %d" ,S[i]);
  } 
  printf("\n");
 
  return 0;
}
 

Measured memory_bytes: 736
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int n;
    cin>>n;
    cout<<fixed<<(long long int)(pow(2,int(log2(n))+1)-1);
	return 0;
}

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

int main()
{
  int K,X;
  cin >> K >> X;
  if(K * 500 >= X){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n, mx = -1, mn = 1e6;
map<int, int> m;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	// If range > 1, then no.
	// There are bigger number amount of colors
	// Need EXACTLY smaller number amount of smaller numbers, is that true?
	// Not true, 4 4 4 4 3 3 -> 3 3 0 0 1 2, basically just make sure that smaller number + 
	// larger num / 2 > larger number
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		++m[a];
		mx = max(mx, a);
		mn = min(mn, a);
	}
	
	if (mx - mn > 1) cout << "No";
	else {
		if (mx == mn) {
			if (n == mx + 1 || n >= mx * 2) cout << "Yes";
			else cout << "No";
		} else {
			if (m[mn] > mn) cout << "No";
			else if (m[mn] + m[mx] / 2 >= mx) cout << "Yes";
			else cout << "No";
		}
	}
}


Measured memory_bytes: 8276
use std::io;

fn main() {
    loop {
        let (n, x) = input();
        if (n, x) == (0, 0) {
            break;
        }

        let mut ans = 0;
        for i in 1..(n+1) {
            for j in (i+1)..(n+1) {
                for k in (j+1)..(n+1) {
                    if i + j + k == x {
                        ans += 1;
                    }
                }
            }
        }

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

fn input() -> (i32, i32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();
    let x: i32 = iter.next().unwrap().parse().unwrap();

    (n, x)
}



Measured memory_bytes: 5024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];
		int s = 0;
		for (int i = 0; i < n; i++) {
			num[i] = scanner.nextInt();
			s += num[i];
		}
		boolean[] map = new boolean[s + 1];

		for (int i = 1; i < 1 << n; i++) {
			int sum = 0;
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					sum += num[j];
				}
			}
			map[sum] = true;
		}

		int m = scanner.nextInt();
		while (m-- > 0) {
			int a = scanner.nextInt();
			System.out.println(a <= s && map[a] ? "yes" : "no");
		}

	}
}

Measured memory_bytes: 20312
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();
        }

        boolean[] isPush = new boolean[n];
        int cnt = 0;
        int botten = 1;
        while (botten != 2) {
            if (isPush[botten-1]) {
                cnt = -1;
                break;
            }
            isPush[botten-1] = true;
            botten = a[botten-1];
            cnt++;
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 51864
from math import factorial


def comb(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)


N = input()
K = int(input())
ans = 0
if K == 1:
    for i in range(1, len(N)):
        ans += 9
    ans += int(N[0])
elif K == 2:
    for i in range(K, len(N)):
        ans += 81 * comb(i - 1, 1)
    for i1 in range(1, 10):
        for i2 in range(1, 10):
            for p in range(len(N) - 1):
                if str(i1) + "0" * (len(N) - p - 2) + str(i2) + "0" * p <= N:
                    ans += 1
elif K == 3:
    for i in range(K, len(N)):
        ans += 729 * comb(i - 1, 2)
    for i1 in range(1, 10):
        for i2 in range(1, 10):
            for i3 in range(1, 10):
                for p1 in range(1, len(N) - 1):
                    for p2 in range(p1):
                        st = str(i1) + "0" * (len(N) - p1 - 2) + str(i2) + \
                            "0" * (p1 - p2 - 1) + str(i3) + "0" * p2
                        if st <= N:
                            ans += 1

print(ans)


Measured memory_bytes: 49592
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
const int MAX_N = 400 * 400;
struct UnionFind{
    int par[MAX_N];
    int white[MAX_N];
    void init(int n){
        for(int i = 0;i < n;i++){
            par[i] = i;
            white[i] = 0;
        }
    }
    int root(int x){
        if(par[x] == x)return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y)return;
        par[y] = x;
    }
    int wcnt(int x){
        return white[root(x)];
    }
};
main(){
    int H,W;
    cin >> H >> W;
    UnionFind uf;
    uf.init(H * W);
    vector<string> V(H);
    rep(i,0,H){
        cin >> V[i];
    }

    int dy[] = {1,0,-1,0};
    int dx[] = {0,1,0,-1};
    rep(i,0,H)rep(j,0,W)rep(k,0,4){
        int ny = i + dy[k];
        int nx = j + dx[k];
        if(ny < 0 || ny >= H || nx < 0 || nx >= W)continue;
        if(V[i][j] != V[ny][nx])uf.unite(ny * W + nx, i * W + j);
    }
    ll cnt[H][W] = {};
    rep(i,0,H)rep(j,0,W){
        int r = uf.root(i * W + j);
        int y = r / W;
        int x = r % W;
        if(V[i][j] == '.')cnt[y][x]++;
    }
    ll ans = 0;
    rep(i,0,H)rep(j,0,W){
        int r = uf.root(i * W + j);
        int y = r / W;
        int x = r % W;
        if(V[i][j] == '#'){
            //cout << i << " " << j << endl;
            //cout << cnt[y][x] << endl;
            ans += cnt[y][x];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2944
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int k = scn.nextInt();

        int[] s = new int[n];
        Arrays.fill(s, 1);

        for (int i = 0; i < k; i++) {
            int d = scn.nextInt();
            for (int a = 0; a < d; a++) {
                int A = scn.nextInt();
                s[(A - 1)] = 0;
            }
        }

        int ans = 0;

        for (int i = 0; i < n; i++) {
            ans = ans + s[i];
        }

        System.out.println(ans);


        scn.close();
    }
}

Measured memory_bytes: 37332
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
const int N=2005*2;
int n,m;
struct qq
{
	int x,y,last;
}e[N];
int num,last[N];
void init (int x,int y)
{
	e[num].x=x;e[num].y=y;
	e[num].last=last[x];
	last[x]=num;
	num++;
}
int x[N],y[N];
vector<int> path[N],vec[N];
bool vis[N],used[N];//用过没有 
int sum[N];
bool dfs (int x,int fa,int t,int p)
{
	if (x==t) return true;
	for (int u=last[x];u!=-1;u=e[u].last)
	{
		int y=e[u].y;
		if (y==fa) continue;
		if (dfs(y,x,t,p))
		{
			path[p].push_back(u);
			sum[u>>1]++;
			vec[u>>1].push_back(p);
			return true;
		}
	}
	return false;
}
int main()
{
	num=0;memset(last,-1,sizeof(last));
	memset(used,false,sizeof(used));
	memset(vis,false,sizeof(vis));
	scanf("%d%d",&n,&m);
	for (int u=1;u<n;u++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		init(x,y);init(y,x);
	}
	for (int u=1;u<=m;u++)
	{
		scanf("%d%d",&x[u],&y[u]);
		dfs(x[u],0,y[u],u);
	}
	int ans=0;
	for (int u=0;u<n-1;u++)	ans=ans+min(sum[u],2);
	while (true)
	{
		int id=-1;
		for (int u=0;u<n-1;u++)
		{
			if (sum[u]==1&&(vis[u<<1]^vis[u<<1|1])==1)
			{
				id=vis[u<<1]==1?u<<1|1:u<<1;
				break;
			}
		}
	
		if (id==-1)
		{
			for (int u=0;u<n-1;u++)
			{
				if (sum[u]>0)//随便决策一下 
				{
					id=(u<<1);
					break;
				}
			}
			if (id==-1) break;
		}	
		int p=(id>>1);
		while (used[vec[p].back()]) vec[p].pop_back();
		int t=vec[p].back();vec[p].pop_back();
		used[t]=true;
		bool rev=false;
		for (int u=0;u<path[t].size();u++)
		{
			if ((path[t][u]^id)==1)
			{
				rev=true;
				break;
			}
		}
		if (rev==true)
		{
			for (int u=0;u<path[t].size();u++) path[t][u]^=1;
			swap(x[t],y[t]);
		}
		for (int u=0;u<path[t].size();u++) 
		{
			sum[path[t][u]>>1]--;
			vis[path[t][u]]=true;
		}
	}
	printf("%d\n",ans);
	for (int u=1;u<=m;u++)printf("%d %d\n",x[u],y[u]);
	return 0;
}

Measured memory_bytes: 13952
#include "bits/stdc++.h"
using namespace std;
// #define int long long
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define INF 2e18;
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(s) (int)s.size()
#define all(x) x.begin(), x.end()
typedef long double f80;
 
int x[105], y[105];
 
signed main()
{
    //freopen("inp.txt","r",stdin);
    //freopen("out.txt","w",stdout);
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    fr(i, 1, n) {
        cin >> x[i] >> y[i];
    }
    f80 z = (2 * acos(-1))/1000000;
    ll ans = 0;
    for(int i = 0; i < 1000000; i++) {
        f80 x1 = cos(z * i), y1 = sin(z * i);
        int xx = 0, yy = 0;
        fr(j, 1, n) {
            if(x1 * x[j] + y1 * y[j] >= 0) {
                xx += x[j], yy += y[j];
            }
        }
        ans = max(ans, (ll)xx * xx + (ll)yy * yy);
    }
    cout << setprecision(20) << fixed << sqrtl(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[12345];
int main(){
	scanf("%s",s);
	int len = strlen(s);
	long long ans =0;
	for(int t =0;t<(1<<(len-1));t++){
		long long num=s[0]-'0';
		for(int i= 0;i<len-1;i++){
			if(t&(1<<i)){
				ans+=num;
				num = 0;
			}
			num = num*10+s[i+1]-'0';
		}
		ans+=num;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>

int n;

void MH(int murata[],int i){
    
    int l,r,e,tmp;
    
    l = 2 * i;
    
    r = (2 * i) + 1;
    
    if(l <= n && murata[l] > murata[i]){
        e = l;
    }
    else e = i;
    
    if(r <= n && murata[r] > murata[e]) e = r;
    
    if(e != i){
        
        tmp=murata[i];
        murata[i]=murata[e];
        murata[e]=tmp;
        MH(murata,e);
        
    }
}

void BM(int murata[]){
    int i;
    for(i = n/2 ; i >=1 ; i--) MH(murata,i);
}



int main(){
    
    int i,murata[500000];
    
    scanf("%d",&n);
    
    for(i = 1 ; i <= n ; i++) scanf("%d",&murata[i]);
    
    BM(murata);
    
    for(i = 1 ; i<= n ; i++){
    
        printf(" %d",murata[i]);
    }
    
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 2552
N,A,B,C,D = map(int,input().split())
A -= 1
B -= 1
C -= 1
D -= 1
S = list(input())
if D < C:
    sl = [0]
    ml = [0]
    cnt = 0
    mcnt = 0
    for i in range(A+1,B-1):
        if [S[i],S[i+1]] == ['#','#']:
            cnt += 1
        elif [S[i],S[i+1]] == ['#','.']:
            sl.append(cnt)
            cnt = 0
        if i == B-2 :
            sl.append(cnt)
            cnt = 0
    for i in range(D+1,C):
        if [S[i],S[i+1]] == ['#','#']:
            cnt += 1
        elif [S[i],S[i+1]] == ['#','.']:
            sl.append(cnt)
            cnt = 0
        if i == C-1 :
            sl.append(cnt)
    for i in range(B-1,D+1):
        if [S[i],S[i+1]] == ['.','.']:
            mcnt += 1
        elif [S[i],S[i+1]] == ['.','#']:
            ml.append(mcnt)
            mcnt = 0
        if i == D:
            ml.append(mcnt)
            mcnt = 0
    if max(sl) >= 1:
        print('No')
    elif max(ml) <= 1:
        print('No')
    else:
        print('Yes')
else:
    acnt = 0
    bcnt = 0
    al = [0]
    bl = [0]
    for i in range(A+1,C):
        if [S[i],S[i+1]] == ['#','#']:
            acnt += 1
        elif [S[i],S[i+1]] == ['#','.']:
            al.append(acnt)
            acnt = 0
        if i == C-1 :
            al.append(acnt)
            acnt = 0
    for i in range(B+1,D):
        if [S[i],S[i+1]] == ['#','#']:
            bcnt += 1
        elif [S[i],S[i+1]] == ['#','.']:
            bl.append(bcnt)
            bcnt = 0
        if i == C-1 :
            bl.append(bcnt)
            bcnt = 0
    if max(al) >= 1:
        print('No')
    elif max(bl) >= 1:
        print('No')
    else:
        print('Yes')

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

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	int xa = x - a; if (xa < 0) xa *= -1;
	int xb = x - b; if (xb < 0) xb *= -1;
	if (xa < xb) cout << "A" << endl;
	else cout << "B" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 2e6;
bool sieve[MX];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	ll a, b;
	cin >> a >> b;
	ll g = __gcd(a, b);
	int ans = 1;
	for(ll i=2; i<MX; i++) {
		if(!sieve[i]) {
			for(ll j=i*2; j<MX; j+= i)
				sieve[j] = 1;
			if(g % i == 0) {
				while(g % i == 0)
					g /= i;
				ans++;
			}
		}
	}
	if(g > 1)
		ans++;
	cout << ans;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0,K = 0,ans = 0;
  cin >> N >> K;
  cout << min(N % K,abs(K - N % K));
}


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

int main(){
    int x, y;
    cin >> x >> y;
    for (int c = 0; c <= x; c++) {
        int t = x - c;
        int asi = c * 2 + t * 4;
        if (asi == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
using namespace std;
typedef complex<double> xy;
double eps = 1e-9;
double dot_product(xy a,xy b) {return (conj(a)*b).real();}
double cross_product(xy a,xy b) {return (conj(a)*b).imag();}
xy projection(xy p,xy b) {return b*dot_product(p,b)/norm(b);}
xy projection2(xy p1,xy p2,xy p){
    p -= p1; p2 -= p1;
    xy proj = projection(p,p2);
    return p1+proj;
}

bool is_online(xy a1,xy a2,xy p){
    return abs(a1-p)+abs(a2-p)<=abs(a1-a2)+eps;    
}

bool is_intersected(xy a1, xy a2, xy b1, xy b2){
    if(is_online(a1,a2,b1) || is_online(a1,a2,b2)) return true;
    if(is_online(b1,b2,a1) || is_online(b1,b2,a2)) return true;
    return (cross_product(a2-a1,b1-a1)*cross_product(a2-a1,b2-a1)<-eps) && 
    (cross_product(b2-b1,a1-b1)*cross_product(b2-b1,a2-b1))<-eps;
}

xy cross_point(xy a1, xy a2, xy b1, xy b2){
    xy b = b2-b1;
    double d1 = abs(cross_product(b,a1-b1));
    double d2 = abs(cross_product(b,a2-b1));
    double t = d1/(d1+d2);
    return a1+(a2-a1)*t;
}

int Q;
double X[5],Y[5];
int main(){
    cin >> Q;
    for(int i=0;i<Q;i++){
        for(int j=1;j<=4;j++){
            cin >> X[j] >> Y[j];
        }
        xy ans = cross_point(xy(X[1],Y[1]),xy(X[2],Y[2]),xy(X[3],Y[3]),xy(X[4],Y[4]));
        cout << fixed;
        cout << setprecision(10) << ans.real() << " " << ans.imag() << endl;     
    }
}


Measured memory_bytes: 3284
use std::io::BufRead;
fn main() {
    let stdin = std::io::stdin();
    let line = stdin.lock().lines().next().unwrap().unwrap();
    let mut split = line.split(' ').map(|x| x.parse::<u64>().unwrap());
    let (n, mut x) = (split.next().unwrap(), split.next().unwrap());

    if x * 2 == n {
        println!("{}", x * 3);
        std::process::exit(0);
    }

    // The resulting parallelogram is the same.
    if x > n / 2 {
        x = n - x;
    }
    let mut dist = n;
    // Starting from an obtuse angle.  a is the longer edge.
    let (mut a, mut b) = (n - x, x);
    loop {
        let rem = a % b;
        if rem == 0 {
            dist += (a - rem) * 2 - b;
            break;
        }
        dist += (a - rem) * 2;
        a = b;
        b = rem;
    }
    println!("{}", dist);
}


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

bool checkPrimeNumber(int N) {
  bool check = true;
  for (int i = 2; i <= sqrt(N); i++) {
    check = (N % i != 0);
    if (!check) break;
  }
  return check;
}

int main() {
  int N;
  cin >> N;
  int ANS = 0;
  for (int i = 0; i < N; i++) {
    int TEMP;
    cin >> TEMP;
    if (checkPrimeNumber(TEMP)) ANS++;
  }
  
  cout << ANS << endl;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/
#define int ll
void Calc() {
  int n, c, k;
  in, n, c, k;

  auto t = in.Array<ll>(n);
  sort(all(t));
  int pre = 0;
  int pre_c = c;
  int cnt = 0;
  for (auto& i : t) {
    if (pre < i || pre_c == 1) {
      cnt++;
      pre = i + k;
      pre_c = c;
      err(pre);
    } else pre_c--;
  }
  cout << (cnt) << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

void write(int, int);

int main() {
    int H, W;
    while(1) {
        scanf("%d%d", &H, &W);
    
        if (H == 0 && W == 0) break;
    
        write(H, W);
    }
    return 0;
}

void write(int H, int W) {
    int i, j;
    
    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) {
            if (i % 2 == 1 && j % 2 == 1) printf("#");
            
            else if (i % 2 == 1 && j % 2 == 0) printf(".");
            
            else if (i % 2 == 0 && j % 2 == 1) printf(".");
            
            else if (i % 2 == 0 && j % 2 == 0) printf("#");
        }
        printf("\n");
    }
    printf("\n");
}


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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    
    std::vector< bool > PM(1e6+1, true);
    std::vector< int > PM_list;
    std::vector< int > PM_list_sqrt;
    std::map< int, int > PM_map;
    for(int i=2; i<=1e6; i++){
        if(PM[i]){
            PM_list.push_back(i);
            if(i <= 1000){
                PM_list_sqrt.push_back(i);
            }
            PM_map[i] = 0;
            for(int j=i+i; j<=1e6; j+=i){
                PM[j] = false;
            }
        }
    }
    
    //std::vector< int > PM_cnt(PM_list.size(), 0);
    
    for(int i=0; i<N; i++){
        while(A[i] != 1){
            auto find_itr = PM_map.find(A[i]);
            if(find_itr != PM_map.end()){
                PM_map[find_itr->first]++;
                A[i] = 1;
            }else{
                for(int j=0; j<PM_list_sqrt.size(); j++){
                    if(A[i] % PM_list_sqrt[j] == 0){
                        while(A[i] % PM_list_sqrt[j] == 0){
                            A[i] /= PM_list_sqrt[j];
                        }
                        PM_map[PM_list_sqrt[j]]++;
                        break;
                    }
                }
            }
        }
    }
    
    int f = 2;
    for(int j=0; j<PM_list.size(); j++){
        if(PM_map[PM_list[j]] == N){
            f = 0;
            break;
        }else if(PM_map[PM_list[j]] > 1){
            f = 1;
        }
    }
    
    if(f == 2){
        std::cout << "pairwise coprime" << std::endl;
    }else if(f == 1){
        std::cout << "setwise coprime" << std::endl;
    }else{
        std::cout << "not coprime" << std::endl;
    }
    
    
    return 0;
    
}


Measured memory_bytes: 11260
N = int(input())
A = list(map(int,input().split()))
ABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)
prev = [0]
for k, (a, i) in enumerate(ABI):
    curr = [0]*(k+2)
    for l in range(k+1):
        curr[l] = max(curr[l], prev[l] + a*abs(N-i-(k-l)))
        curr[l+1] = prev[l]+a*abs(i-l-1)
    prev = curr
print (max(prev))

Measured memory_bytes: 9436
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define max_n 100000

int main(){
  int n;
  int a[max_n];
  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n);

  int index = 0;
  int ret = 0;
  while(index < n){
    int num = 0;
    int tmp = a[index];
    while(index < n && a[index] == tmp){
      num++;
      index++;
    }
    ret += num%2;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,j,k,n;
	cin>>k>>n;
	vector<ll> v;
	for(i=0;i<n;i++)
	{
		cin>>j;
		v.pb(j);
	}
	ll min1 = v[n-1] - v[0];
	for(i=1;i<n;i++)
		min1 = min(min1, (k - v[i]) + v[i-1]);
	cout<<min1<<endl;
	return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int out=0;
    rep(i,n/2){
      vector<string>in(2);
      rep(j,2)cin>>in[j];
      sort(all(in));
      if(in[0]=="lu"&&in[1]=="ru")out++;
      if(in[0]=="ld"&&in[1]=="rd")out++;
    }
    if(n%2){
      string s;cin>>s;
    }
    cout<<out<<endl;
  }
}

Measured memory_bytes: 1216
N, M = map(int, raw_input().split())

A = [0] * M
for i in xrange(N):
    K = map(int, raw_input().split())
    for j in xrange(1, len(K), 1):
        A[K[j]-1] += 1

count = 0
for a in A:
    if a == N: count += 1

print count


Measured memory_bytes: 2568
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)
#define emax(l, r) l = max(l, r)
#define vmin(l, r) l = min(l, r)

template<class T, class U>
bool contains(const T & vec, const U & value) {
    return vec.find(value) != vec.end();
}

ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


typedef pair<ll, ll> pll;

void proc(ll x, ll h, ll& w, vector<pll>& hs, ll& ans) {
    if (x < w) {
        hs.emplace_back(x, h);
        ans += (w - x - 1) * (h - 2);
        w = x;
    } else {
        auto it = lower_bound(hs.begin(), hs.end(), pll(x, -1), [](const pll& left, const pll& right)
                              {
                                  return left.first > right.first;
                              });
        ans -= it->second - 2;
    }
}

int main()
{
    ll n, q;
    cin >> n >> q;
    ll ans = 0;
    ll h = n, w = n;
    vector<pll> hs, ws;
    rep(_, q) {
        ll c, x;
        cin >> c >> x;
        if (c == 1) {
            proc(x, h, w, hs, ans);
        } else {
            proc(x, w, h, ws, ans);
        }
    }
    ans += (h - 2) * (w - 2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6864
//
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string str;
    //int n = 0;
    cin >> str;
    
    
    for(int i = (int)str.size() - 1; i >= 0; i--){
        printf("%c", str[i]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 3204
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<map>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
	int n;
	int out=100000;
	cin>>n;
	rep(i,n){
		out*=1.05;
		if(out%1000)out+=1000-out%1000;
	}
	cout<<out<<endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(void)
{
    int i, n, l, a[200], ans=0, mina=200000, j, sum=0, minb;
    scanf("%d%d", &n, &l);
    for(i=0;i<n;i++){
        a[i]=l+i;
        sum=sum+a[i];
    }
    for(i=0;i<n;i++){
        ans=0;
        for(j=0;j<n;j++){
            if(i!=j)ans=ans+a[j];
        }
        if(max(ans, sum)-min(ans, sum)<mina){
            mina=max(ans, sum)-min(ans, sum);
            minb=ans;
        }
    }
    printf("%d\n", minb);
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    string s;
    cin >> n >> s;

    vector<ll> x1(n), x2(n);
    REP(i, n) {
        if(i) x1[i] = x1[i-1];
        if(s[i]=='#') x1[i]++;
    }
    for(ll i=n-1; i>=0; --i) {
        if(i!=n-1) x2[i] = x2[i+1];
        if(s[i]=='.') x2[i]++;
    }

    ll ret = x2[0];
    chmin(ret, x1[n-1]);
    REP(i, n-1) {
        chmin(ret, x1[i]+x2[i+1]);
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3732
n,k = gets.chomp.split(' ').map(&:to_i)
d = gets.chomp.split(' ').map(&:to_s)

pay = n
while true
  chars = pay.to_s.chars
  found = false
  chars.each do |s|
    if d.include?(s)
      found = true
      break
    end
  end
  break if not found
  pay += 1
end

puts pay


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int MAX = 110;
const int MAX2 = 1e5 + 10;
const long long inf = 0x3f3f3f3f3f3f3f3fll;
int main() {
	int n, w;
	scanf("%d %d", &n, &w);
	vector<int> values(n), weight(n);
	for(int i = 0; i < n; ++i)scanf("%d %d", &weight[i], &values[i]);
	int maxVal = 100000;
	vector<long long>dp(maxVal + 10, inf);
	dp[0] = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = maxVal - values[i]; j>= 0; --j) {
			dp[j + values[i]] = min(dp[j + values[i]], weight[i] + dp[j]);
		}
	}
	long long ans = 0;
	for(int i = 0; i <= maxVal; ++i) {
		if(dp[i] <= w)ans = max(ans, 1ll*i);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int a,b;
  cin>>a >> b;
  int ans;
  if(a == b) {
    ans = a + b;
  } else if (a > b) {
    ans = a + a - 1;
  } else {
    ans = b + b - 1;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
//	freopen("input.txt","r",stdin);
	
	int n,x,t;
	cin>>n>>x>>t;
	int num;
	if(n%x==0) num=n/x;
	else num=n/x+1;
	cout<<num*t; 
	
	return 0;
} 

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

#include <math.h>
#include <stdlib.h>


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

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 int INF = 1001001001;
// long long max => LLONG_MAX

const ll mod = 1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<int>c(3, -1);
    ll ans = 1;

    for(int i = 0 ; i < n; i++){
        int cnt = 0;
        for(int j = 0; j < 3; j++){
            if(a[i] == c[j]+1) cnt++ ;
        }
        ans *= cnt;
        ans %= mod;

        if(a[i] == c[0]+1) c[0]++;
        else if(a[i] == c[1]+1) c[1]++;
        else c[2]++;
    }

    int cnt = 0;
    for(int i = 0; i < 3; i++){
        if(c[i] > -1) cnt++;
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INFI = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 102, MAXK = 1e5+2;
int N, K, a[MAXN];
bool dp[MAXK][2], vis[MAXK][2];
bool solve(int stones, int turn){
	if(vis[stones][turn])return dp[stones][turn];
	vis[stones][turn] = true;
	if(stones==0) return dp[stones][turn]=false;
	for(int i = 1;i<=N;i++){
		if(a[i]==stones)return dp[stones][turn]=true;
		if(a[i]<stones){
			if(!solve(stones-a[i], turn^1))return dp[stones][turn]=true;
		}
	}
	return dp[stones][turn]=false;
}
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N >> K;
	for(int i = 1;i<=N;i++)cin >> a[i];
	if(solve(K, 0)){
		cout << "First" << nl;
	}else{
		cout << "Second" << nl;
	}
	return 0;
}

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

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

  int I=0,J=0,O=0,JO=0,IOI=0,JOI=0;
  for(int i=0;i<n;i++){
    if(str[i]=='I'){
      I++;
      if(O*J*JO)J--,JO--,O--,JOI++;
      else if(O*I)O--,IOI++;
    }

    if(str[i]=='O') {
      if(I-IOI+J>O) O++;
      if(J>JO) JO++;
    }
    if(str[i]=='J') J++;
  }

  cout<<JOI + min( IOI,(I-JOI)/2 )<<endl;

return 0;
}

Measured memory_bytes: 2068
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[101];
int main() {
	int n;
	cin >> n;
	int ans = 1000000000;
	rep(i, n) { cin >> a[i]; }
	for (int i = -100; i < 101; i++) {
		long long s = 0;
		rep(j, n) {
			s+=(a[j] - i)*(a[j] - i);
			
		}
		if (s < ans) { ans = s; }
	}
	cout << ans << endl;
}


Measured memory_bytes: 256