akhauriyash/Code-Regression huggingface dataset:
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    string S;cin >> S;
    int N;cin >> N;
    for(int i = 0;i<S.size();i+=N){
        cout << S.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
	    
	    
	    using namespace std;
	
	    #define ll long long
	    #define do double
	    #define ff first
	    #define ss second
	    #define FOR(a,n) for(i=0;i<n;i++){    cin>>a[i];}
	    #define pb push_back
	    #define mp make_pair
	    #define inf LONG_LONG_MAX
	    #define mod  1000000007
	    #define PI 3.141592653589793238462643383279
	    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	    

	ll d,x,y;
	void extendedEuclid(ll A, ll B) 
	{
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        int temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}

	ll power(ll x,ll y, ll p) 
	{ 
	    ll res = 1; 
	    x = x % p;
	    while (y > 0) 
	    {  // If y is odd, multiply x with result 
	        if (y & 1) 
	            res = (res*x) % p;
	            
	        y = y>>1; 
	        x = (x*x) % p;   
	    } 
	    return res; 
	} 



map<ll,ll> par,val;
void ini()
{
	for(ll i=0;i<500010;i++)
		{
			par[i]=i;
		}
}

ll root(ll x)
{
	while(par[x]!=x)
	{
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}

void uni(ll x,ll y)
{
	x=root(x);
	y=root(y);
		par[y]=par[x];
}

int gcdExtended(int a, int b, int *x, int *y) 
{ 

    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    int x1, y1;
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1;
    return gcd; 
}  
int modInverse(int b, int m) 
{ 
    int x, y; 
    int g = gcdExtended(b, m, &x, &y); 
    if (g != 1) 
        return -1; 
    return (x%m + m) % m; 
}
ll isPrime(ll n)
{
    if(n==0||n==1)
        return n;
    if(n%2==0)
        return (ll)2;
    if(n%3==0)
        return (ll)3;
    else
    {
        for(ll i=5;i*i<=n;i+=6)
        {
            if(n%i==0)
                return i;
            if(n%(i+2)==0)
                return (i+2);
        }
        return n;
    }
}

int main()
{
	FAST;
	ll n,i,j,k;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=0;
	ans+=b/c - (a-1)/c;
	ans+=b/d - (a-1)/d;
	ll x=(c*d)/__gcd(c,d);
	ans-=(b/(x) - (a-1)/x);
	cout<<b-a+1-ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, W; cin >> N >> W;
    vec w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];
    int w0 = w[0];
    REP(i, N) w[i] -= w0;
    int X = 3 * N;

    mat dp(N + 1, vec(X + 1, -1 * INF));
    dp[0][0] = 0;
    REP(i, N){
        mat tmp = dp;
        REP(n, N){
            REP(u, X + 1 - w[i]){
                if(dp[n][u] > -1 * INF)
                tmp[n + 1][u + w[i]] = max(tmp[n + 1][u + w[i]], dp[n][u] + v[i]);
            }
        }
        dp = tmp;
    }
    int ans = 0;
    REP(n, N + 1){
        int Wmax = min(X, W - n * w0);
        REP(u, Wmax + 1) ans = max(ans, dp[n][u]);
    }
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 784
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

enum result{
	o, x, d
}

public class Main {


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		ArrayList<String> games = new ArrayList<String>();
		while(sc.hasNextLine()) games.add(sc.nextLine());
		
		Iterator<String> it = games.iterator();
		while(it.hasNext()) {
			result gameresult = judge(it.next());
			System.out.println(gameresult.toString());
		}

	}

	
	static result judge(String game) {
		//テァツオツ静ヲツ楪徙テ」ツ?古・ツ仰敕」ツ?。テ」ツ?ェテ」ツつ?, xテ」ツ?古・ツ仰敕」ツ?。テ」ツ?ェテ」ツつ?, テ・ツシツ陛」ツ?催・ツ按?」ツ?妥」ツ?ェテ」ツつ?
		//テ」ツつイテ」ツδシテ」ツδ?、ツセツ黍oosxssxs
		
		char[][] gameboard = new char[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				gameboard[i][j] = game.charAt(i*3 + j);
			}
		}
		
		//gameboardテ」ツ?古・ツョツ古ヲツ按静」ツ?療」ツ?淌」ツつ嘉ァツクツヲテ」ツ??ヲツィツェテ」ツ??ヲツ鳴愿」ツつ?」ツつ津ィツェツソテ」ツ?ケテ」ツつ?
		
		//テヲツィツェ
		for(int i = 0; i < 3; i++) {
			char firstmark = gameboard[i][0];
			if(gameboard[i][1] == firstmark && gameboard[i][2] == firstmark) {
				if(firstmark == 'o') return result.o;
				else if(firstmark == 'x') return result.x;
			}
		}
		
		//テァツクツヲ
		for(int j = 0; j < 3; j++) {
			char firstmark = gameboard[0][j];
			if(gameboard[1][j] == firstmark && gameboard[2][j] == firstmark) {
				if(firstmark == 'o') return result.o;
				else if(firstmark == 'x') return result.x;
			}
		}
		
		//テヲツ鳴愿」ツつ?(テ・ツキツヲテ、ツクツ甘」ツ?凝」ツつ嘉・ツ渉ウテ、ツクツ?
		{
			char firstmark = gameboard[0][0];
			if(gameboard[1][1] == firstmark && gameboard[2][2] == firstmark) {
				if(firstmark == 'o') return result.o;
				else if(firstmark == 'x') return result.x;
			}
		}
		
		
		//テヲツ鳴愿」ツつ?(テ・ツ渉ウテ、ツクツ甘」ツ?凝」ツつ嘉・ツキツヲテ、ツクツ?
		{
			{
				char firstmark = gameboard[2][0];
				if(gameboard[1][1] == firstmark && gameboard[0][2] == firstmark) {
					if(firstmark == 'o') return result.o;
					else if(firstmark == 'x') return result.x;
				}
			}
			
		}
		
		//テ」ツ?ゥテ」ツつ古」ツ?ォテ」ツつづィツゥツイテ・ツスツ禿」ツ?療」ツ?ェテ」ツ?妥」ツつ古」ツ?ーテ・ツシツ陛」ツ?催・ツ按?」ツ??
		return result.d;
	}
}

Measured memory_bytes: 17296
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18+5LL
# define LN 20  
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (int)1e9+2
# define maxn 300006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;    
    }
};

**************************************************/
int main()
{
  IOS;
  int n;
  cin >> n;
  int a[n];
  for(int i=1;i<=n;i++)
  {
     cin >> a[i];
  }

  int ans=0;
  for(int i=1;i<n;i++)
  {
     if(i==n-1)
     {
       if(a[i+1]==(i+1))
       {
         swap(a[i],a[i+1]);
         ans++;
          continue;
       }
      
     }
     if(a[i]==i)
     {
       swap(a[i],a[i+1]);
       ans++;
     }
  }
  cout << ans;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  double x = 0,y = 0,a,b,ang = 90;
  for(;;){
    scanf("%lf,%lf",&a,&b);
    if(a == 0 && b == 0) break;
    x+=a*cos(ang*M_PI/180);
    y+=a*sin(ang*M_PI/180);
    ang-=b;
  }
  printf("%d\n%d\n",(int)x,(int)y);
  return 0;
}

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

int main()
{
  int n;
  cin >> n;
  
  int sum;
  
  if (n == 100000) sum = 90909;
  else if (n >= 10000) sum = n - 9999 + 900 + 9;
  else if (n >= 1000) sum = 909;
  else if (n >= 100) sum = n - 99 + 9;
  else if (n >= 10) sum = 9;
  else sum = n;
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
import itertools

def distance(xy1, xy2):
    x1, y1 = xy1
    x2, y2 = xy2

    dis = ((x1-x2)**2 + (y1-y2)**2)**0.5

    return dis

def solve():
    n = int(input())
    xy = [list(map(int, input().split())) for _ in range(n)]

    cnt = 0
    cnt2 = 0
    for l_xy in itertools.permutations(xy):
        cnt2 += 1
        for j in range(n-1):
            cnt += distance(l_xy[j], l_xy[j+1])

    return cnt/cnt2

    
print(solve())


Measured memory_bytes: 3188
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int a;
	char s[13];

	scanf("%d",&a);
	scanf("%s",s);
	if(a >= 3200)	puts(s);
	else puts("red");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<complex>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define NEXT(i,n) ((i+1)%(n))
  
typedef long long ll;
typedef complex<double> P;

double dot(P a,P b){
  return a.real()*b.real()+a.imag()*b.imag();
}

P symmetric_point(P o,P p,P q){
  P N=p-o,L=q-o;
  double t = abs(L);
  N/=abs(N);
  L/=abs(L);
  double prepL = dot(N,L);//theta element of vector L against N (|L|=|N|=1
  double d=2*prepL;
  P r(d*N - L);//R vector symmetric point of L
  return o+t*r;
}

main(){
  P p,q,o;
  char dummy;
  while(cin>>o.real()>>dummy>>o.imag()>>dummy
	>>p.real()>>dummy>>p.imag()>>dummy
	>>q.real()>>dummy>>q.imag()){
    P ans=symmetric_point(o,p,q);
    printf("%.5lf %.5lf\n",ans.real(),ans.imag());
  }
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Scanner;

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

		while(sc.hasNextInt()){
			int x=sc.nextInt();
			int y=sc.nextInt();
			
			if(x==0 && y==0){
				break;
			}
			
			if(y<x){
				int tmp=x;
				x=y;
				y=tmp;
			}
			a.add(x + " " + y);
		}

		for(int i = 0; i < a.size(); i++){
			System.out.println(a.get(i));
		}
	}
}


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

#define MAX_SIZE 110
#define NIL -1

int n, G[MAX_SIZE][MAX_SIZE];
int dist[MAX_SIZE];

void bfs(int start) {
    queue<int> q;
    q.push(start);
    for (int i = 0; i < n; i++) dist[i] = NIL;
    dist[start] = 0;
    int u;
    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (int i = 0; i < n; i++) {
            if (G[u][i] == 0) continue;
            if (dist[i] != NIL) continue;
            dist[i] = dist[u] + 1;
            q.push(i);
        }
    }    
    return;
}

void print() {
    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << dist[i] << endl;
    }
    return;
}

int main() {
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            G[i][j] = 0;
        }
    }

    int u, k, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            G[u - 1][v - 1] = 1;
        }
    }

    bfs(0);
    print();

    return 0;
}


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

#define EPS 1e-10
#define INF 1000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int,int> pii;
typedef long long ll;

ll addSum( vbb T, vb visited, int pos ) {
  int len = T.size();
  bool visited_all = true;

  for (int i = 0; i < len; i++) {
    if (!visited[i]) {
      visited_all = false;
    }
  }
  if (visited_all) {
    return 1;
  }

  ll ans = 0;
  for (int i = 0; i < len; i++) {
    if (!T[pos][i] || pos == i) {
      continue;
    }
    if (visited[i]) {
      continue;
    }

    visited[i] = true;
    ans += addSum(T, visited, i);
    visited[i] = false;
  }

  return ans;
}

ll calc( vbb T ) {
  int len = T.size();
  ll ans = 0;
  vb visited(len, false);

  int st = 0;
  //for (int st = 0; st < len; st++) {
    visited[st] = true;
    ans += addSum(T, visited, 0);
    //visited[st] = false;
  //}

  return ans;
}

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

  if (M == 0) {
    cout << 0 << endl;
    return 0;
  }

  vbb T(N, vb(N, false));
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;

    T[a-1][b-1] = true;
    T[b-1][a-1] = true;
  }

  ll ans = calc(T);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll res=0, top=a.back();
    if(!a[0]){
        repd(i, n){
            if(a[i]+1<top){
                cout <<  -1 << endl; return 0;
            }else if(top<=a[i]){
                res += a[i];
            }
            top = a[i];
        }
    }else res = -1;
    cout << res << endl;
}


Measured memory_bytes: 4748
using System;
using System.Linq;

namespace ABC110A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[] ints = Input.IntArray();
            int A = ints[0];
            int B = ints[1];
            int C = ints[2];

            if (A >= B)
            {
                if (A >= C)
                {
                    Console.WriteLine(10 * A + B + C);
                    return;
                }
            }

            if (B >= A)
            {
                if (B >= C)
                {
                    Console.WriteLine(10 * B + C + A);
                    return;
                }
            }

            if (C >= A)
            {
                if (C >= B)
                {
                    Console.WriteLine(10 * C + A + B);
                }
            }
        }
    }
    
    internal static class Input
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

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

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

Measured memory_bytes: 256
// https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;
struct UnionFind {
  vector<ll> parents;

  UnionFind(ll n) : parents(vector<ll>(n, -1)) {}

  ll root(ll a) {
    if (parents[a] < 0) {
      return a;
    }

    auto r = root(parents[a]);
    parents[a] = r;
    return r;
  }

  bool same(ll a, ll b) { return root(a) == root(b); }

  void merge(ll a, ll b) {
    ll ar = root(a);
    ll br = root(b);

    if (ar == br) {
      return;
    }

    // make less index one as a root
    if (ar > br) {
      swap(ar, br);
    }

    parents[ar] += parents[br];
    parents[br] = ar;
  }

  ll size(ll a) { return -parents[a]; }

  ll group_count() {
    ll res = 0;

    for (auto s : parents) {
      if (s < 0) {
        res++;
      }
    }

    return res;
  }
};

void solve() {
  ll N, M;
  cin >> N >> M;

  UnionFind uf(N);

  VL lang_to_person(M, -1);

  rep(i, N) {
    ll K;
    cin >> K;

    rep(j, K) {
      ll L;
      cin >> L;
      L--;

      if (lang_to_person[L] != -1) {
        uf.merge(i, lang_to_person[L]);
      } else {
        lang_to_person[L] = i;
      }
    }
  }

  if (uf.group_count() == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1792
n, s = int(input()), str(input())

num1, num2, num3 = set(), set(), set()
for i in range(n):
    if s[i] in num1:
        continue
    num1.add(s[i])
    for j in range(i + 1, n):
        tmp2 = s[i] + s[j]
        if tmp2 in num2:
            continue
        num2.add(tmp2)
        for k in range(j + 1, n):
            num3.add(tmp2 + s[k])
print(len(num3))


Measured memory_bytes: 73432
#include <stdio.h>
  
int main(void)
{   int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}


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

int a,b,c,d,e,k;
int main(void){
  cin >> a >> b >> c >> d >> e >> k;
  if( b-a>k || c-a>k || d-a>k || e-a>k ) cout << ":(" << endl;
  else if( c-b>k || d-b>k || e-a>k ) cout << ":(" << endl;
  else if( d-c>k || e-c>k ) cout << ":(" << endl;
  else if( e-d>k ) cout << ":(" << endl;
  else  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main() {
	ll N;
	cin >> N;
	for (ll n = 1; n <= 3500; n++) {
		for (ll w = 1; w <= 3500; w++) {
			ll x = 4 * n*w - N * (w + n);
			if (x > 0 && (N*n*w) % x == 0) {
				cout << (N*n*w) / x << " " << n << " " << w << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;

bool check(int n){
    string s=to_string(n);
    for(int i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1])return 0;
    }
    return 1;
}

int main(){
    int n;cin>>n;
    for(int i=111;;i++){
        if(i>=n&&check(i)){cout<<i;return 0;}
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin>>a>>b>>c;
	for(int i=b;i<=c;i++)
	{
		if(i%a==0)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
 } 

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();

    ll ans = 0, state = 0;
    vector<ll> a(n, 0);
    if(s[0] == 'A') a[0] = 1;
    for(int i=1;i<n;++i) {
        if(s[i] == 'A') {
            a[i] = a[i-1] + 1;
        } else {
            a[i] = 0;
        }
    }
    for(int i=2;i<n;++i) {
        if(s[i-2] == 'A' && s[i-1] == 'B' && s[i] == 'C') {
            ans += a[i-2];
            s[i] = 'A';
            a[i] = a[i-2];
        } else if(s[i] == 'A') {
            a[i] = a[i-1] + 1;
        } else {
            a[i] = 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  ll N,x;
  cin>>N>>x;
  vector<ll> a(N);

  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  ll ans=0;
  ll ini=a[0]+a[1];
  if(ini>x){
    int rest=ini-x;
    ans+=rest;
    if(rest>a[1]){
      a[1]=0;
    }else{
      a[1]-=rest;
    }
  }

  for(int i=1;i<N-1;i++){
    int rest=a[i]+a[i+1]-x;
    if(rest>0){
      ans+=rest;
      a[i+1]-=rest;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, x, y, xx, yy, maxx, minx, maxy, miny, id, ans;
	cin >> x >> y >> n;
	maxx = x; minx = 0;
	maxy = y; miny = 0;
	while (n--) {
		cin >> xx >> yy >> id;
		if (id == 1) minx = max(minx, xx);
		if (id == 2) maxx = min(maxx, xx);
		if (id == 3) miny = max(miny, yy);
		if (id == 4) maxy = min(maxy, yy);
	}

	if (minx > maxx) ans = 0;
	else if (miny > maxy) ans = 0;
	else ans = (maxx - minx) * (maxy - miny);
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 888
#include <stdio.h>
#include <math.h>
int tre[1000][2];
int mem[1000][10000];
int main(void){
	int w,n,aw,av,k=0,m,i,j;
	while(scanf("%d",&w)*w){
		scanf("%d",&n);
		for(i=0;i<n;i++){for(j=0;j<=w;j++){mem[i][j]=0;}}
		for(i=0;i<n;i++){scanf("%d,%d",&tre[i][0],&tre[i][1]);mem[i][tre[i][1]]=tre[i][0];}

		for(m=1;m<n;m++){
			aw=tre[m][1];
			for(i=1;i<=w;i++){
				av=mem[m-1][i];
				if(av>0){
					if(mem[m][i]<av)mem[m][i]=av;
					if(i+aw<=w && mem[m][i+aw]<av+tre[m][0])mem[m][i+aw]=av+tre[m][0];
				}
			}
			av=0;aw=0;
			for(i=0;i<=w;i++){
				if(mem[m][i]<=av)mem[m][i]=0;
				if(mem[m][i]>av){av=mem[m][i];aw=i;}
			}
		}
		if(n==1){if(tre[0][1]<=w)printf("Case %d:\n%d\n%d\n",++k,tre[0][0],tre[0][1]);}
		else printf("Case %d:\n%d\n%d\n",++k,av,aw);
	}
	return 0;
}

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

template <typename flow_t> struct flow_graph {
	static const flow_t INF = 1e18;
	struct edge {
		int dest;
		flow_t cap;

		edge() {}
		edge(int dest_, flow_t cap_) : dest(dest_), cap(cap_) {}
	};
	vector<vector<int> > adj;
	vector<edge> edges;
	vector<int> memo;
	vector<int> dist;
	vector<int> bfs;

	flow_graph(int n) {
		memo.resize(n);
		dist.resize(n);
		adj.resize(n);
		bfs.reserve(n);
	}

	void add_edge(int from, int to, flow_t cap) {
		assert(cap >= 0);
		int e = int(edges.size());
		adj[from].push_back(e);
		adj[to].push_back(e+1);
		edges.push_back(edge(to, cap));
		edges.push_back(edge(from, 0));
	}

	void path(int sidx) {
		bfs.clear();
		bfs.push_back(sidx);
		fill(dist.begin(), dist.end(), -1);
		dist[sidx] = 0;
		for (int s = 0; s < int(bfs.size()); s++) {
			int v = bfs[s];
			for (int j = 0; j < int(adj[v].size()); j++) {
				int e = adj[v][j];
				int w = edges[e].dest;
				if (edges[e].cap > 0 && dist[w] == -1) {
					dist[w] = dist[v] + 1;
					bfs.push_back(w);
				}
			}
		}
	}

	flow_t block_flow(int tidx, int v, flow_t r) {
		if (tidx == v) {
			return r;
		}
		for (int& j = memo[v]; j < int(adj[v].size()); j++) {
			int e = adj[v][j];
			int w = edges[e].dest;
			flow_t& c = edges[e].cap;
			if (c && dist[w] == dist[v]+1) {
				flow_t del = block_flow(tidx, w, min(r, c));
				if (del > 0) {
					c -= del;
					edges[e^1].cap += del;
					return del;
				}
			}
		}
		return 0;
	}

	flow_t maxflow(int sidx, int tidx) {
		flow_t total = 0;
		while (true) {
			path(sidx);
			if (dist[tidx] == -1) break;
			fill(memo.begin(), memo.end(), 0);
			while (true) {
				flow_t del = block_flow(tidx, sidx, INF);
				if (del == 0) break;
				total += del;
			}
		}
		return total;
	}
};

using ll = long long;
const int OFF = 1e9;
const ll INF = 1e15;

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	flow_graph<ll> mf(n + 2);
	int sidx = n;
	int tidx = n+1;
	ll total = 0;
	// S: 扔掉
	for (int i = 0; i < n; i++) {
		mf.add_edge(sidx, i, OFF);
		mf.add_edge(i, tidx, OFF + a[i]);
		total += a[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i+i; j <= n; j += i) {
			mf.add_edge(i-1, j-1, INF);
		}
	}
	ll answer = total - (mf.maxflow(sidx, tidx) - ll(n) * OFF);
	cout << answer << '\n';
}


Measured memory_bytes: 3708
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin>>N;
    
    vll A(N+1);
    for(ll i=0;i<=N;i++)cin>>A[i];
    if(N==0){
        if(A[0]==1){
            cout<<1<<endl;
            return 0;
        }else {
            cout<<-1<<endl;
            return 0;
        }
    }
    if(A[0]!=0){
        cout<<-1<<endl;
        return 0;
    }
    
    
    vll B(N+1);
    for(ll i=0;i<=N;i++){
        if(i==0){
            B[0]=1;
        }else{
            if(B[i-1]>100000000000000000)B[i]=100000000000000001;
            else B[i]=(B[i-1]-A[i-1])*2;
            
            if(B[i]<A[i]){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    
    vll C(N+1);
    for(ll i=N;i>=0;i--){
        if(i==N){
            C[i]=A[i];
        }else{
            C[i]=C[i+1]+A[i];
        }
    }
    
    ll ans=0;
    for(ll i=0;i<=N;i++){ans+=min(B[i],C[i]);
    }
    cout<<ans<<endl;
    
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =  sc.nextInt();
		int K = sc.nextInt();
		long A[] = new long[N];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextLong();
		}
		Arrays.parallelSort(A);
		long sum =0;
		for(int i=0;i<N-K;i++) {
			sum +=A[i];
		}
		System.out.println(sum);
		return ;
	}
}

Measured memory_bytes: 61312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; ++i)
#define int int64_t

const int N = 1e5 + 10;
int n, m, a[N], ans = 1e17, cnt, bal, op[N], cl[N], add[N];

int dd(int x1, int x2) { /// x1 -> x2
    if (x1 <= x2) return x2 - x1;
    return x2 - x1 + m;
}

int dist(int i, int x) { /// i -> i + 1
    return min(dd(a[i], a[i + 1]), 1 + dd(x, a[i + 1]));
}

int get_cnt(int x) {
    int res = 0;
    rep(i, 0, n - 1)
        res += dist(i, x);
    return res;
}

main() {
    cin >> n >> m;
    rep(i, 0, n) { scanf("%lld", &a[i]); --a[i]; }
    rep(i, 0, n - 1) {
        if (a[i] < a[i + 1]) {
            op[(a[i] + 1) % m]++;
            cl[a[i + 1]]++;
            add[a[i + 1]] += dd(a[i], a[i + 1]) - 1;
        } else {
            op[(a[i] + 1) % m]++;
            cl[a[i + 1]]++;
            add[a[i + 1]] += dd(a[i], a[i + 1]) - 1;
            if (a[i] + 1 < m) cnt++;
        }
    }
    bal = get_cnt(0);
    ans = min(ans, bal);
    rep(i, 0, m) {
        //cerr << bal << ' ' << cnt << ' ' << add[i] << '\n';
        ans = min(ans, bal);
        cnt += op[i];
        cnt -= cl[i];
        bal += add[i];
        bal -= cnt;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3328
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention

# C_Attention_beta.py

N = int(input())
S = input()

e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]

# 累積和を求める
for i in range(N):
    # そこからE側の人で、Wを向くべきなのにEを向いている人
    if i > 0:
        w[i] += w[i-1]
    if i < N-1:
        if S[i] == "W":
            w[i+1] += 1


# そこからW側の人で、Eを向くべきなのにWを向いている人
for j in range(N):
    i = N-1-j
    if i < N-1:
        e[i] += e[i+1]
    if i > 0:
        if S[i] == "E":
            e[i-1] += 1


min = 10 ** 6
for i in range(N):
    total = e[i] + w[i]
    if total < min:
        min = total
print(min)


Measured memory_bytes: 29696
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	s := Scan()
	ans := 0
	for i := 0; i < n; i++ {
		d := make(map[rune]struct{})
		for _, v := range s[:i] {
			d[v] = struct{}{}
		}
		e := make(map[rune]struct{})
		for _, v := range s[i:] {
			if _, ok := d[v]; ok {
				e[v] = struct{}{}
			}
		}
		ans = larger(ans, len(e))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1812
S = input()

flag = True

s = not (S.find("S") == -1)
n = not (S.find("N") == -1)
w = not (S.find("W") == -1)
e = not (S.find("E") == -1)

flag &= not s^n
flag &= not w^e

print("Yes") if flag else print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

const int MOD = INF + 7;
int main(){
   ll k;
   cin >> k;
   
   ll MIN = 49 + k / 50 - k % 50;
   ll MAX = 49 + k / 50 + 50 - k % 50;
   cout << 50 << endl;
   rep(i, k % 50){
       cout << MAX << " ";
   }
   rep(i, 50 - k % 50){
       cout << MIN << " ";
   }
   cout << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
#define MOD 1000000007ll
using namespace __gnu_pbds;
using namespace std;

int k,pw[2000010];
string s;

inline int my_pow(int x,int y)
{
	if(y==0) return 1;
	if(y==1) return x;
	int res=my_pow(x,y/2);
	if(y%2==0) return (res*res)%MOD;
	else return (((res*res)%MOD)*x)%MOD;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>k>>s;
	int n=s.size();
	pw[0]=1ll;
	for(int i=1;i<=n+k;i++){
		pw[i]=(pw[i-1]*i)%MOD;
	}
	int ans=0ll;
	for(int i=n;i<=n+k;i++){
		ans+=(((my_pow(pw[n+k-i],MOD-2ll)*my_pow(pw[i],MOD-2ll))%MOD)*((pw[n+k]*my_pow(25ll,n+k-i))%MOD))%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19796
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut buf = buf.split_whitespace();
    let a: i32 = buf.next().unwrap().parse().unwrap();
    let b: i32 = buf.next().unwrap().parse().unwrap();
    let c: i32 = buf.next().unwrap().parse().unwrap();
    let d: i32 = buf.next().unwrap().parse().unwrap();

    if (a-c).abs() <= d {
        println!("Yes");
    } else if (a-b).abs() <= d && (b-c).abs() <=d {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;


#define PI 3.141592653589793
#define MOD 1000000007

int main()
{
	IOS;
	ll n;
	cin>>n;
	if(n<600)  cout<<"8";
	else if(n<800)  cout<<"7";
	else if(n<1000)  cout<<"6";
	else if(n<1200) cout<<"5";
	else if(n<1400)  cout<<"4";
	else if(n<1600)  cout<<"3";
	else if(n<1800)  cout<<"2";
	else if(n<2000)  cout<<"1";
}


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

using namespace std;

bitset<1000000> pokolei;
int wynik;

int main(void)
{

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n;
  cin >> n;

  int prev;
  cin >> prev;

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

    int c;
    cin >> c;

    if( c == prev+1 )
      pokolei[c-1] = true;

    prev = c;

  }

  for(int i=0;i<n;i++)
  {

    int c;
    cin >> c;

    wynik+=c;

  }

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

    int c;
    cin >> c;

    if( pokolei[i] )
      wynik+=c;

  }

  cout << wynik;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

void solve(void){
	int N;
	cin >> N;
	cout << (N >= 3 ? 0 : N & 1 ? 2 : 1) << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



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

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

    string S;
    cin >> S;

    vector<int> x;

    int c = 1;
    char a = S[0];

    for(int i = 1; i < S.length(); i++) {
        if(a == S[i]) c++;
        else {
            x.push_back(c);
            a = S[i];
            c = 1;
        }
    }

    x.push_back(c);

    if(x.size() == 1) {
        cout << S.length() << endl;
    } else if(x.size() == 2) {
        cout << max(x[0], x[1]) << endl;
    } else {
        int b = 10000000;
        int z = 0;
        for(int i = 0; i < x.size() - 1; i++) {
            b = min(b, max(z + x[i], (int)S.length() - (z + x[i])));
            z += x[i];
        }
        cout << b << endl;
    }
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const string YES = "YES";
const string NO = "NO";

void solve()
{
  ll A;
  scanf("%lld",&A);
  ll B;
  scanf("%lld",&B);
  ll X;
  scanf("%lld",&X);
  if (A+B>=X&&A<=X) cout << YES << endl;
  else cout << NO << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        int min = x - k + 1;
        int max = x + k - 1;
        for (int i=min; i<=max; i++) {
            System.out.print(i + " ");
        }
    }
}

Measured memory_bytes: 38572
#include <stdio.h>
#include <algorithm>

int N,x,a[100];
int main(){
        scanf("%d %d",&N,&x);
        for(int i = 0; i < N; i++) scanf("%d",a+i);
        std::sort(a,a+N);
        
        int c = 0;
        while(c < N && x >= a[c] )  x -= a[c++];
            
  		printf("%d\n",(c == N && x > 0)? N-1:c);        
}

Measured memory_bytes: 128
"use strict"
function Main(input) {
  input = input.trim().split(' ').map(Number);
  const n = input[0];
  const a = input[1];
  const b = input[2];

  let ans = 0;
  for(let i=1; i<=n; ++i){
    let o = i;
    let calc = 0;
    while(o>0){
      calc += o%10;
      o = Math.floor(o/10);
    }

    if(a<=calc && calc<=b){
      ans += i;
    }

  }

  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

long long gcf(long long a, long long b) {
	if (b == 0)
		return a;
	else
		return gcf(b, a % b);
}


int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long lcm = (c * d) / gcf(c, d);
	long long abc = ((b / c) - ceil((long double) a / c)) + 1;
	long long abd = ((b / d) - ceil((long double) a / d)) + 1;
	long long ablcm = ((b / lcm) - ceil((long double) a / lcm)) + 1;
	long long cnt = b - a + 1;
	cnt -= (abc + abd - ablcm);
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 384
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        d: [(usize, usize)]
    }

    let mut cnt = 0;
    let mut max = 0;
    for &(a, b) in &d {
        if a == b {
            cnt += 1;
        } else {
            cnt = 0;
        }

        if max < cnt {
            max = cnt;
        }
    }

    if max >= 3 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string s;
	int x,y,dir = 0,now[2] = {},nxt[2] = {1,1},cnt = 0;
	bool dp[2][2][16010] = {},flag = false;
	cin >> s >> x >> y;
	s += 'T';
	dp[0][0][8000] = true;
	dp[1][0][8000] = true;
	for(int i = 0;i < s.length();i++){
		if(s[i] == 'T'){
			for(int j = 0;j <= 16000;j++) dp[dir][nxt[dir]][j] = false;
			for(int j = 0;j <= 16000;j++){
				if(dp[dir][now[dir]][j]){
					dp[dir][nxt[dir]][j + cnt] = true;
					if(flag) dp[dir][nxt[dir]][j - cnt] = true;
				}
			}
			cnt = 0;
			flag = true;
			swap(now[dir],nxt[dir]);
			dir = (dir + 1) % 2;
		}else cnt++;
	}
	if(dp[0][now[0]][8000 + x] && dp[1][now[1]][8000 + y]) Yes();
	else No();
	return 0;
}

Measured memory_bytes: 384
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(deftype int32 () '(signed-byte 32))
(deftype int64 () '(signed-byte 64))


;;macros
(defmacro println (n)
  `(format t "~a~%" ,n))
(defmacro vint-out (vec)
  `(progn
     (rep i (length ,vec)
          (princ (vref ,vec i))
          (princ " "))
     (fresh-line)))
(defmacro aif (test-form then-form &optional else-form)
  `(let ((it ,test-form))
     (if it ,then-form ,else-form)))

;;vector
(defmacro vec (type &optional (num 100) (val 0))
  (let* ((g (gensym)))
    `(let* ((,g ,num))
       (make-array ,g :element-type ',type :initial-element ,val
                   :adjustable nil :fill-pointer ,g))))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vint (&optional (num 0) (val 0))
  `(vec int32 ,num ,val))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vref (vector pos &optional value)
  (let ((g (gensym)))
    `(let ((,g ,value))
       (if ,g
           (setf (aref ,vector ,pos) ,g)
           (aref ,vector ,pos)))))

(defmacro chvar (sym comp predicate)
  (let ((g (gensym)))
    `(let ((,g ,comp))
       (if (or (null ,sym) (not (funcall ,predicate ,sym ,g)))
           (setf ,sym ,g)))))

(defmacro chmax (sym comp &optional (predicate #'>))
  `(chvar ,sym ,comp ,predicate))

(defmacro chmin (sym comp &optional (predicate #'<))
  `(chvar ,sym ,comp ,predicate))

(defmacro defchangef (name op default-val)
  `(defmacro ,name (var &optional (val ,default-val))
     `(setq ,var (,',op ,val ,var))))
(defmacro read-str ()
  `(write-to-string (read)))

;;本体
(defun main ()
  (let ((w (read)) (h (read))
        (x (read)) (y (read)))
    (format t "~,9F~%" (/ (* w h) 2.0))
    (println (if (and
                  (= w (* x 2))
                  (= h (* y 2)))
                 1 0))))

#-swank(main)


Measured memory_bytes: 12136