akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
using namespace std;

#define rep(i, n)       rep2 (i, 0, n)
#define rep2(i, m, n)   for (int i = m; i < int(n); ++i)

typedef long long ll;

int cur, sz;
string str;

ll parse_num() {
    int a = 0;
    if (cur >= sz || !isdigit(str[cur]) || str[cur] == '0') throw "invalid";
    while (cur < sz && isdigit(str[cur]))
        a = a * 10 + (str[cur++] - '0');
    return a;
}
ll parse_or();
ll parse_fact() {
    if (cur < sz && str[cur] == '(') {
        ++cur;
        int a = parse_or();
        if (cur >= sz || str[cur++] != ')') throw "invalid";
        return a;
    }
    return parse_num();
}
ll parse_term() {
    ll a = parse_fact();
    while (cur < sz && str[cur] == '*') ++cur, a *= parse_fact();
    return a;
}
ll parse_plus() {
    ll a = parse_term();
    while (cur < sz && (str[cur] == '+' || str[cur] == '-')) {
        char op = str[cur++];
        ll b = parse_term();
        op == '+' ? a += b : a -= b;
    }
    return a;
}
ll parse_and() {
    ll a = parse_plus();
    while (cur < sz && str[cur] == '&') ++cur, a &= parse_plus();
    return a;
}
ll parse_xor() {
    ll a = parse_and();
    while (cur < sz && str[cur] == '^') ++cur, a ^= parse_and();
    return a;
}
ll parse_or() {
    ll a = parse_xor();
    while (cur < sz && str[cur] == '|') ++cur, a |= parse_xor();
    return a;
}
ll parse() {
    cur = 0;
    sz = str.size();
    ll a = parse_or();
    if (cur < sz) throw "invalid";
    return a;
}

vector<string> next() {
    vector<string> res;
    string tmp, ch = "0123456789*+-&^|";
    rep (i, str.size() + 1) {
        tmp = str;
        tmp.insert(i, 1, ' ');
        rep (j, 16) { tmp[i] = ch[j]; res.push_back(tmp); }
    }
    rep (i, str.size()) {
        tmp = str;
        tmp.erase(i, 1);
        res.push_back(tmp);
    }
    return res;
}

int main()
{
    int n;
    while (cin >> n >> str, n) {
        ll a = -1e18;
        vector<string> v = next();
        if (n % 2 == 1) {
            rep (i, v.size()) {
                str = v[i];
                try { a = max(a, parse()); } catch (...) {}
            }
        } else {
            rep (i, v.size()) {
                str = v[i];
                try { parse(); } catch (...) { continue; }
                ll b = 1e18;
                vector<string> w = next();
                rep (j, w.size()) {
                    str = w[j];
                    try { b = min(b, parse()); } catch (...) {}
                }
                a = max(a, b);
            }
        }
        cout << a << endl;
    }
}

Measured memory_bytes: 1308
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    if (A > 2 * C && B > 2 * C) {
        int nc = max(X, Y);
        cout << 2 * nc * C << endl;
    } else if (A > 2 * C && X >= Y) {
        cout << 2 * X * C << endl;
    } else if (B > 2 * C && X <= Y) {
        cout << 2 * Y * C << endl;
    } else if (A + B > 2 * C) {
        int nc = min(X, Y);
        cout << (X - nc) * A + (Y - nc) * B + 2 * nc * C << endl;
    } else {
        cout << X * A + Y * B << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int Add(int n, int s, int cnt, int num, int sum);

int answer;
int ocu[10];
int main(void){
	int n, s, sum, cnt;
	int factrial;
	int i;
	
	while(1){
		for(i=0; i<10; i++){
			ocu[i] = 0;
		}
		answer = 0;
		sum = 0;
		cnt = 0;
		factrial = 1;
		scanf("%d %d", &n, &s);
		if(n == 0 && s == 0) break;

		for(i=n; i >= 1; i--){
			factrial *= i;	
		}

		for(i=0; i<10; i++){
			ocu[i] = 1;
			cnt++;
			if(Add(n, s, cnt, i, sum) == 1) break;	
			ocu[i] = 0;
			cnt--;
		}
		printf("%d\n", answer / factrial);
	}
}

int Add(int n, int s, int cnt, int num, int sum){
	int i;
	sum += num;
	if(cnt == n){
		if(sum == s){
		   	answer++; 	
			return 1;
		}
	}else{
		for(i=0; i<10; i++){
			if(ocu[i] == 0){
				ocu[i] = 1;
			}else{
				continue;
			}
			cnt++;
			if(Add(n, s, cnt, i, sum) == 1){
				ocu[i] = 0;
				cnt--;
				break;
			}
			
			ocu[i] = 0;
			cnt--;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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,a,b,c;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  rep(i,n) cin >> l[i];

  int m = (1<<n)-1;
  vector<pair<ll,ll>> ls(m);
  ls[0].first = 1e9;
  rep(x,m){
    rep(i,n){
      if((x&(1<<i))>0){
        ls[x].first += l[i];
        ls[x].second++;
      }
    }
  }
  ll ans = 1e9;
  rep(i,m){
    if(ls[i].second>a) continue;
    rep(j,m){
    if((i&j)>0) continue;
    if(ls[j].second>b) continue;
      rep(k,m){
        if((i&k)>0 || (j&k)>0) continue;
        if(ls[k].second>c) continue;
        ll temp = abs(ls[i].first-a) + 10*(ls[i].second-1)
                + abs(ls[j].first-b) + 10*(ls[j].second-1)
                + abs(ls[k].first-c) + 10*(ls[k].second-1);
        ans = min(ans,temp);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		//System.out.println(S);
		if (S.equals("Sunny")) {
			System.out.println("Cloudy");
		} else if (S.equals("Rainy")) {
			System.out.println("Sunny");
		} else {
			System.out.println("Rainy");
		}
	}
}


Measured memory_bytes: 21204
function Main(input) {
  "use strict"
	const temp = input.split("\n");

	const s = temp.shift();
  switch(s){
    case 'Sunny':
      console.log('Cloudy');
      break;
    case 'Cloudy':
      console.log('Rainy');
      break;
    case 'Rainy':
      console.log('Sunny');
      break;
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJDPL_1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NW = ReadInt();
            int N = NW[0];
            int W = NW[1];

            int[] v = new int[N];
            int[] w = new int[N];
            for (int i = 0; i < N; i++)
            {
                var input = ReadInt();
                v[i] = input[0];
                w[i] = input[1];
            }

            int[,] dp = new int[N + 1, W + 1];
            for (int i = 1; i < N + 1; i++)
            {
                for (int j = 0; j < W + 1; j++)
                {
                    if (j < w[i-1])
                    {
                        dp[i, j] = dp[i - 1, j];
                    }
                    else dp[i, j] = Math.Max(dp[i, j - w[i-1]] + v[i-1], dp[i - 1, j]);
                }
            }

            Console.WriteLine(dp[N, W]);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 21812
#include<bits/stdc++.h>
using namespace std;
int ans=700,n;
char s[10];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++)
		if(s[i]=='o')ans+=100;
	printf("%d",ans);
	return 0;
}

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

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

	ll A,B,K;
	ll prime[100000]={};
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	vector<int> given;

	cin >> A >> B >> K;

	A=A-K;
	if(A<0) B=B-abs(A);

	if(A<0) A=0;
	if(B<0) B=0;

	cout << A << " " << B << endl;

	return 0;
}



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 sx,sy,tx,ty,dx,dy;
	cin>>sx>>sy>>tx>>ty;
	string ans="";
	dx=abs(tx-sx);
	dy=abs(ty-sy);

	rep(i,dy)ans+='U';
	rep(i,dx)ans+='R';

	rep(i,dy)ans+='D';
	rep(i,dx)ans+='L';

	ans+='L';
	rep(i,dy+1)ans+='U';
	rep(i,dx+1)ans+='R';
	ans+='D';

	ans+='R';
	rep(i,dy+1)ans+='D';
	rep(i,dx+1)ans+='L';
	ans+='U';

	cout<<ans<<endl;
}

Measured memory_bytes: 256
import itertools
import math

N = int(input())
L = []
for i in range(N):
    X, Y = map(int, input().split())
    L.append((X, Y))

total = 0
cnt = 0
for l in itertools.permutations(L):
    cnt += 1
    for i in range(1, N):
        total += math.sqrt((l[i][0]-l[i-1][0])**2 + (l[i][1]-l[i-1][1])**2)

print(total/cnt)

Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)

const int INF = INT_MAX;

int main(){

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

	int k,x;cin>>k>>x;
	if(k*500>=x) cout<<"Yes";
	else cout<<"No";
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define rep(x, l, r) for(int x = l; x <= r; x++)
#define repd(x, r, l) for(int x = r; x >= l; x--)
#define clr(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define MAXN 100005
#define fi first
#define se second
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int INF = 1 << 30;
const int p = 1e9;
int lowbit(int x){ return x & (-x);}
int fast_power(int a, int b){ int x; for(x = 1; b; b >>= 1){ if(b & 1) x = 1ll * x * a % p; a = 1ll * a * a % p;} return x % p;}

int ans[MAXN];

int main(){
	int n, k, s;
	scanf("%d%d%d", &n, &k, &s);
	rep(i, 1, k) ans[i] = s;
	rep(i, k + 1, n) ans[i] = s % p + 1;
	rep(i, 1, n) printf("%d ", ans[i]);
	puts("");
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(int*)b - *(int*)a; // 大きい順
}

int main(void){
  int n;
  int h[101] = {0};
  int a[101] = {0};
  int sum;
  int l = 0, r = 0;

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

  
  while(1){
     //もう足さなくていいところを確認
    for(int i = 0; i < n; i++){
      //      printf("h[%d] = %d, a[%d] = %d, l = %d\n", i, h[i], i, a[i], l);
      if(h[i] == a[i]){
	l = i + 1;
	if(i == n - 1){
	  printf("%d\n", sum);
	  return 0;
	}
      }else{
	//	printf("break h[%d] = %d, a[%d] = %d, l = %d\n", i, h[i], i, a[i], l);
	break;
      }
    }

    r = l;
    sum++;
    //どこまで足すか決める
    for(int i = l; i < n; i++){
      if(h[i] - a[i] > 0){
	r++;
      }else{
	break;
      }
      //      printf("h[%d] = %d, a[%d] = %d, r = %d\n", i, h[i], i, a[i], r);
    }

    //足す
    for(int i = l; i < r; i++){
      a[i]++;
    }
    //    printf("a sum = %d \n", sum);
  }
  
  //  printf("%d\n", sum);

  return 0;
}


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

using namespace std;


int main()
{
    int c=0;
    map<char ,int> mp;
    string s;

    map<char,int>::iterator it;
    cin>>s;

    for(int i=0;i<s.size();i++)
        mp[s[i]]++;
        for(it=mp.begin();it!=mp.end();it++)
           if((*it).second==2)
            c++;
            else
                return cout<<"No" ,0;

           if(c==2)
            cout<<"Yes"<<endl;
           else
            cout<<"No"<<endl;
      return 0;

}


Measured memory_bytes: 256
/*
* @author:  codancer
* @createTime:  time
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
int main(){
	ll x;
	cin>>x;
	ll a=x/500;
	x%=500;
	a*=1000;
	ll b=x/5;
	b*=5;
	cout<<a+b<<endl;
	return 0;
}

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

int main(){
	unsigned long long int n;
	cin >> n;
	
	
	unsigned long long int x,y;
	unsigned long long int res = 1e12+7;
	for(unsigned long long int i=1;i*i<=n;++i){
		x = i;
		if(n%x == 0){
			y = n/x;
			x--;
			y--;
			res = min(res,x+y);
		}
	}
	
	cout<< res <<endl;
	
	
	return 0;
}

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

int main() {
  double D, T, S;
  cin >> D >> T >> S;
  
  double min = D / S;
  
  if (min <= T && S != 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 50LL);
const int  maxn = 1e6 + 5;
int n;
int arr[maxn];
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i =0 ; i < n; i ++){
        cin >> arr[i];
    }
    sort(arr, arr + n);
    int sum = 0;
    for(int i =0 ; i < n - 1; i ++){
        sum += arr[i];
    }
    if(sum > arr[n - 1]){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}


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

int rec(int arr[], int n, int mem[])
{
  	if(n<=0)
    	return INT_MAX;
    if(n==1)
      	return 0;
  	if(mem[0]!=-1)
      	return mem[0];
    int a=rec(arr+1,n-1,mem+1);
    if(a!=INT_MAX)
    	a+=abs(arr[0]-arr[1]);
  	int b=rec(arr+2,n-2,mem+2);
  	if(b!=INT_MAX)
  		b+=abs(arr[0]-arr[2]);
  	mem[0]=min(a,b);
  	return mem[0];
}

int main(){
	int n;
  	cin>>n;
  	int arr[n],mem[n];
  	for(int i=0;i<n;i++)
      	cin>>arr[i];
  	for(int i=0;i<n;i++)
      	mem[i]=-1;
 	cout<<rec(arr,n,mem)<<endl;
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    int K = Integer.parseInt(r.readLine());

    long[] arr = new long[114514];
    long[] start_low = new long[114514];
    long[] start_high = new long[114514];
    long[] retired_low = new long[114514];
    long[] retired_high = new long[114514];
    long[] cleared_low = new long[114514];
    long[] cleared_high = new long[114514];

    String s = r.readLine();
    String[] sl = s.split("[\\s]+");
    for(int i = 0; i < K; i++)
    {
      arr[i] = Long.parseLong(sl[i]);
    }

    if(arr[K - 1] != 2)
    {
      System.out.println("-1");
      System.exit(0);
    }

    start_low[K] = 2;
    start_high[K] = 3;
    cleared_low[K] = 2;
    cleared_high[K] = 2;
    retired_low[K] = 0;
    retired_high[K] = 1;

    for(int i = K - 1; 0 <= i; i--)
    {
      cleared_low[i] = (start_low[i + 1] + arr[i] - 1) / arr[i] * arr[i];
      cleared_high[i] = start_high[i + 1] / arr[i] * arr[i];
      retired_low[i] = 0;
      retired_high[i] = arr[i] - 1;
      start_low[i] = cleared_low[i] + retired_low[i];
      start_high[i] = cleared_high[i] + retired_high[i];

      if(start_low[i] > start_high[i])
      {
        System.out.println("-1");
        System.exit(0);
      }
    }

    System.out.printf("%d %d\n", start_low[0], start_high[0]);


  }

}

Measured memory_bytes: 62292
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
dd = inpl()
dd.sort()

print(dd[N//2]-dd[N//2-1])


Measured memory_bytes: 15536
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int ans = 0;
	int a, b;
	cin >> a >> b;
	vector<int> an(a);
	vector<int> br(b);
	for (int i = 0; i < a; i++) {
		cin >> an[i];
	}
	for (int i = 0; i < b; i++) {
		cin >> br[i];
	}
	for (int i = 0; i < b; i++) {
		int th = i;
		for (int j = 0; j < a and th<b; j++) {
			if (an[j] == br[th]) {
				th++;
			}
		}
		ans = max(ans, th - i);
	}
	cout << ans << endl;
}


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

using namespace std;

vector<int> pal_nums;

int CalculatePal(const string & s) {
    int ans = 0;
    for (auto i = 0; i < (s.size() + 1) / 2; ++i) {
        if (s[i] != s[s.size() - i - 1]) {
            return -1;
        } else {
            ans += abs(pal_nums[i] - pal_nums[pal_nums.size() - i - 1]);
        }
    }
    return ans;
}

int main()
{
    string s;
    string s_processing;
    
    cin >> s;
    int p_num = 0;
    for (auto & c: s) {
        if (c != 'x') {
            s_processing.push_back(c);
            pal_nums.push_back(p_num);
            p_num = 0;
        } else {
            ++p_num;
        }
    }
    pal_nums.push_back(p_num);

    
    cout << CalculatePal(s_processing);

    return 0;
}

Measured memory_bytes: 1148
N, D = map(int, input().split())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

count = 0
for i in range(N):
    if (X[i]**2 + Y[i]**2)**0.5 <= D:
        count += 1
print(count)

Measured memory_bytes: 24916
//#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int p, q, r;
    cin >> p >> q >> r;

    cout << min(min(p + q, p + r), q + r) << endl; 
    return 0;
} /*atcoder*/


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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e15+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vi a(m);
    vi b(m);
    vi c(m);
    rep(i,m){
        cin>>a[i];
        cin>>b[i];
        c[i] = 0;
        rep(j,b[i]){
            ll temp;
            cin>>temp;
            temp--;
            c[i] = c[i] | (1<<temp);
        }
    }
    ll jmax = (1<<n) - 1;
    ll dp[m][jmax+1];
    //memset(dp, 0 , sizeof(dp[0][0]) * m * (jmax+1));

    for(int i = 0; i < m; i++){
        for(int j=0; j<=jmax; j++){
            if(j == 0){
                dp[i][j] = 0;
            } else {
                dp[i][j] = INF;
            }
        }
    }


    for(int i=0; i<m; i++){
        for(int j=0 ; j<=jmax; j++){
            if(i > 0){
                dp[i][j] = min(dp[i][j],dp[i-1][j]);
            }
            int k=0;
            for(int box = 0; box < n; box++){
                if(!((1<<box) & (c[i])) && ((1<<box) & (j))){
                    k = k | (1<<box);
                }
            }
            //cout<<"i,j,k= " <<i<<" "<<j<<" "<<k<<endl;
            if(i>0){
                dp[i][j] = min(dp[i][j], a[i] + dp[i-1][k]);
            } else {
                if(k == 0){
                    dp[i][j] = min(dp[i][j] , a[i]);
                }
            }
        //cout<<dp[i][j]<<" ";;
        }
        //cout<<endl;

    }
    if(dp[m-1][jmax] < MOD){
        cout<<dp[m-1][jmax]<<endl;
    } else {
        cout<<-1<<endl;
    }


    timer();
    return 0;
}


Measured memory_bytes: 32256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int c=0;
	for(int i=0;i<s.size();i++){
		if(c==0){
			if(s[i]=='C')c=1;
		}
		else if(s[i]=='F'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}	 
	 


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        ProblemI.main();
    }
}

class ProblemI {
    /*
    * Idea: build DP of prob of having j heads using first i coins (i=1,...,N, j=0,...,i)
    * DP[i][j] = DP[i-1][j]*(1-P[i]) + DP[i-1][j-1]* P[i]
    * Time & space complexity = 2+3+...+(n+1) = O(n^2)
     * */
    static int N;
    static double[] p;
    static double[][] dp;

    static void main() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        dp = new double[N + 1][N + 1];
        p = new double[N + 1];
        for (int i = 1; i <= N; i++) {
            p[i] = sc.nextDouble();
        }

        // initial condition
        dp[1][1] = p[1];
        dp[0][0] = 1;
        for (int i = 1; i <= N; i++) dp[i][0] = dp[i-1][0] * (1 - p[i]);


        // implement dp
        for (int i = 2; i <= N; i++) {
            for (int j = 1; j <= i; j++) {
                dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1] * p[i];
            }
        }

        // get ans
        double ans = 0;
        for (int j = N/2 + 1; j<=N; j++) {
            ans+=dp[N][j];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 134072
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll memo[1001];
int calc(int idx, vector<string>& v){
  int N = v.size();
  if(idx == N) return 1;
  if(memo[idx] != -1) return memo[idx];
  ll &res = memo[idx];
  res = 0;
  string s;
  string mask[4] = {
    "0xxxxxxx",
    "110yyyyx10xxxxxx",
    "1110yyyy10yxxxxx10xxxxxx",
    "11110yyy10yyxxxx10xxxxxx10xxxxxx"
  };
  for(int l = 0; l < 4; l++){
    if(idx + l == N) return res;
    s += v[idx + l];
    bool y_judge[256] = {};
    bool ok = true;
    REP(i, mask[l].size()) {
      if(mask[l][i] == 'y'){
        y_judge[s[i]] = true;
      }
      if(mask[l][i] == '0' && s[i] == '1') ok = false;
      if(mask[l][i] == '1' && s[i] == '0') ok = false;
    }
    if(l >= 1 && !y_judge['x'] && !y_judge['1']) ok = false;
    if(!ok) continue;
    ll cnt1 = 1, cnt2 = 1;
    REP(i, mask[l].size()){
      if(mask[l][i] == 'y' && s[i] == 'x') cnt1 <<= 1;
      if(mask[l][i] == 'x' && s[i] == 'x') cnt2 <<= 1;
    }
    if(l >= 1 && !y_judge['1']) cnt1--;
    res += cnt1 * cnt2 * calc(idx + 1 + l, v);
    res %= 1000000;
  }
  return res;
}
int main(){
  int N;
  while(cin>>N && N){
    vector<string> v(N);
    REP(i, N) cin>>v[i];
    memset(memo, -1, sizeof(memo));
    cout<<calc(0, v)<<endl;
  }
  return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	Int ans = n*(n+1)/2;
	for(Int i=1; 3*i<=n; ++i)
		ans -= 3*i;
	for(Int i=1; 5*i<=n; ++i)
		ans -= 5*i;
	for(Int i=1; 15*i<=n; ++i)
		ans += 15*i;
	cout << ans << "\n";
}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int a[111];
int main(void){
  while(cin >> n && n){
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    int sum = 0;
    for(int i = 1; i < n-1; i++) sum += a[i];
    cout << sum/(n-2) << endl;
  }
}

Measured memory_bytes: 1176
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] abc = scanner.nextLine().split(" ", 3);

        int[] arr = new int[3];
        arr[0] = Integer.parseInt(abc[0]);
        arr[1] = Integer.parseInt(abc[1]);
        arr[2] = Integer.parseInt(abc[2]);
        Arrays.sort(arr);

        System.out.println(arr[0] + arr[1] + arr[2] * 10);
    }
}


Measured memory_bytes: 21844
# include <iostream>
# include <string.h>
using namespace std;
const int N=56;
char a[N];
int n;
void work (void)
{
	a[n-8]='\0';
	cout<<a;
}
int main (void)
{
	cin>>a;
	n=strlen (a);
	work ();
	return 0;
}


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


int f(int a, int k) {
    if (a % k != 0) {
        int d = a % k;
        int m = a / k + 1;

        if (d < m * 2) return f(a - m, k);
        else {
            int c = d / m;
            return f(a - m * c, k);
        }
    } else return a / k;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        bool flag=0;
        int x=0;
        for(int i=0;i<n;i++)
        {
            int res=0;
            int a,b;
            scanf("%d%d",&a,&b);
            //printf("%d\n",f(a,b));
            x^=f(a,b);
        }
        puts(x?"Takahashi":"Aoki");
        //printf("%d\n\n",res);
    }
}


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

	using namespace std;
	//500 yen= 1000 happypoints
	//5 yen= 5 happypoints
	int main(){
		long long money;
		long long happyPoints=0;
		cin>>money;
		happyPoints+= (money/500)*1000;
		happyPoints+= ((money%500)/5)*5;//we divide by 5 and then multiply by 5 to erase units (24/5=4, 4*5=20)
		cout<< happyPoints;
	return 0;
	}


Measured memory_bytes: 256
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *NOIP 2019 RP++                                           *
 ***********************************************************/
//#pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
    char *pp = (char*)malloc(size) + size;  \
    __asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) ((x>y)?x:y)
#define Min(x,y) ((x<y)?x:y)
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (int)(1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
//char buf[1<<20],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());return x*f;
}
template<typename T>
inline void write(T a){
    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//
char s[200020];
ll n,a[200020],bc[200020],ans,x,y;
inline int ch(){
	FOR(i,1,n-2)if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')return i;
	return 0;
}
signed main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    while(ch()){
    	FOR(i,1,n)a[i]=bc[i]=0;
	    for(int i=n;i>1;--i)if(s[i-1]=='B'&&s[i]=='C')bc[i]=bc[i+1]+1,bc[i-1]=bc[i],--i;
	    for(int i=1;i<n-1;++i){
	    	if(s[i]=='A')a[i]=a[i-1]+1;
//	    	write_(i,a[i],bc[i+1]);
//	    	printf("%s\n",s+1);
		    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
		    	x=a[i];y=bc[i+1];
		    	ans+=1ll*Min(x,y)*(abs(x-y)+Min(x,y));
		    	for(int j=i-x+1;j<=i-x+y*2;++j)s[j]='B',s[j+1]='C',++j;
		    	for(int j=i-x+y*2+1;j<=i+y*2;++j)s[j]='A';
		    	a[i+y*2]=x;i=i+y*2;
		    }
	    }
    }
    writeln(ans);
    return 0;
}


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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

const int N = (int) 1e5+5;

vector<int> vec[N];
priority_queue<int> q;

int main()
{
    int n , m , ans = 0;

    cin >> n >> m;

    for(int i = 0; i < n; ++i){
        int a , b;
        cin >> a >> b;
        if(a > m)
            continue;
        vec[a].pb(b);
    }

    for(int i = 1; i <= m; ++i){
        for(auto x : vec[i])
            q.push(x);
        if(q.empty())
            continue;
        ans += q.top();
        q.pop();
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 5632
// Copyright 2019 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> A(N),B(N),C(N-1);
	int ans = 0;
	for(auto&v:A)cin >> v;
	for(auto&v:B)cin >> v;
	for(auto&v:C)cin >> v;
	int prev = -1;
	for(auto&v:A){
		--v;
		ans += B[v];
		if(prev>=0&&prev+1==v)
			ans += C[prev];
		prev=v;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ss second
#define ff first
#define INF 30000000000001
#define ll_max 9000000000000000001
#define mod 1000000007
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 1;

void update(ll BIT[], ll n, ll x, ll i)
{
    for(; i <= n; i += (i) & (-i)) BIT[i] += x;
}

ll query(ll BIT[], ll l)
{
    ll sum1 = 0;
    for(; l; l = l & (l - 1)) sum1 += BIT[l];
    return sum1;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, x, y;
        cin >> n;
        pair<long double, pair<int,int> > a[2 * n];
        long double ans = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> x >> y;
            a[i].ff = atan2(y, x);
            a[i].ss.ff = x;
            a[i].ss.ss = y;
        }
        sort(a, a + n);
        for(int i = n; i < 2 * n; i++) a[i] = a[i - n], a[i].ff += 2 * PI;
        for(int i = 0; i < 2 * n; i++)
        {
            x = 0, y = 0;
            for(int j = i; j < 2 * n; j++)
            {
                x += a[j].ss.ff;
                y += a[j].ss.ss;
                if(a[j].ff - a[i].ff <= PI)
                {
                    ans = max((ll)ans, x * x + y * y);
                }
                else break;
            }
        }
        ans = sqrt(ans);
        cout << fixed << setprecision(11) << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    input += chunk;
});
process.stdin.on('end', function() {
    main(input)
});

function main(input){
    var args = input.trim().split('\n');
    args = args.slice(1, parseInt(args[0]) + 1 );
    args.forEach(function(data){
        data = data.split(' ').map(function(x){
            x = parseInt(x);
            return x * x;
        }).sort(function(a,b){
            return a - b;
        });

        var isRight = data[0] + data[1] === data[2];
        var res = isRight ? "YES" : "NO";
        console.log(res);
    })
}

Measured memory_bytes: 17980
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N; int ans = 1000 -	(N % 1000);
  ans =	ans % 1000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;
long long h[100000];
int main(){
    int N;
    long long A;
    long long B;

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

    long long left = 0;
    long long right = 10000000000;
    while(left + 1 < right){
        long long mid = (left + right) / 2;
        long long base_damage = mid * B;
        bool all_dead = true;
        long long left_mp = mid;
        for(int i = 0; i < N; i++){
            long long stamina = h[i] - base_damage;
            if(stamina <= 0){
                continue;
            }

            int required_mp;
            if(stamina % (A - B) == 0){
                required_mp = stamina / (A - B);
            } else {
                required_mp = stamina / (A - B) + 1;
            }
            if(left_mp < required_mp){
                all_dead = false;
                break;
            } else {
                left_mp -= required_mp;
            }
        }

        if(all_dead){
            right = mid;
        } else {
            left = mid;
        }
    }
    cout << right << endl;
    return 0;
}


Measured memory_bytes: 1024
///-----Bismillahir Rahmanir Rahim-----///

#include<bits/stdc++.h>
using namespace std;

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
    //this is a sample overloading function for sorting stl
    bool operator()(pii const &a, pii const &b)
    {
        if(a.F==b.F)
            return (a.S<b.S);
        return (a.F<b.F);
    }
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        map<int,int>cnt;
        for(int i=1; i<=100; i++)
        {
            for(int j=1; j<=100; j++)
            {
                for(int k=1; k<=100; k++)
                {
                    int tmp=i*i+j*j+k*k+i*j+j*k+k*i;
                    cnt[tmp]++;
                }
            }
        }
        ll n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cout<<cnt[i]<<endl;
        }
        cnt.clear();
    }
    return 0;
}


Measured memory_bytes: 5364
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);

int main(){
    int n, k;
    cin>>n>>k;
    int arr[n];
    ip(arr, n);

    int dp[k+1];
    for(int i=0; i<=k; i++) dp[i]=2;

    for(int i=1; i<=k; i++){
        for(int j=0; j<n; j++){
            if(i-arr[j]<0) continue;
            if(dp[i-arr[j]] == 2){
                dp[i]=1;
            }
        }
    }
    if(dp[k] == 2) cout<<"Second\n";
    else cout<<"First\n";
    return 0;
}

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

int main() {
    long n;
    cin >> n;
    vector<long> vl(100003, 0);
    for (long i=0; i<n; i++) {
        long unko;
        cin >> unko;
        if (unko > 0)
            vl[unko-1]++;
        vl[unko]  ++;
        vl[unko+1]++;
    }
    long max = -1;
    for (long i=0; i<=100001; i++) {
        long tmp = vl[i];
        if (tmp > max)
            max = tmp;
    }
    printf("%ld\n", max);
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	//for (n = 1; n <= 179; n++)
	//{
		int deg = n;
		int cnt = 0;
		int curdeg = 0;
		while (1)
		{
			curdeg += deg;
			cnt++;
			if (curdeg % 360 == 0) break;
			curdeg %= 360;
		}
		
	//}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3632
S = input()
length = len(S)

def sim(temp):
    ret = 0
    for i in range(length):
        if S[i] != str(temp):
            ret += 1
        if temp == 0:
            temp = 1
        else:
            temp = 0 
    return ret
    
res1 = sim(0)
res2 = sim(1)
ans = min(res1, res2)
print(ans)

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};

signed main() {
    long long n;
    cin >> n;
    vector<int> as(n);
    long long sumneg = 0, sum = 0;
    int minn = 1e9;
    REP(i, n) {
        cin >> as[i];
        if (as[i] < 0) {
            sumneg++;
        }
        as[i] = abs(as[i]);
        sum += as[i];
        minn = min(as[i], minn);
    }
    if (sumneg % 2 == 0) {
        cout << sum << endl;
    } else {
        cout << sum - 2 * minn << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>

using namespace std;


long long dp[101][21];

int main() {

  int n;
  int a[101];


  cin >> n;

  for(int i=0;i<n;i++) cin >> a[i];

  memset(dp,0,sizeof(dp));

  dp[1][a[0]]=1; //1ÔÚÜÅvZµ½Æ«ÉrÊªa[0]Å éêÍPÊè

  for(int i=1;i<n-1;i++) {

    //DP(dp[i+1][j}a[i]]=°(j=0/j=20)dp[i][j])
    //i+1ÔÚÜÅvZµ½rÊªA élk(=j}a[i])Å éÆ¢¤±ÆÍAiÔÚÜÅvZµ½rÊªA éljÅ ÁÄA©Âa[i](i+1ÔÚÌ)ðvZµ½Æ¢¤±Æ
    for(int j=0;j<=20;j++) {

      //DPe[uª0ÅÈ¢Æ«(} è)
      if(dp[i][j]>0) {

	int plus=j+a[i];
	int minus=j-a[i];

	if(plus>=0 && plus<=20) dp[i+1][plus]+=dp[i][j];

	if(minus>=0 && minus<=20) dp[i+1][minus]+=dp[i][j];

      }

    }

  }

  //n-1ÔÚÜÅvZµ½rÊÌlªa[n-1](nÔÚÌB½¾µ0<=a[n-1]<=9)Å éÈçÎA»êÍA»ÌãÉa[n-1]ð«»¤ªø±¤ªK¸³µ¢Æm©ßé±ÆªoéêÆÈÁÄ¢éB
  //æÁÄAdp[n-2][a[n-1]]Ìlª®ÌÂÆÈé
  cout << dp[n-1][a[n-1]] << endl;

  return 0;

}

Measured memory_bytes: 0
use whiteread::parse_line;

fn main() {
    let _n: i32 = parse_line().unwrap();
    let mut a: Vec<i32> = parse_line().unwrap();
    let mut alice: i32 = 0;
    let mut bob: i32 = 0;

    // 降順にソート
    a.sort_by(|a, b| b.cmp(a));
    for i in 0..a.len() {
        if i % 2 == 0 {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }
    assert!(alice >= bob);
    println!("{}", alice - bob);
}


Measured memory_bytes: 2164
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}

int N, M;
vvi e;
vb visited;
int cnt = 0;

void dfs(int t, int x) {
    if (visited[x]) return;
    visited[x] = true;

    if (t >= N-1) {
        bool ok = true;
        FOR(i,1,N+1) {
            if (!visited[i]) {
                ok = false;
                break;
            }
        }
        if (ok) cnt++;
        visited[x] = false;
        return;
    }

    for(int i : e[x]){
        dfs(t + 1, i);
    }

    visited[x] = false;
}

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

    cin >> N >> M;
    vi a(M), b(M); REP(i,M) cin >> a[i] >> b[i];
    
    e = vvi(N + 1);

    REP(i,M) {
        e[a[i]].push_back(b[i]);
        e[b[i]].push_back(a[i]);
    }

    visited = vb(N+1, false);
    cnt = 0;

    dfs(0, 1);

    int ans = cnt;
    cout << ans << endl;  

    return 0;
}

Measured memory_bytes: 256