akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int [N];
		int[] B = new int [N];
		int[] C = new int [N];
		
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}
		int sum = 0;
		
		for(int i = 0; i < N; i++) {
			sum += sc.nextInt();
		}
		for(int i = 0; i < N - 1; i++) {
			C[i] = sc.nextInt();
		}
		sc.close();
		
		for(int i = 0; i < N - 1; i++){
			if(A[i] + 1 == A[i + 1])sum += C[A[i]];
		}
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
n, m = (int(x) for x in input().split())
max_l = float('-inf')
min_r = float('inf')
for _ in range(m):
  l, r = (int(x) for x in input().split())
  max_l = max(max_l, l)
  min_r = min(min_r, r)
print(max(0, min_r - max_l+1))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long s,W,H,i,a,b,c,d,e,ans=1e10;
int main(){
	cin>>W>>H;
	for(i=0;i<=H/2;i++){
		a=W*i;                                       //________________
		b=(H-i)*(W/2);                              //|_______a_______|
		c=W*H-a-b;                                  //|   b   |    c  |
		s=max(max(a,b),c)-min(min(a,b),c);          //|_______|_______|
		ans=min(ans,s);
		
		d=(H-i)/2*W;                                 //________________ 
		e=W*H-a-d;                                  //|_______a_______|
		s=max(max(a,d),e)-min(min(a,d),e);          //|_______d_______|
		ans=min(ans,s);                             //|_______e_______|
 	}
	for(i=0;i<=W/2;i++){                             //________________
		a=H*i;                                      //|       |   b   | 
		b=(W-i)*(H/2);                              //|   a   |_______|
		c=W*H-a-b;                                  //|_______|___c___|
		s=max(max(a,b),c)-min(min(a,b),c);
		ans=min(ans,s);
		
		d=(W-i)/2*H;                                 //_______________
		e=W*H-a-d;                                  //|      |   |   |
		s=max(max(a,d),e)-min(min(a,d),e);          //|   a  | d | e |
		ans=min(ans,s);                             //|______|___|___|
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}
int main()
{
    vok();
    string s,t;
    IN s>>t;
    int ans=0;
    loop(i,0,int(s.length()))
    {
        if(s[i]!=t[i])
        {
            ans++;
        }
    }
    OUT ans<<endl
    return 0;
}

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

using namespace std;

int v[4], a[] = {1, 4, 7, 9};

int main () {
  for(int i = 0; i < 4; i++) {
    cin >> v[i];
  }
  sort(v, v+4);
  bool ok = 1;
  for(int i = 0; i < 4; i++) {
    ok &= v[i] == a[i];
  }
  cout << (ok ? "YES" : "NO") << endl;
}

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

int main(){
    string S,T;
    cin >> S >> T;
    int s = S.length();
    int t = T.length();
    if(s+1 == t && S.substr(0,s) == T.substr(0,s)){
        cout << "Yes";
    }
    else{
        cout << "No";
    }


}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    vi a(n);
    rep(i, n){
        cin >> a[i];
    }

    int ans = 0;
    int j = 1;
    rep(i, n){
        if(a[i] != j){
            ans++;
        }else{
            j++;
        }
    }

    if(ans == n){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 1024
from collections import Counter
n = int(input())

def prime_factor(n):
    ass = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass


prime = prime_factor(n)
#print(prime)
c = Counter(prime)
count = 0
already = []
for p in prime:
    if p not in already:
        already.append(p)
        x = c[p]
        i = 1
        while x >= i:
            x -= i
            i += 1
            count += 1

print(count)


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

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

    string ans;
    rep(i, s.size()) {
        if (s[i] == 'B') {
            if (ans.empty()) continue;
            ans = ans.substr(0, ans.size() - 1);
        } else
            ans += s[i];
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//split??????????????§????????????????§£????????£??\
		String[] lines = sc.nextLine().split(" ");
		int num1 = Integer.parseInt(lines[0]);
		int num2 = Integer.parseInt(lines[1]);
		int num3 = Integer.parseInt(lines[2]);
		//???????????£??\??????result?????£?¨????
		String result;

		//???????????????????????????????????£??\???
		if(num1 < num2 && num2 < num3){
			result = "Yes";
		} else {
			result = "No";
		}

		//???????????¨??????
		System.out.println(result);

	}
}

Measured memory_bytes: 26148
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(void){
  long long S;
  cin>>S;
  if(S==1000000000000000000){
    printf("0 0 1000000000 0 0 1000000000\n");
  }
  else{
  long long s = (long long)sqrt(S);
  printf("0 0 %lld %lld 1 %lld\n",s+1,(s+1)*(s+1)-S,s+1);
}
return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
string s;
char a[100010];
int main()
{
	 cin>>s;
	 int k=0;
	 for(int i=0;i<s.size();i++)
	 {
	 	if(s[i]!='B') a[++k]=s[i];
	 	else 
	     {
	     	k--;
	     	if(k<0) k=0;
	     }
	 }
	 for(int i=1;i<=k;i++)
	 	cout<<a[i];
	 cout<<"\n";
	 
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    while(1){
        int a, b; cin >> a >> b;
        if(a == 0 && b == 0) return 0;
        int n; cin >> n;
        vector<vector<int>> dp(b, vector<int> (a,0));
        vector<vector<bool>> g(b, vector<bool> (a,true));

        rep(i,n){
            int j, k; cin >> j >> k; j--; k--;
            g[k][j] = false;
        }

        dp[0][0] = 1;
        rep(i,b){
            rep(j,a-1){

                if(j == 0 && i > 0){
                    if(g[i][j] == true) dp[i][j] = dp[i-1][j];
                    if(g[i][j+1] == true) dp[i][j+1] += dp[i][j] + dp[i-1][j+1];
                    continue;
                }

                if(g[i][j+1] == true){
                    if(i == 0) dp[i][j+1] += dp[i][j];
                    else dp[i][j+1] += dp[i][j] + dp[i-1][j+1];
                }

            }
        }

        cout << dp[b-1][a-1] << endl;
        //rep(i,b){
            //rep(j,a){
                //cout << dp[i][j];
            //}
            //cout << endl;
        //}

    }
}


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

		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] h = new long[N];
		for( int i=0; i<N; i++ ){
			h[i] = sc.nextLong();
		}
		Arrays.sort(h);
		long minium = 1000000000L;
		for( int i=0; i<=N-K; i++ ){
			long ans = h[i-1+K] - h[i];
			minium = Math.min(ans,minium); 
		}
		System.out.println(minium);
	}
}


Measured memory_bytes: 52116
#include <stdio.h>

int main(void)
{
  int S, h, m, s;
  scanf("%d", &S);

  m = S/60;
  h = m/60;
  m = m%60;
  s = S%60;
  printf("%d:%d:%d\n", h, m, s);
  return(0);
}

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

int main(){
    int n,fp=0,fw=0,fg=0,fy=0;
    string x;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x;
        if(x == "P")
            fp++;
        else if(x == "W")
            fw++;
        else if(x == "G")
            fg++;
        else
            fy++;
    }
    if((fp&&fw&&fg&&fy) == 1)
        cout << "Four" << endl;
    else 
        cout << "Three" << endl;
}

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

int main(){
    string s;
    cin >> s;
    string ans;
    if(s == "Sunny") ans = "Cloudy";
    else if(s == "Cloudy") ans = "Rainy";
    else ans = "Sunny";
    cout << ans << endl;
    return 0;  
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define int long long
int calc(int tot,int k)
{
    if(k>tot) return 0;
    k--;tot--;
    int num=1,fac=1;
    for(int i=0;i<k;i++)
        num*=(tot-i);
    for(int i=1;i<=k;i++)
        fac*=i;
    int type=num/fac,res=1,each=1;
    for(int i=0;i<k;i++)
        each*=9;
    res=type*each;
    return res;
}
signed main()
{
    string n;
    cin>>n;
    int len=(int)n.length(),k;
    n="_"+n;
    scanf("%lld",&k);
    if(k>len)
    {
        puts("0");
        return 0;
    }
    if(k==1)
    {
        int ans=0;
        ans+=(len-1)*9;
        ans+=(n[1]-'0');
        printf("%lld\n",ans);
    }
    else if(k==2)
    {
        int ans=0;
        for(int i=1;i<len;i++)
            ans+=9*(i-1)*9;
        ans+=(n[1]-'0'-1)*(len-1)*9;
        for(int i=2;i<=len;i++)
            if(n[i]!='0')
            {
                ans+=(n[i]-'0');
                ans+=(len-i)*9;
                break;
            }
        printf("%lld\n",ans);
    }
    else if(k==3)
    {
        int ans=0;
        for(int i=1;i<len;i++)
            ans+=9*((i-1)*(i-2)/2)*81;
        ans+=(n[1]-'0'-1)*((len-1)*(len-2)/2)*81;
        for(int i=2;i<=len;i++)
            if(n[i]!='0')
            {
                int left=len-i;
                ans+=(left*(left-1)/2)*81;
                ans+=(n[i]-'0'-1)*left*9;
                for(int j=i+1;j<=len;j++)
                    if(n[j]!='0')
                    {
                        ans+=(n[j]-'0');
                        ans+=(len-j)*9;
                        break;
                    }
                break;
            }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
cnt = 0
A = [int(input()) for _ in range(N)]
if A[0]!=0:
    cnt = -1
else:
    for i in range(1,N):
        if A[i]==A[i-1]+1:
            continue
        elif A[i]<=A[i-1]:
            cnt += A[i-1]
        else:
            cnt = -1
            break
    if cnt>=0:
        cnt += A[N-1]
print(cnt)  

Measured memory_bytes: 57304
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

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

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

vector<int> A;

int solve(const int N, vector<string> &output) {
    int max_val = A[0];
    int min_val = A[N - 1];

    int acc = min_val;
    int idx = 1;
    for (; idx < N - 1; idx++) {
        if (A[idx] < 0) break;
        output.push_back(to_string(acc) + " " + to_string(A[idx]));
        acc = acc - A[idx];
    }

    int ans = A[0];
    for (; idx < N - 1; idx++) {
        output.push_back(to_string(ans) + " " + to_string(A[idx]));
        ans = ans - A[idx];
    }

    output.push_back(to_string(ans) + " " + to_string(acc));
    return ans - acc;
}

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

    A.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    vector<string> output;
    int ans = solve(N, output);
    cout << ans << endl;
    for (auto &str : output) {
        cout << str << endl;
    }

    return 0;
}


Measured memory_bytes: 9332
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push_back
#define ITR ::iterator


#define MOD 1000000009LL
#define EPS 1e-8



int main(){
	int m, a[7] = {}, s, g;
	scanf("%d", &m);
	for(int i = 1; i <= 6; ++i){
		scanf("%d", &a[i]);
	}
	scanf("%d%d", &s, &g);
	vint d(m + 1);
	for(int i = 1; i <= m; ++i){
		scanf("%d", &d[i]);
	}
	
	vvint rG(m + 1);
	for(int i = 1; i <= m; ++i){
		rG[i + d[i]].push_back(i);
	}
	
	vint mincnt(m + 1, 10000000);
	vint to(m + 1, -10000000);
	queue<int> q;
	mincnt[g] = 0;
	q.push(g);
	to[g] = 0;

	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i = 0; i < rG[u].size(); ++i){
			int v = rG[u][i];
			for(int j = 1; j <= 6; ++j)
			for(int sg = -1; sg <= 1; sg += 2){
				int dif = a[j] * sg;
				int w = v - dif;
				if(w < 1 || w > m){ continue; }
				if(to[w] < 0){
					to[w] = v;
					mincnt[w] = mincnt[u] + 1;
					q.push(w);
				}
			}
		}
	}

	int p = s, x;
	while(1){
		scanf("%d", &x);
		int out = 0;
		for(int sg = -1; sg <= 1; sg += 2){
			int dif = a[x] * sg;
			if(p + dif == to[p]){
				out = sg;
				break;
			}
		}
		printf("%d\n", out);
		fflush(stdout);
		
		if(out){
			p += a[x] * out;
			p += d[p];
		}
		if(p == g){ break; }
	}
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 
    int n,t;
    scanf("%d%d",&n,&t);
 
    int cot = 1, minn , maxx = -10;
    int c,tc;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&c);
        if(i)
        {
            if(c>tc)
            {
                if(c-minn>maxx)
                    maxx=c-minn,cot = 1;
                else if(c-minn==maxx)
                    cot++;
            }
            if(minn>c)
                minn = c;
        }
        else
            minn = c;
        tc = c;
    }
    cout<<cot<<endl;
 
 
 
    return 0;
}

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

class Program
{
    struct cell
    {
        public long val;
        public long weight;
        public cell(long w, long v)
        {
            val = v;
            weight = w;
        }
        public static cell operator +(cell lhs, cell rhs)
        {
            return new cell(lhs.weight + rhs.weight, lhs.val + rhs.val);
        }
    }

    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');

        int N = int.Parse(s[0]);
        int W = int.Parse(s[1]);

        cell[] List = new cell[N + 1];

        long[][] MinW = new long[N + 1][];

        long VSum = 0;
        for (int i = 1; i <= N; i++)
        {
            s = Console.ReadLine().Split(' ');
            List[i] = new cell(int.Parse(s[0]), int.Parse(s[1]));
            VSum += List[i].val;
        }
        for (int i = 0; i <= N; i++)
            MinW[i] = new long[VSum + 1];

        for (int i = 0; i <= N; i++)
        {
            for (int j = 1; j <= VSum; j++)
                MinW[i][j] = long.MaxValue;
        }

        for (int i = 1; i <= N; i++)
        {
            for (long j = i; j <= N; j++)
            {
                MinW[j][List[i].val] = Math.Min(List[i].weight, MinW[j][List[i].val]);
            }
        }

        for (int i = 1; i <= N; i++)
        {
            for (int j = 1; j <= VSum; j++)
            {
                if (j >= List[i].val)
                {
                    if (MinW[i - 1][j] - List[i].weight > MinW[i - 1][j - List[i].val])
                        MinW[i][j] = MinW[i - 1][j - List[i].val] + List[i].weight;
                    else
                        MinW[i][j] = MinW[i - 1][j];
                }
                else
                    MinW[i][j] = MinW[i - 1][j];
            }
        }
        
        Console.WriteLine(Array.FindLastIndex(MinW[N], x => W >= x));
    }
}

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

int main() {
  int a[4], b[4];
  while(cin >> a[0]) {
    for(int i = 1; i < 4; i++) cin >> a[i];
    for(int i = 0; i < 4; i++) cin >> b[i];

    int hit = 0, blow = 0;
    for(int i = 0; i < 4; i++) {
      for(int j = 0; j < 4; j++) {
        if(a[i] == b[j]) {
            if(i == j) hit++;
            else blow++;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    for (auto&& c : s) {
        c = ((c - 'A') + n) % ('Z' - 'A' + 1) + 'A';
    }

    cout << s << endl;
}

Measured memory_bytes: 256
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var a = o.m(n-1);
  for(var i = 0; i < n-1; i++){
    a[i][0]--, a[i][1]--;
    a[i][2] = i;
  }
  var mx = 1;
  var set = xArray("new Set()",n);
  a.sort((a,b)=>a[0]-b[0]);
  a[0][3] = 1;
  set[a[0][0]].add(1);
  set[a[0][1]].add(1);
  var id = 0, k = 2;
  for(var i = 1; i < n-1; i++){
    var u = a[i][0], v = a[i][1];
    if(u !== id)k = 1, id = u;
    while(set[u].has(k)||set[v].has(k))k++;
    if(mx < k)mx = k;
    a[i][3] = k;
    set[u].add(k);
    set[v].add(k);
  }
  a.sort((a,b)=>a[2]-b[2]);
  var ans = Array(n-1);
  for(var i = 0; i < n-1; i++){
    ans[i] = a[i][3];
  }
  console.log(mx);
  return ans.join("\n");
}

Measured memory_bytes: 94196
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

from fractions import gcd
from functools import reduce

def gcd(a, b):
	return gcd(b, a%b) if b else a

def get_gcd(A):
	return reduce(gcd, A)

def get_lcm(A):
	def lcm_base(a, b):
		return a*b//gcd(a,b)
	return reduce(lcm_base , A, 1)


def get_primes(n):
	divs = []
	for i in range(2, int(n**0.5)+1):
		c = 0
		while n % i == 0:
			n = n // i
			c += 1
		if c > 0:
			divs.append((i, c))
	if n > 1:
		divs.append((n, 1))
	return divs

N = ri()
A = rl()

pc = True

h = set()
for a in A:
	ps = get_primes(a)
	for p in ps:
		if p in h:
			pc = False
			break
		h.add(p)
	if pc == False: break

if pc:
	print('pairwise coprime')
	exit()

sc = (get_gcd(A) == 1)
if sc:
	print('setwise coprime')
else:
	print('not coprime')


Measured memory_bytes: 187368
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n")[0],n=t.length,r=n,o=t[0],u=1;u<n;u++)if(o!=t[u]){var i=Math.max(u,n-u);i<r&&(r=i),o=t[u]}console.log(r)}},function(e,t){e.exports=require("fs")}]);

Measured memory_bytes: 7756
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
int m,d,ans;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
	m=read();d=read();
	for(int i=1;i<=m;i++)
		for(int j=1;j<=d;j++)
		{
			int x=j/10,y=j%10;
			if(x>1&&y>1)
				if(x*y==i)ans++;
		}
	cout<<ans;
}

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

int main()
{
	int n;
	cin >> n;
	
	int sum = 0;
	
	for (int i = 0; i < n; i++)
	{
		int l, r;
		cin >> l >> r;
		sum += r - l + 1;
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 384
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, X, M = list(map(int, _in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ans = 0
    A = X
    head_list = []
    head = set()
    repeat = set()
    for i in range(N):
        if A in head:
            ind = head_list.index(A)
            repeat = head_list[ind:]
            head = head_list[:ind]
            break
        else:
            head.add(A)
            head_list.append(A)
            A = pow(A, 2, M)

    if len(repeat) == 0:
        ans = sum(head)
    else:
        repeat_time = (N - len(head)) // len(repeat)
        tail_len = N - len(head) - repeat_time * len(repeat)
        ans = sum(head) + sum(repeat) * repeat_time + sum(repeat[:tail_len])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 76892
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using mint = modint998244353;

mint pw10[200200];
mint inv9;

struct S{
    mint num;
    ll siz;
};

using F = mint;
const F ID = 10;

S op(S a, S b){ 
    return S{a.num * pw10[b.siz] + b.num, a.siz + b.siz};
}
S e(){ return {0, 0}; }
S mapping(F f, S x){ 
    if(f == ID) return x;
    mint num = (pw10[x.siz] - 1) * f * inv9;
    return S{num, x.siz};
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

void solve() {
	int n, q; cin >> n >> q;
    pw10[0] = 1;
    for(int i = 1; i < 200200; ++ i) {
        pw10[i] = pw10[i - 1] * 10;
    }
    mint s = 9;
    inv9 = s.inv();
    vector<S> v(n);
    rep(i, n) {
        mint r = 1;
        v[i] = S{r, 1};
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    // cerr << seg.prod(0, n).num.val() << endl;
    rep(_, q) {
        int l, r, d; cin >> l >> r >> d;
        mint t = 0; t += d;
        -- l;
        seg.apply(l, r, t);
        cout << seg.all_prod().num.val() << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 16356
n, m = [int(i) for i in input().split()]
 
matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])
 
vector = []
for mi in range(m):
    vector.append(int(input()))
 
b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]
 
    print(sum)

Measured memory_bytes: 7960
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if (a==1){
    a+=13;
  }
  if(b==1){
    b+=13;
  }
  if(a==b){
    cout << "Draw" << endl;
  }
  else if (a>b){
    cout << "Alice" << endl;
  }
  else {
    cout << "Bob" << endl;
  }
}

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

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<int> cnt(n + 1, 0);
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	
	sort(cnt.begin(), cnt.end());
	
	int ans = 0;
	for(int i = 0; i <= n - k; ++i) {
		ans += cnt[i];
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main()
{
    int a,b,c,p;
    cin>>a>>b>>c;
        if(a>=(b+c))
        {
            p=0;
            printf("%d\n",p);
        }
        else
        {
            p=(b+c)-a;
            printf("%d\n",p);
        }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int unused __attribute__((unused));
  int i, j, cnt = 0;
  int N, K, *d, **A, *sunuke;
  unused = scanf("%d %d", &N, &K);
  d = malloc(sizeof(int)*N);
  A = malloc(sizeof(int *)*K);
  sunuke = malloc(sizeof(int)*N);
  for(i=0; i<N; i++) sunuke[i] = 0;

  for(i=0; i<K; i++){
    unused = scanf("%d", &d[i]);
    A[i] = malloc(sizeof(char)*N);
    for(j=0; j<d[i]; j++){
      unused = scanf("%d", &A[i][j]);
      sunuke[A[i][j]-1] = 1;
    }
  }
  for(i=0; i<N; i++){
    if(sunuke[i]==0) cnt++;
  }
  printf("%d", cnt);
  return 0;
}


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

int W,H;
int fie[111][111];
int D[111][111];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct state { 
  int x,y,c;
};

bool check(int x,int y){
  if( x < 0 || y < 0 || x >= 2*W || y >= 2*H ) return true;
  return false;
}

int bfs(){
  memset(D,0,sizeof(D));
  queue<state> q;
  q.push( (state){0,0,1} );
  D[0][0] = 1;
  while( !q.empty() ){
    state p = q.front(); q.pop();
    //    cout << p.x << " " << p.y << " " << p.c << endl;
    if( p.x == (W-1)*2 && p.y == (H-1)*2 ) return p.c;
    for(int i=0;i<4;i++){
      int ncx = p.x + dx[i], ncy = p.y + dy[i];
      int nx = p.x + dx[i]*2, ny = p.y + dy[i]*2;
      if( check(nx,ny) ) continue;
      if( fie[ncx][ncy]  ) continue;
      if( D[nx][ny] == 0 ){
	D[nx][ny] = p.c + 1;
	q.push( (state){nx,ny,p.c+1} );
      }
    }
  }
  return 0;
}

int main(){
  while( cin >> W >> H && (W||H) ){
    memset(fie,0,sizeof(fie));
    for(int i=0;i<2*H-1;i++){
      for(int j=0;j<W-(i%2==0?1:0);j++){
	if( i & 1 )
	  cin >> fie[2*j][i];
	else
	  cin >> fie[2*j+1][i];
      }
    }

    cout << bfs() << endl;
  }
}

Measured memory_bytes: 1316
import scala.util.control.Breaks

object Main extends App {
  val n = scala.io.StdIn.readInt()
  val read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  var diff = 0

  val b = new Breaks
  b.breakable{
    for(i<-0 to (n - 1)) {
      val left = array.slice(0, i + 1).sum
      val right = array.slice(i + 1, n).sum
      val tempDiff = Math.abs(left - right)
      if (i == 0 || diff > tempDiff) {
        diff = tempDiff
      } else{
        b.break()
      }
    }
  }
  println(diff)
}

Measured memory_bytes: 27196
K=int(input())
A=[1,2,3,4,5,6,7,8,9]+[0]*K
i=9
j=0
while i<K:
    if A[j]%10!=0 and A[j]%10!=9:
        A[i]=10*A[j]+A[j]%10-1;i+=1
        A[i]=10*A[j]+A[j]%10;i+=1
        A[i]=10*A[j]+A[j]%10+1;i+=1
    elif A[j]%10==0:
        A[i]=10*A[j]+A[j]%10;i+=1
        A[i]=10*A[j]+A[j]%10+1;i+=1
    else:
        A[i]=10*A[j]+A[j]%10-1;i+=1
        A[i]=10*A[j]+A[j]%10;i+=1
    j+=1
print(A[K-1])

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<set<int>> S(M);
    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            s--;
            S[i].insert(s);
        }
    }
    vector<int> P(M);
    for (int i = 0; i < M; i++) {
        cin >> P[i];
    }

    int ans = 0;
    for (int i = 0; i < 1 << N; i++) {
        bool ok = true;
        for (int j = 0; j < M; j++) {
            int cnt = 0;
            for (int k = 0; k < N; k++) {
                if (i >> k & 1) {
                    if (S[j].find(k) != S[j].end()) {
                        cnt++;
                    }
                }
            }
            if (cnt % 2 != P[j]) {
                ok = false;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

string s;
bool check(int cnt){
  DUMP(s[cnt]);
  if(s[cnt] - '0' < 0 ||  s[cnt] - '0' > 9)return false;
  return true;
}

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r,g;
  while(cin >> r >> g){
    double ans = g * 2 - r;
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
    int ab,bc,ca;
    cin >> ab >> bc >> ca;
    cout << ab*bc/2 << endl;
    return 0;
}


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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


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

    UnionFind tree(n);

    for(int i = 0;i < m;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        tree.unite(a, b);
    }

    vector<int> ans;

    for(int i = 0;i < n;i++){
        ans.push_back(tree.root(i));
    }

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

    int count = 1;

    for(int i = 1;i < ans.size();i++){
        if(ans[i] != ans[i - 1]) count++;
    }

    cout << count - 1 << endl;

    return 0;
}

Measured memory_bytes: 3912
N = int(input())
import re
for _ in [0]*N:
    a = input().zfill(100)
    b = input().zfill(100)
    result = []
    prev = 0
    for i in range(1, 81):
        n = int(a[-i]) + int(b[-i]) + prev
        result.append(n%10)
        prev = n // 10
    if prev > 0 or int(a[:-80]) + int(b[:-80]) > 0:
        print("overflow")
    else:
        result = "".join(map(str, result[::-1]))
        print(int(result))

Measured memory_bytes: 7868
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    k = min(n - 1, k);
    fact();
    int ans = 1;
    rep(i, k) {
        ans = (ans + Mul(C(n, i + 1), C(n - 1, i + 1))) % mod;
        //cout << ans << endl;
    }
    cout << ans << endl;



    return 0;
}


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

typedef long long ll;

int main() {
  int H,W,h,w; cin >> H >> W >> h >> w;
  cout << H*W-(h*W+(H-h)*w) << endl;
  return 0;
}


Measured memory_bytes: 256
loop do
  begin
    n, m = gets.chomp.split.map(&:to_i)
    break if n == 0 && m == 0
    next if n.nil?

    vegitables = gets.chomp.split.map(&:to_i).sort.reverse

    vegitables.each.with_index(1) do |v, i|
      if i % m == 0
        vegitables[i - 1] = 0
      end
    end

    p vegitables.inject(:+)
  rescue
    next
  end
end

Measured memory_bytes: 6368
a,b,c = map(int,input().split())
if a%2 == b%2 and b%2 == c%2:
    if a == max([a,b,c]):
        p = min(b,c)
        q = max(b,c)
        ans = abs(a-p)//2+abs(a-q)//2
    elif b == max([a,b,c]):
        p = min(a,c)
        q = max(a,c)
        ans = abs(b-p)//2+abs(b-q)//2
    elif c == max([a,b,c]):
        p = min(a,b)
        q = max(a,b)
        ans = abs(c-p)//2+abs(c-q)//2
else:
    even = []
    odd = []
    if a%2:odd.append(a)
    else:even.append(a)
    if b%2:odd.append(b)
    else:even.append(b)
    if c%2:odd.append(c)
    else:even.append(c)
    if len(even) > len(odd):
        ans = 1
        even[0] +=1
        even[1]+=1
        ans += abs(max(even)-min(even))//2+abs(odd[0]-max(even))//2
    
    else:
        ans = 1
        odd[0]+=1
        odd[1]+=1
        ans += abs(max(odd)-min(odd))//2+abs(even[0]-max(odd))//2
print(ans)




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

typedef long long ll;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

const ll mod = 1000000007;

ll powmod(ll x, ll y)
{
    ll res = 1;
    for (ll i = 0; i < y; i++)
    {
        res = res * x % mod;
    }
    return res;
}

int main()
{
    
    ll N;
    cin >> N;
    ll ans = 0;
    ll p = 1;
    ll r = 1;
    ll k = 1;
    for (int i = 0; i < N; i++)
    {
        r *= 10;
        p *= 8;
        k *= 9;
        r %= mod;
        p %= mod;
        k %= mod;
    }
    ans = (r - k - k + p) % mod;
    ans = (ans + mod) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, m;
  cin >> n >> m;
  vector<pair<i64, i64>> k(m);
  for (i64 i = 0; i < m; i++)
  {
    i64 b;
    cin >> k[i].first >> b;
    for (i64 j = 0; j < b; j++)
    {
      i64 d;
      cin >> d;
      k[i].second |= (1LL << (d - 1));
    }
  }
  vector<vector<i64>> dp(m + 1, vector<i64>(1LL << n, 1e9));
  dp[0][0] = 0;
  for (i64 i = 0; i < m; i++)
    for (i64 j = 0; j < (1LL << n); j++)
    {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      dp[i + 1][j | k[i].second] = min(dp[i + 1][j | k[i].second], dp[i][j] + k[i].first);
    }
  if (dp[m][(1LL << n) - 1] == 1e9)
    cout << -1 << endl;
  else
    cout << dp[m][(1LL << n) - 1] << endl;
  return 0;
}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

struct edge{
    int to, ac;
    //ac : after_cost
    ll time;
    edge(){}
    edge(int a, int b, ll c){
        to = a;
        ac = b;
        time = c;
    }
};
template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}

int main() {
    cin>>N>>M>>K;
    vector<vector<vector<edge> >> G(N, vector<vector<edge>>(N * 50 + 1, vector<edge>(0)));
    rep(i,M){
        int u, v, a;
        ll b;
        cin>>u>>v>>a>>b;
        --u;
        --v;
        reps(j,a,N * 50 + 1){
            G[u][j].emplace_back(v, j - a, b);
            G[v][j].emplace_back(u, j - a, b);
        }
    }
    rep(i,N){
        int c, d;
        cin>>c>>d;
        reps(j,c, N * 50 + 1){
            G[i][j - c].emplace_back(i, j, d);
        }
    }
    mat dist(N, vec(N * 51, INF));
    dist[0][min(N * 50, K)] = 0;
    priority_queue<P, vector<P>, greater<P>> pque;
    pque.emplace(0, (min(N * 50, K) * N) + 0);
    while(!pque.empty()){
        P p = pque.top();
        pque.pop();
        int v = p.se%N, sil = p.se / N;
        if(dist[v][sil] < p.fi) continue;
        for(edge e : G[v][sil]){
            if(chmin(dist[e.to][e.ac], dist[v][sil] + e.time)){
                pque.emplace(dist[e.to][e.ac], (e.ac * N) + e.to);
            }
        }
    }
    reps(i,1,N) {
        ll ans = INF;
        rep(j, N * 50 + 1) chmin(ans, dist[i][j]);
        cout<<ans<<endl;
    }
}

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

int main(void){
  vector<int> n(3);

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

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

  cout << n[0] + n[1] + n[2]*10 << endl;

  return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 100001
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {printf("0\n"); return 0;}
#define FAIL_1 {printf("-1\n"); return 0;}

int N, K;
int A[101];
LL dp[MAXN][101];
LL S[MAXN][101];

void add(LL &a, LL b) {
    a = (a+b) % MOD;
}

int main(int argc, char **argv)
{
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);

    LL sum = 0;
    for (int i = 0; i < N; i++) sum += A[i];
    if (K > sum) FAIL0;

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

    for (int n = 1; n < N; n++) {
        S[0][n-1] = 1;
        for (int k = 1; k <= K; k++) 
            S[k][n-1] = (S[k-1][n-1] + dp[k][n-1]) % MOD;

        //printf("n = %d\n", n);
        //for (int k = 1; k <= K; k++) 
            //printf("%lld ", S[k][n-1]);
        //printf("\n");

        dp[0][n] = 1;
        for (int k = 1; k <= K; k++) {
            int mn = max(0, k-A[n]);
            LL x = 0;
            if (mn) x = S[mn-1][n-1];
            dp[k][n] = (S[k][n-1] - x) % MOD;
            while (dp[k][n] < 0) dp[k][n] += MOD;
            //for (int t = mn; t <= k; t++)
                //add(dp[k][n], dp[t][n-1]);
        }

        //for (int k = 1; k <= K; k++) 
            //printf("%lld ", dp[k][n]);
        //printf("\n\n");
    }

    printf("%lld\n", dp[K][N-1]);
    return 0;
}


Measured memory_bytes: 158080
#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=1e5+10;
char lx[N];

int main(){
	scanf("%s",lx+1);
	int n=strlen(lx+1);
	if(lx[n]=='1'||lx[1]=='0'||lx[n-1]=='0') return printf("-1\n"),0;
	fr(i,1,n/2) if(lx[i]!=lx[n-i]) return printf("-1\n"),0;
	int nw=2,rt=2,nm=1;
	printf("1 2\n");
	fr(i,2,n/2){
		if(lx[i]=='1'){
			printf("%d %d\n",++nw,rt);
			rt=nw;
		} else printf("%d %d\n",++nw,rt);
		nm++;
	}
	fr(i,nm+1,n-1) printf("%d %d\n",++nw,rt);
	return 0;
}

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

int main()
{

    int n,h,w,a[1000],b[1000],sum = 0;

    cin >> n >>h>>w;
    for(int i = 0;i<n;i++)
    {
        cin >> a[i] >> b[i];
        if(a[i]>=h && b[i]>=w)
        {
            sum++;
        }
    }



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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int count=0, maxa=0;
  for(int i=0; i<3; i++)
  {
    if(s[i]=='R')
    {
      count++;
      maxa=max(count, maxa);
    }
    else 
    {
      count=0;
    }
  }
  cout<<maxa<<endl;
  return 0;
}

Measured memory_bytes: 3628