akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // This will work only for g++ compiler. 
using namespace std;
#define fo(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define fon(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
//short hand for usual tokens
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
#define INF (int)1e9
// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())
// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    int x,n;
    cin>>x>>n;
    set<int>st;
    fo(i,n){
        int elem;
        cin>>elem;
        st.insert(elem);
    }
    int part = 0;
    while(true){
        int m = x-part;
        int n = x+part;
        if(st.find(m)==st.end()){
            cout<<m<<endl;
            break;
        }
        if(st.find(n)==st.end()){
            cout<<n<<endl;
            break;
        }
        part++;
    }
    
    return 0;
}

Measured memory_bytes: 3668
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] b = new int[n];
    for(int i = 0; i < n; i++) {
      b[i] = sc.nextInt();
    }
    int f = 0;
    int[] ans = new int[n];
    for(int i = n - 1; i >= 0; i--) {
      int p = 0;
      int t = 0;
      for(int j = n - 1; j >= 0; j--) {
        if(b[j] == (j + 1)) {
          p = 1;
          ans[i] = (j + 1);
          t = j;
          break;
        }
      }
      if(p == 0) {
        f = 1;
        System.out.println(-1);
        break;
      } else {
        for(int j = t; j < n; j++) {
          if(j < n - 1) b[j] = b[j + 1];
          if(j == n - 1) b[j] = 0;
        }
      }
    }
    if(f == 0) {
      for(int i = 0; i < n; i++) {
        System.out.println(ans[i]);
      }
    }
  }
}

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

int main() {
  int s1;
	int x = 0;
  cin >> s1;
  if(s1%10==1 ||s1==1){
  	x=x+1;
  }
  if (s1-100>=0){
    x=x+1;
  }
  if (s1%100>=10||s1==11&&s1==10){
    x=x+1;
  }
  cout << x <<endl;
}

Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

int c[100010];

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

  int n;
  cin >> n;
  int a[n];
  int X = 0;

  for (int i = 0; i < n; i++){
    cin >> a[i];
    X ^= a[i];
  }
  
  for (int i = 0; i < n; i++)
    cout << (X^a[i]) << " ";
  cout << endl;
  

 

  
}


Measured memory_bytes: 5124
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args){
		
		// 方針：タブーリスト付きの深さ優先探索、この手に限る
		
		// 隣接行列、0か1なのでbooleanで十分
		boolean[][] adjacencyMatrix = createAdjacencyMatrix();
		int n= adjacencyMatrix.length;
		// 訪問履歴、タブーリスト
		boolean[] history = new boolean[n];
		// 1番のノード（インデックスの0）から探索を始めるよ
		history[0] = true;
		int eulerianTrailNum = traverseAndCountEulerianTrail(0, adjacencyMatrix, history);
		System.out.println(eulerianTrailNum);
		
	}
	
	// 入力から隣接行列を作る
	public static boolean[][] createAdjacencyMatrix(){
		
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		
		boolean[][] ret = new boolean[n][n];
		
		IntStream.range(0, m)
			.forEach(nouse -> {
				// 配列の番号じゃなくて、ノード番号で渡されるので-1
				int p = scan.nextInt() - 1;
				int q = scan.nextInt() - 1;
				ret[p][q] = true;
				ret[q][p] = true;
			});
		
		scan.close();
		return ret;
		
	}
	
	public static int traverseAndCountEulerianTrail(int currentNode, boolean[][] adjacencyMatrix, boolean[] history) {
		
		int n = history.length;
		// ここがゴールだったみたいです。1本見つけましたよ
		if(IntStream.range(0, n).boxed().allMatch(index -> history[index])) {
			return 1;
		}
		
		// ゴールじゃなかったので再帰して木探索してきてね
		return IntStream.range(0, n)
						// 隣接してて、行ったことのないところに行きたい
						.filter(index -> adjacencyMatrix[currentNode][index] && history[index] == false)
						.map(index -> {
							history[index] = true;
							// 再帰していってきます
							int num = traverseAndCountEulerianTrail(index, adjacencyMatrix, history);
							// 深さ優先探索なので配列を使いまわせる
							history[index] = false;
							return num;
						})
						.sum();
		
	}

}


Measured memory_bytes: 46764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 数値
		// int n1 = sc.nextInt();
		String n1 = sc.next();

		if ("AAA".equals(n1) || "BBB".contentEquals(n1)) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}

		//		for (int i = 0; i < n; i++) {
		//			System.out.println(n1);
		//
		//		}

	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    vector<ll> A(3,0);
    cin>>A[0]>>A[1]>>A[2];
    sort(A.begin(), A.end());
    ll ans=0;
    ans+=A[2]-A[1];
    while(A[0]<A[1]){
        A[0]+=2;
        ans++;
    }
    if(A[0]!=A[1])ans++;
    print(ans)

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
 
typedef long long ll;
int main() {
  string predicted_weather, actual_weather;
  cin >> predicted_weather;
  cin >> actual_weather;
  int answer = 0;
  rep(i, 3) {
    if(predicted_weather[i] == actual_weather[i]) answer++;
  }
  cout << answer << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
int n;
int ans=0;
typedef vector<int> vi;
int main()
{
  while(1)
    {
      int n,m,p;
      cin >> n >> m >> p;
      if(!n) break;
      vi x(n);
      int totalbet=0;
      for(int i=0;i<n;i++)
	{
	  cin >> x[i];
	  totalbet+=x[i]*100;
	}
      totalbet-=(totalbet*p/100);
      if(x[m-1]>0) cout << totalbet/x[m-1] << endl;
      else cout << 0 << endl;
    }
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
  int a,b;
  cin >> a >> b;
  int k;
  k = a+b;
  
  if(k%2 == 0) cout << k/2 <<endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

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

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

    int D;
    cin >> D; 

    int cnt=0;

    vector<vector<int>> data(N,vector<int>(D));

    for(int i=0; i<N; i++){
        for(int j=0; j<D; j++){
            cin >> data.at(i).at(j);
        }
    }
    for(double i=0; i<N; i++){
        for(double j=i+1; j<N; j++){
            double ans=0;
            for(double k=0; k<D; k++){
                ans += pow(data.at(i).at(k)-data.at(j).at(k),2);
            }

            ans =pow(ans,0.5);

            if(ans == (int)ans)cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {
  bool all_visited = true;
  rep(i,N) {
    if (visited[i]==false) all_visited = false;
  }
  if (all_visited) return 1;

  int ret = 0;
  rep(i,N) {
    if (graph[v][i] == false) continue;
    if (visited[i]) continue;

    visited[i] = true;
    ret += dfs(i,N,visited);
    visited[i] = false;
  }
  return ret;
}

int main () {
  int N, M;
  cin >> N >> M;
  
  rep(i,M) {
    int A, B;
    cin >> A >> B;
    graph[A-1][B-1] = graph[B-1][A-1] = true;
  }

  bool visited[nmax];
  rep(i,N) visited[i] = false;

  visited[0] = true;
  cout << dfs(0,N,visited) << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"unicode"
)

func main() {
	alph := []string{
		"a", "b", "c", "d", "e", "f", "g", "h", "i",
		"j", "k", "l", "m", "n", "o", "p", "q", "r",
		"s", "t", "u", "v", "w", "x", "y", "z",
	}
	count := make(map[string]int)
	for _, a := range alph {
		count[a] = 0
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)

	for sc.Scan() {
		s := strings.ToLower(sc.Text())
		runes := []rune(s)
		for _, r := range runes {
			if unicode.IsLetter(r) {
				count[string(r)]++
			}
		}
	}

	for _, a := range alph {
		fmt.Printf("%s : %d\n", a, count[a])
	}
}



Measured memory_bytes: 1116
N = int(input())

# 桁数の多い方の数字の桁数を返す関数
def f(a, b):
    a_digits = len(list(str(a)))
    b_digits = len(list(str(b)))
    return max([a_digits, b_digits])

f_min = 10**10
for a in [i for i in range(1, int(N**0.5)+1) if N % i == 0]:
    b = int(N / a)
    if f(a, b) < f_min:
        f_min = f(a, b)

print(f_min)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

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


    int a,t,t2,t3;
    cin >> a;
    t = a%10;
    t2= (a/10)%10;
    t3= a/100;
    if(t==7 || t2==7 || t3==7){
        cout<<"Yes"<<endl;
    }   
    else {
        cout<<"No"<<endl;
    }   
}


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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  int sum = a1 + a2 + a3;
  if (sum >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void)
{
	double x, h,s;

	while (1) {
		scanf("%lf",&x);
		scanf("%lf", &h);
	    if ((x == 0) && (h == 0)) break;

		h = sqrt(h*h + ((x/2)*(x/2)));
		s = x*x + x*h*0.5 * 4;
		printf("%lf\n",s);
	}
	return 0;
}

Measured memory_bytes: 644
n,a,b,c,d = map(int,input().split())
s=input()+"."
if c<d or (c>d and "..." in s[b-2:d+1]):
    if "##" not in s[b:d] and "##" not in s[a:c]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3572
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>

int search(int arr[], int n, int x);
void mergeSort(int arr[], int l, int r);
void merge(int arr[], int l, int m, int r);


int main(void){
	int n;
	scanf("%i", &n);
	int flag = 0;
	int count = 0;
	for(int i=0; i<n; i++){
	    int d1 = 0, d2 = 0;
	    scanf("%i %i", &d1, &d2);
	    if(d1 == d2){
	        count++;
	    }
	    if(count==3){
	        flag=1;
	        break;
	    }
	    if(d1!=d2){
	        count = 0;
	    }
	}

	if(flag){
	    printf("Yes");
	}
	else{
	    printf("No");
	}

}

int search(int arr[], int n, int x)
{
    int i;
    for (i = 0; i < n; i++)
        if (arr[i] == x)
            return i;
    return -1;
}

void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 = r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1 + j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2) {
        if (L[i] <= R[j]) {
            arr[k] = L[i];
            i++;
        }
        else {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1) {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2) {
        arr[k] = R[j];
        j++;
        k++;
    }
}

void mergeSort(int arr[], int l, int r)
{
    if (l < r) {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l + (r - l) / 2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m + 1, r);

        merge(arr, l, m, r);
    }
}

Measured memory_bytes: 1736
#include <algorithm>
#include<vector>
#include<map>
#include<iostream>
#include<string>

typedef long long ll;

using namespace std;

int main()
{
	//ACGT 
	string s;

	cin >> s;

	int count = 0;
	int maxv = 0;

	for (char c : s)
	{
		if (c == 'A' || c == 'C' || c == 'G' || c == 'T')
		{
			count++;
		}
		else
		{
			maxv = max(maxv, count);
			count = 0;
		}
	}

	maxv = max(maxv, count);

	cout << maxv;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#include <cstring>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	ll X, Y;
	cin >> X >> Y;

	ll cnt = 0;
	for ( ll i = X; i <= Y; i *= 2 )
	{
		++cnt;
	}

	cout << cnt << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

class UnionFind {
  vector<int> parent;

  public:
  UnionFind(void) {}
  UnionFind(const int size) { init(size); }
  void init(const int size) { parent.assign(size, -1); }
  int  find(int x) {
    if (parent[x] < 0) return x;
    return parent[x] = find(parent[x]);
  }
  bool unite(int a, int b) {
    a = find(a), b = find(b);
    if (a == b) return false;
    if (parent[a] > parent[b]) swap(a, b);
    parent[a] += parent[b];
    parent[b]  = a;
    return true;
  }
  bool same(int a, int b) { return find(a) == find(b); }
  int  size(int x) { return -parent[find(x)]; }
};

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep (i, m) {
    int x, y;
    cin >> x >> y;
    a[i] = --x, b[i] = --y;
  }
  UnionFind uf(n);
  vector<lint> ans(m, (lint)n * (n - 1) / 2);
  lint ok = 0;
  for (int i = m - 1; i > 0; --i) {
    lint asize = uf.size(a[i]), bsize = uf.size(b[i]);
    if (uf.unite(a[i], b[i])) {
      if (asize > 1) ok -= asize * (asize - 1) / 2;
      if (bsize > 1) ok -= bsize * (bsize - 1) / 2;
      lint absize = uf.size(a[i]);
      ok += absize * (absize - 1) / 2;
    }
    ans[i - 1] -= ok;
  }
  allrep (x, ans) cout << x << "\n";
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main() {
	int a1,a2,a3;
	scanf("%d %d %d", &a1,&a2,&a3);
	
	if(a1+a2+a3>21) {
		printf("bust");
	} else {
		printf("win");
	}
	return 0;
}

Measured memory_bytes: 128
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int p[n];
    int pm = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        ans += p[i];
        if (pm < p[i]) {
            pm = p[i];
        }
    }
    ans -= pm / 2;
    cout << ans;
}


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

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

    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes";
    else cout << "No";

	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
signed main() {
	ll n, a, cnt = 1, ans = 0; cin >> n >> a;
	for (int h = 1; h < a - n; h++) {
		ans += h;
	}
	cout << ans - n << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std;
using uint = unsigned int;

int main() {
	string S;
	cin >> S;
	
	for(uint i=0; i<S.length(); i++) {
		if(i % 2 == 0 && S.substr(i, 1) == "L") {
			cout << "No";
			return 0;
		} else if(i % 2 == 1 && S.substr(i, 1) == "R") {
			cout << "No";
			return 0;
		}
	}
	
	
	cout << "Yes";
			
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char S[4],T[4];
  int ans=0;
  scanf("%s\n%s",S,T);
  for(int i=0;i<3;i++)
    if(S[i]==T[i]) ans++;
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
 
int main(){
  int n[5],m,i,j;
 
  while(scanf("%d,%d,%d,%d,%d",&n[0],&n[1],&n[2],&n[3],&n[4])!=EOF){
    for(i=0;i<4;i++) 
      for(j=i+1;j<5;j++) 
	if(n[i]>n[j]) { 
	  m=n[i];
	  n[i]=n[j];
	  n[j]=m;
	}

    if((n[0]+1==n[1] && n[1]+1==n[2] && n[2]+1==n[3] && n[3]+1==n[4]) ||(n[0]==1 && n[1]==10 && n[2]==11 && n[3]==12 && n[4]==13)) 
      printf("straight\n");

    else if((n[0]==n[1] && n[0]==n[2] && n[0]==n[3]) || (n[1]==n[2] && n[1]==n[3] && n[1]==n[4])) 
      printf("four card\n");

    else if((n[0]==n[1] && n[0]==n[2] && n[3]==n[4]) || (n[0]==n[1] && n[2]==n[3] && n[2]==n[4])) 
      printf("full house\n");

    else if((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3]) || (n[2]==n[3] && n[3]==n[4])) 
      printf("three card\n");

    else if((n[0]==n[1] && (n[2]==n[3] || n[3]==n[4])) || (n[1]==n[2] && n[3]==n[4]))
      printf("two pair\n");

    else if(n[0]==n[1] || n[1]==n[2] || n[2]==n[3] || n[3]==n[4]) 
      printf("one pair\n");

    else 
      printf("null\n");
  }
  return 0;
}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

ll sum[4][110];

int main(){
    ll N, W; cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i,N) cin >> w[i] >> v[i];
    vector<vector<ll>> vec(4);
    rep(i,N) vec[w[i] - w[0]].push_back(v[i]);
    rep(i,4) sort(RALL(vec[i]));
    rep(it,4){
        //累積和
        sum[it][0] = 0;
        for(int i = 0; i < 110; ++i){
            sum[it][i+1] = sum[it][i] + (i < vec[it].size() ? vec[it][i] : 0);
        }
    }
    ll ans = 0;
    for(int a = 0; a <= N && w[0] * a <= W; ++a){
        for(int b = 0; b+a <= N && w[0] * a + (w[0]+1) * b <= W; ++b){
            for(int c = 0; c+b+a <= N && w[0] * a + (w[0]+1) * b + (w[0]+2) * c <= W; ++c){
                int d = min((ll)N - a - b - c, (ll)(W - (w[0] * a + (w[0]+1) * b + (w[0]+2) * c))/(w[0] + 3));
                ll tmp = sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d];
                //cout << a << b << c << d  << endl;
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# AGC003A - Wanna go back home
from collections import Counter


def main():
    D = Counter(input().rstrip())
    flg = True
    if (
        (D["N"] != 0 and D["S"] == 0)
        or (D["N"] == 0 and D["S"] != 0)
        or (D["E"] != 0 and D["W"] == 0)
        or (D["E"] == 0 and D["W"] != 0)
    ):
        flg = False
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int x,y;
  cin >> x>>y;
  if(x+y<10){
    cout << x+y << endl;
  }
  else{
    cout << "error" << endl;
  }
}
      

Measured memory_bytes: 3596
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def solve(A):
    if N == 1:
        return True

    S = sum(A)
    if S % ((N + 1) * N // 2) != 0:
        return False
    # 箱を選ぶ回数
    K = S // ((N + 1) * N // 2)

    cnt = 0
    for i in range(N):
        j = (i + 1) % N
        d = A[j] - A[i]
        if (K - d) % N != 0:
            return False
        if (K - d) // N < 0:
            return False
        cnt += (K - d) // N
    return cnt == K


if solve(A):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 14784
n=int(input())
xy=[list(map(int, input().split())) for _ in range(n)]
a1=0
a2=xy[0][0]+xy[0][1]
b1=xy[0][0]-xy[0][1]
b2=xy[0][0]-xy[0][1]
for i in range(n):
    res1=xy[i][0]+xy[i][1]
    res2=xy[i][0]-xy[i][1]
    a1=max(a1,res1)
    a2=min(a2,res1)
    b1=max(b1,res2)
    b2=min(b2,res2)
ans=max(a1-a2,b1-b2)
print(ans)


Measured memory_bytes: 102356
/*
** Longest Common Subsequence
*/

# include <cstdio>
# include <cstring>
# include <algorithm>
using namespace std;

const int MAX = 1000 + 5;

char s1[MAX], s2[MAX];
int c[MAX][MAX];

int lcs() {
    int m = strlen(s1+1);
    int n = strlen(s2+1);
    c[0][0] = 0;
    int maxl = 0;
    for (int i = 1; i <= m; i++) {
        c[i][0] = 0;
    }
    for (int i = 1; i <= n; i++) {
        c[0][i] = 0;
    }

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (s1[i] == s2[j]) {
                c[i][j] = c[i - 1][j - 1] + 1;
            }
            else {
                c[i][j] = max(c[i][j - 1], c[i - 1][j]);
            }
            maxl = max(maxl, c[i][j]);
        }
    }

    return maxl;
}

void solve() {
    int n;
    scanf("%d", &n);
    while (n--) {
        scanf("%s %s", s1+1, s2+1);
        printf("%d\n", lcs());
    }
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 6636
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;

int main(void){
    int n,ac = 0,wa = 0,tle = 0,re = 0;
    cin >> n;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }

    for(int j = 0; j < n; j++){
        if(s[j] == "AC") ac++;
        else if(s[j] == "WA") wa++;
        else if(s[j] == "TLE") tle++;
        else if(s[j] == "RE") re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;    
}

Measured memory_bytes: 6676
fun main(args: Array<String>) {
    val (N, Q) = readLine()!!.split(" ").map(String::toInt)
    val S = readLine()!!
    val LR = Array(Q) { readLine()!!.split(" ").map(String::toInt).let { Pair(it[0], it[1]) } }

    val array = IntArray(S.length)
    for (i in 1 until S.length) {
        if (S.substring(i - 1, i + 1) == "AC") {
            array[i] = array[i - 1] + 1
        } else {
            array[i] = array[i - 1]
        }

    }
    LR.forEach {
        val (first, second) = it
        println(array[second - 1] - array[first - 1])
    }
}



Measured memory_bytes: 77608
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    inf=10*20
    N=I()
    A=[[]for _ in range(N)]
    A2=[[1]*N for _ in range(N)]
    ans=0
    for i in range(N):
        A[i]=LI()
        ans+=sum(A[i])
        
    


        
    def warshall_floyd(d):
        #d[i][j]: iからjへの最短距離
        for k in range(N):
            for i in range(N):
                if k==i:
                    continue
                for j in range(N):
                    if j==i or j==k:
                        continue
                    dd=d[i][k] + d[k][j]
                    #d[i][j] = min(d[i][j],d[i][k] + d[k][j])
                    
                    if dd==d[i][j]:
                        A2[i][j]=0
                    elif dd<d[i][j]:
                        return -1
        return 1
    
    if warshall_floyd(A)==-1:
        ans=-2
    else:
        ans=0
        for i in range(N):
            for j in range(N):
                ans+=A[i][j]*A2[i][j]
        
        
    print(ans//2)
        
    

main()

Measured memory_bytes: 43740
#include<bits/stdc++.h>
using namespace std;
bool iss(string s)
{
  int a=s.size();
  for(int i=0;i<a/2;i++)
  {
    if(s[i]!=s[a-1-i])
     { 
      return 0;
  }}
  return 1;
}
int main()
{
  string s;
  cin>>s;
  int a=s.size();
  if(iss(s))
  {
    if(iss(s.substr(0,(a)/2)));
           {
             if(iss(s.substr(((a-1)/2)+1,(a)/2)))
                    {cout<<"Yes";return 0;}
           }
  }cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
    int  main(){
    int a,b,i;
    scanf("%d%d",&a,&b);
    if (a>b)
{
	for(i=1;i<=a;i++)
	printf("%d",b);
}
else
for(i=1;i<=b;i++)
printf("%d",a);
    }

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> x, y;
    rep(i, n){
        int a;
        cin >> a;
        if(a < 0){
            y.push_back(abs(a));
        }else{
            x.push_back(a);
        }
    }
    if(y.size() > 0){
        sort(y.begin(), y.end());
    }


    int ans = INF;
    if(y.size() >= k && ans > y[k-1]){
        ans = y[k-1];
    }
    if(x.size() >= k && ans > x[k-1]){
        ans = x[k-1];
    }

    for(int i = 1; i < k-1; i++){
        if(x.size() < i+1 || y.size() < k-1-i){
            continue;
        }

        int mi = min(x[i], y[k-2-i]);
        int ma = max(x[i], y[k-2-i]);

        if(mi * 2 + ma < ans){
            ans = mi * 2 + ma;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int N=2e5+5;
int32_t main(){

    int a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    int s=abs(a-b);
    int p=(v-w)*t;
    if(p>=s)cout<<"YES\n";
    else cout<<"NO\n";

    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#define INF 10000000
#define N 100
int m[N][N];
int p[N], n;
 

 
void matrixChainOrder() {
  int i, j, l, k, q;
  for (i = 1; i <= n; i++) {
    m[i][i] = 0;
  }
  for (l = 2; l <= n; l++) {
    for (i = 1; i <= n-l+1; i++) {
      j = i+l-1;
      m[i][j] = INF;
      for (k = i; k <= j-1; k++) {
        q = m[i][k] + m[k+1][j] + p[i-1] * p [k] * p[j];
       if(m[i][j]>q) m[i][j] = q; 
      }
    }
  }
}
 
int main() {
  int i, j;
  scanf("%d\n", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d\n", &p[i], &p[i+1]);
  }
  matrixChainOrder();
  printf("%d\n", m[1][n]);
 
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <stdlib.h>
#define inf 99999

using namespace std;

bool check(int *label, int n)
{
	for(int i = 1; i <= n; i++){
		if(label[i] == 0){
			return true;
		}
	}
	
	return false;
}

void dij(int **a, int n, int s, int t)
{
	int *label, current=s, num=1, next, *cost, min;
	
	cost = (int *)calloc(n+1, sizeof(int));
	label = (int *)calloc(n+1, sizeof(int));
	
	for(int i = 1; i <= n; i++){
		cost[i] = a[current][i];
	}
	label[current] = num++;
	
	while(check(label, n)){
		min = inf;
		for(int i = 1; i <= n; i++){
			if(min >= cost[i] && label[i] == 0){
				min = cost[i];
				next = i;
			}
		}
		label[next] = num++;
		for(int i = 1; i <= n; i++){
			if(label[i] == 0 && cost[i] > (a[next][i]+cost[next])){
				cost[i] = a[next][i] + cost[next];
			}
		}
		current = next;
	}
	cout << cost[t] << endl;
	
	free(cost);
	free(label);
	
	return ;
}

int main(int argc, char **argv)
{
	int **t, **c, n, m, a, b, p, q;
	
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		
		t = (int **)calloc(m+1, sizeof(int));
		c = (int **)calloc(m+1, sizeof(int));
		for(int i = 0; i <= m; i++){
			t[i] = (int *)calloc(m+1, sizeof(int));
			c[i] = (int *)calloc(m+1, sizeof(int));
		}
		
		for(int i = 0; i < n; i++){
			cin >> a >> b >> p >> q;
			c[a][b] = c[b][a] = p;
			t[a][b] = t[b][a] = q;
		}
		for(int i = 1; i <= m; i++){
			for(int j = 1; j <= m; j++){
				if(i != j && c[i][j] == 0){
					c[i][j] = inf;
				}
				if(i != j && t[i][j] == 0){
					t[i][j] = inf;
				}
			}
		}
		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> a >> b >> p;
			if(p == 0){
				dij(c, m, a, b);
			} else {
				dij(t, m, a, b);
			}
		}
		
		for(int i = 0; i <= m; i++){
			free(t[i]);
			free(c[i]);
		}
		free(t);
		free(c);
	}
	
	return 0;
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  int r1, c1;
  cin >> r1 >> c1;
  int r2, c2;
  cin >> r2 >> c2;
  vector <vpii> g(n * m);
  auto get = [&] (int r, int c) { return r * m + c; };
  vector <string> s(n);
  r1--, r2--;
  c1--, c2--;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int r = 0; r < n; r++) {
    for (int c = 0; c < m; c++) {
      if (s[r][c] != '.') continue;
      int u = get(r, c);
      for (int nr = r; nr <= r + 2; nr++) {
        for (int nc = c - 2; nc <= c + 2; nc++) {
          if (nr == r and nc == c) continue;
          if (not (0 <= nr and nr < n)) continue;
          if (not (0 <= nc and nc < m)) continue;
          if (s[nr][nc] != '.') continue;
          int d = abs(nr - r) + abs(nc - c);
          int cost = 1;
          if (d == 1) cost = 0;
          int v = get(nr, nc);
          g[u].pb(pii(v, cost));
          g[v].pb(pii(u, cost));
        }
      }
    }
  }
  const int INF = 1e9;
  vi dis(n * m, INF);
  dis[get(r1, c1)] = 0;
  set <pii> Q;
  Q.insert(pii(0, get(r1, c1)));
  while (not Q.empty()) {
    int u = (*begin(Q)).second;
    Q.erase(begin(Q));
    for (auto pp: g[u]) {
      int v = pp.first;
      int w = pp.second;
      if (dis[v] > dis[u] + w) {
        Q.erase(pii(dis[v], v));
        dis[v] = dis[u] + w;
        Q.insert(pii(dis[v], v));
      }
    }
  }
  if (dis[get(r2, c2)] == INF) {
    cout << -1 << '\n';
  } else {
    cout << dis[get(r2, c2)] << '\n';
  }
  /*
  for (int r = 0; r < n; r++) {
    for (int c = 0; c < m; c++) {
      cout << dis[get(r, c)] << ' ';
    }
    cout << endl;
  }
  */
  return (0);
}


Measured memory_bytes: 113480
#include <iostream>

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	while (H && W) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W ; j++) {
				if (i % 2 == 0 && j % 2 == 0)
					cout << "#";
				else if (i % 2 == 1 && j % 2 == 1)
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
	return 0;
}

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

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

    vector<pair<ll, ll> > p;
    for(int i = 0; i < n ; i++){
        ll t, k;
        cin >> t >> k;
        p.push_back(make_pair(k, t));
    }
  
    vector<pair<int, int> > dis;
    for(int i = 0; i < n; i++){
        ll k = p[i].second + p[i].first;
        ll t = p[i].second - p[i].first;
        dis.push_back(make_pair(k, t));
    }

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

    int cou = 0;
    ll now = -10e9 - 9;
    for(int i = 0; i < dis.size(); i++){
        if(now <= dis[i].second){
            cou++;
            now = dis[i].first;
        }
    }

    cout << cou << endl;
}

Measured memory_bytes: 3568
#include <iostream>

using namespace std;

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

    int typeArray[n];
    int like[n][m];
    for (int i = 0; i < n; i++)
    {
        int typeCount;
        cin >> typeCount;
        typeArray[i] = typeCount;
        for (int j = 0; j < typeCount; j++)
        {
            cin >> like[i][j];
        }
    }

    if (n == 1)
    {
        cout << typeArray[0] << endl;
        return 0;
    }

    int count = 0;
    for (int i = 0; i < typeArray[0]; i++)
    {
        int matchNum = like[0][i];
        for (int j = 1; j < n; j++)
        {
            bool isMatch = false;
            for (int k = 0; k < typeArray[j]; k++)
            {
                if (matchNum == like[j][k])
                {
                    isMatch = true;
                    break;
                }
            }
            if (!isMatch)
            {
                break;
            }

            if (j == n-1)
            {
                count++;
            }
        }
    }

    cout << count << endl;
    return 0;
}

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

using namespace std;

int n,ans,i,b[105];

int main()
{
	scanf("%d",&n);
	for(i=1;i<n;i++)
		scanf("%d",&b[i]);
	for(i=2;i<n;i++)
		ans+=min(b[i],b[i-1]);
	printf("%d",ans+b[1]+b[n-1]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  int a[100009];
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=n;i++){
    if(i==a[a[i]])cnt++;
  }
  cout<<cnt/2<<endl;
  return(0);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

struct UnionFind {
    vector<int> par;
    vector<int> siz;

    UnionFind(int n) : par(n), siz(n, 1) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root (int i) {
        while (par[i] != i) {
            i = par[i] = par[par[i]];
        }
        return i;
    }
    bool marge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool is_same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int i) {
        return siz[root(i)];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    map<P, bool> mp;
    rep(i,m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        /*
        if (mp[make_pair(x, y)]) {
            continue;
        }
        mp[make_pair(x, y)] = true;
        */
        uf.marge(x, y);
    }
    vector<int> a = uf.siz;
    
    set<int> st;
    /*
    rep(i,n) {
        st.insert(a[i]);
    }
    */

    int ans = 1;
    rep(i,n) {
        ans = max(ans, a[i]);
    }

    // cout << st.size() << endl;
    cout << ans << endl;
}

Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
int main() {
   int N, M;
   cin >> N >> M;
   vector<int> roads(N);
   for(int i=0; i<M; ++i){
       int a, b;
       cin >> a >> b;
       ++roads.at(a-1);
       ++roads.at(b-1);
   }
   
   for(int i=0; i<N; ++i){
       cout << roads.at(i) << endl;
   }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int sum = n[0] + n[1];
        Console.WriteLine(sum >= 10 ? "error" : sum.ToString());
    }
}


Measured memory_bytes: 11348
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S; cin >> S;
    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
}


Measured memory_bytes: 3624
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


n, m = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(m)]

ans = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
            uf.union(edges[j][0]-1, edges[j][1]-1)
    c = 0
    for j in range(n):
        if j == uf.find(j):
            c += 1
    if c > 1:
        ans += 1

print(ans)


Measured memory_bytes: 42608
def print_repeat(time, word):
    for n in range(0, time):
        print("{}".format(word), end="")


sx,sy,tx,ty = map(int, input().split())
S = abs(sy-ty)
T = abs(sx-tx)
print_repeat(S,'U')
print_repeat(T,'R')
print_repeat(S,'D')
print_repeat(T+1,'L')
print_repeat(S+1,'U')
print_repeat(T+1, 'R')
print_repeat(1, 'D')
print_repeat(1, 'R')
print_repeat(S+1,'D')
print_repeat(T+1,'L')
print_repeat(1,'U')


Measured memory_bytes: 4468
# -*- coding: utf-8 -*-
n = int(input())
b = list(map(int,input().split()))

b.sort(reverse=True)
ret = 0
from collections import deque
stack_deque = deque([])
if n == 1:
    print(0)
    import sys
    sys.exit()
if n == 2:
    print(b[0])
    import sys
    sys.exit()

stack_deque.append(b[1])
stack_deque.append(b[1])
ret = b[0]
for bi in b[2::]:
    ret += stack_deque.popleft()
    stack_deque.append(bi)
    stack_deque.append(bi)
print(ret)

Measured memory_bytes: 31676
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll=unsigned long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;}  

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
using P=pair<int,int>;
int d[4]={1,-1};
int dist[250001],ans;
bool ch[250001];
int main(){
  int now,N,M;
  scanf("%d",&N);
  d[2]=N;d[3]=-N;
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      dist[i*N+j]=min({i,j,N-i-1,N-j-1});
    }
  }
  M=N*N;
  for(int times=0;times<M;++times){
    now-=scanf("%d",&now);
    ans+=dist[now];
    queue<P> que;
    que.push(P(dist[now]-1,now));
    while(!que.empty()){
      P x=que.front();que.pop();
      if(!chmin(dist[x.second],x.first))continue;
      for(int i=0;i<4;++i){
        if(x.second+d[i]>=0&&x.second+d[i]<M)que.push(P(x.first+1-ch[x.second+d[i]],x.second+d[i]));
      }
    }
    ch[now]=true;
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 4996