akhauriyash/Code-Regression huggingface dataset:
Public Class Main
    Shared Sub Main()
        'Dim n As Integer = 4
        'Dim a(n) As Integer
        'For i As Integer = 0 To n
        'a(i) = Split()
        'Next
        Dim a As String = Console.ReadLine()
        Dim b(a.Length) As String
        For i As Integer = 0 To a.Length - 1
            b(i) = a(i)
        Next
        Dim ans As String = Jud(b)
        Console.WriteLine(ans)
        Console.ReadKey()
    End Sub

    Shared Function Jud(b) As String
        Dim a As String = "Good"
        For i As Integer = 0 To 3
            If b(i) = b(i + 1) Then
                a = "Bad"
            End If
        Next
        Return a
    End Function
End Class


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  string S;
  cin >> S;
  if(S == "ABC"){
    cout << "ARC"<<endl;
  } else{
    cout <<"ABC" <<endl;
  }
}

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

int n;
vector<pair<int, int>>tasks;

int main(void){
    cin >> n;
    for(int i =0;i<n;i++){
        int a,b;
        cin >> a >> b;
        tasks.emplace_back(b,a);
    }
    
    sort(tasks.begin(),tasks.end());
    int sum =0;
    bool isyes = true;
    for(auto v : tasks){
        sum += v.second;
        
        if(sum > v.first){
            isyes = false;
            break;
        }
    }
    
    cout << (isyes ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 2420
import Data.List
main = do
  [n,d] <- map (read::String->Int) . words <$> getLine
  x <- map (map (read::String->Int)) . map words . lines <$> getContents
  print $ length [d|a<-x, b<-(delete a . dropWhile(/=a)) x,
                  let d = sum $ map (^2) $ zipWith (-) a b,
                  is_square d]

is_square n = m * m == n
  where m = int_sqrt(n)
  
int_sqrt :: Int -> Int
int_sqrt n = floor (sqrt (fromIntegral n))

Measured memory_bytes: 4488
#include<stdio.h>
#include<math.h>
int main() {
	double a, b, C, S, L, h;
	scanf("%lf %lf %lf", &a, &b, &C);
	S = a*b*sin(C*3.14159265/180) / 2;
	L = a + b + sqrt(a*a + b*b - 2 * a*b*cos(C*3.14159265/180));
	h = 2 * S / a;
	printf("%.8lf\n", S);
	printf("%.8lf\n", L);
	printf("%.8lf\n", h);
	return 0;
}

Measured memory_bytes: 652
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false;}
const ll INF = 1e18;

ll n, res, xbit, ybit, cnt; 
V<> x(15), y(15), p(15), ans(16, INF), xp, yp;
VV<> xans(100000, V<>(15)), yans(100000, V<>(15));

void solve(string s){
    xp.clear(); yp.clear();
    res = xbit = ybit = cnt = 0;
    REP(i, n){
        if(s[i] == '1'){
            xp.pb(x[i]);
            xbit += (1 << i);
            cnt++;
        }
        if(s[i] == '2'){
            yp.pb(y[i]);
            ybit += (1 << i);
            cnt++;
        }
    }
    if(cnt > n) return;
    REP(i, n) if(s[i] == '0') res += min(xans[xbit][i], yans[ybit][i]);
    chmin(ans[cnt], res);
}

void dfs(string s){
    if(SZ(s) == n){
        solve(s);
        return;
    }
    dfs(s + "0");
    dfs(s + "1");
    dfs(s + "2");
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    REP(i, n) cin >> x[i] >> y[i] >> p[i];
    REP(bit, (1 << n)){
        REP(j, n){
            xans[bit][j] = abs(x[j]) * p[j];
            yans[bit][j] = abs(y[j]) * p[j];
            REP(k, n) if(bit >> k & 1){
                chmin(xans[bit][j], abs(x[j] - x[k]) * p[j]);
                chmin(yans[bit][j], abs(y[j] - y[k]) * p[j]);
            }
        }
    }
    dfs("");
    REP(i, n + 1) cout << ans[i] << '\n';
}

Measured memory_bytes: 32996
#include<stdio.h>

int main(){
	int m,f,r,num;
	for(;;){
		scanf("%d %d %d",&m,&f,&r);
		if(-1==m && -1==f && -1==r) break;
		num=m+f;
		if(m==-1 || f==-1){ printf("F\n"); continue;}
		if(r>=50){ printf("C\n"); continue;}
		if(num>=80){ printf("A\n"); continue;}
		if(num>=65){ printf("B\n"); continue;}
		if(num>=50){ printf("C\n"); continue;}
		if(num>=30){ printf("D\n"); continue;}
		printf("F\n");
	}
	return 0;
}

Measured memory_bytes: 584
def main():
    S = input()

    former = S[:2]
    latter = S[2:]

    if mm_ok(former) and mm_ok(latter):
        print('AMBIGUOUS')
    elif mm_ok(former) and not mm_ok(latter):
        print('MMYY')
    elif mm_ok(latter) and not mm_ok(former):
        print('YYMM')
    else:
        print('NA')

def mm_ok(s):
    months = ['{:0>2}'.format(i+1) for i in range(12)]
    if s in months:
        return True
    else:
        return False


main()


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

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

   bool flg = true;
   for (int i = 0; i < s.size(); i++) {
      if (i % 2 == 0 && s[i] == 'L') flg = false;
      if (i % 2 == 1 && s[i] == 'R') flg = false;
   }
   if (flg) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i,1000) {
        string t;
        int x = i;
        rep(j,3) {
            t += x%10+'0';
            x /= 10;
        }
        int ti = 0;
        rep(k,s.size()) {
            if(t[ti] == s[k]) {
                ti++;
            }
            if(ti == 3) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    int l_i;
    int sum = 0, max = 0;
    // 和と最大辺を同時に求める
    for (int i=0;i<N;i++) {
        cin >> l_i;
        sum += l_i;
        if (max < l_i) max = l_i;
    }
    //最大辺がその他の辺の和より小さければ存在
    if (sum - 2* max > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int Euclid(int A, int B){
  while(true){
    if(A > B){
      A = A % B;
    }
    else B = B % A;
    if (A == 0 || B == 0){
      break;
    }
  }
  if(A == 0){
    return B;
  }
  else return A;
}

int main(){
  int64_t A;
  int64_t B;
  int64_t C;
  int64_t D;
  int64_t ac;
  int64_t ad;
  int64_t bc;
  int64_t bd;
  int64_t x;
  int64_t y;
  cin >> A >> B >> C >> D;
  int64_t cd = C*D/Euclid(C, D);
  bc = B/C;
  bd = B/D;
  x = B/cd;
  ac = (A-1)/C;
  ad = (A-1)/D;
  y = (A-1)/cd;
  cout << (B-(bc+bd-x))-(A-1-(ac+ad-y)) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n, a, b, c;
	scanf("%d", &n);
	
	a = n/100;
	b = (n/10)%10;
	c = n%10;
	
	if (a == 7)
		printf("Yes");
	else if (b == 7)
		printf("Yes");
	else if (c == 7)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	int i,j,n,m,t,h[lim],dp[lim] = {};
	cin>>n;
	for(i=1; i<=n; i++) cin>>h[i];
	dp[n-1] = abs(h[n-1]-h[n]);
	for(i=n-2; i; i--)
		dp[i] = min(dp[i+1] + abs(h[i]-h[i+1]), dp[i+2] + abs(h[i]-h[i+2]));
	cout<<dp[1];
}

Measured memory_bytes: 1024
def shuffle(array, p, c)
  temp = Array.new
  c.times do |i|
    temp[i] = array[i + p - 1]
  end
  j = c - 1
  while j >= 0 do
    array.delete_at(j + p - 1)
    j -= 1
  end
  array.insert(0, temp)
  array.flatten!
end
cards, operations = 1
until cards == 0 && operations == 0 do
deck = Array.new
cards, operations = gets.split(" ").map{|i| i.to_i}
deck = (1..cards).to_a.reverse
ops = Array.new
j = 0
operations.times do
  ops[j], ops[j+1] = gets.split(" ").map{|i| i.to_i}
  shuffle(deck, ops[j], ops[j+1])
  j+=2
end
unless cards == 0 && operations == 0
  puts deck.first
end
end

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

using namespace std;
int main() {
	int a,suma=0,sumb=0;
	for (int i = 0; i< 4; i++) {
		cin >> a;
		suma += a;
	}

	for (int i = 0; i < 4; i++) {
		cin >> a;
		sumb += a;
	}

	if (suma > sumb) {
		cout << suma << endl;
	}
	else {
		cout << sumb << endl;
	}
	
	


	//getchar();
	//getchar();
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;

  int ans =1;
  for(int i=0;i<N-1;i++){
    if(S[i]!=S[i+1]){
      ans++;
    }
  }
  cout << ans <<endl;
}

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

            int n = Integer.parseInt(sc.next());
            int m = Integer.parseInt(sc.next());

            HashMap<Integer, Integer> map = new HashMap<>();

            int countAc = 0;
            int countWaAll = 0;
 
            for(int i = 0 ; i < m; i++){
                int question = Integer.parseInt(sc.next());
                String waOrAc = sc.next();

                if(!map.containsKey(question)){
                    if(waOrAc.equals("WA")) map.put(question, 1);
                    else{
                        map.put(question, -1);
                        countAc++;
                    } 
                }else{
                    int countWa = map.get(question);
                    if(countWa < 0);
                    else{
                        if(waOrAc.equals("WA")) map.replace(question, countWa, countWa + 1);
                        else{
                            map.replace(question, countWa, -countWa);
                            countAc++;
                            countWaAll += countWa;
                        }
                    }
                }
            }

            System.out.println(countAc + " " + countWaAll);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

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

using namespace std;

int main()
{
    int n,a[100005],b,cou=0;
    cin>>n>>b;
    for(int i=0;i<n;i++)
        {cin>>a[i];
        if(a[i]>=b)cou++;}
    cout<<cou<<endl;
    return 0;
}


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

int main()
{
    int a,b;
    cin >> a >> b;
    /*
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    */
    int ans = -1;
    for(int i=1; i<=10000; i++){
        double tmp1 = i*0.08;
        double tmp2 = i*0.10;
        if(a == (int)tmp1 && b == (int)tmp2){
            cout << i << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
static const int INF = 1000000000;
static const int MAX_K = 100000;

static int dp[2][MAX_K];
static int table[MAX_K];

int main(){
	ios_base::sync_with_stdio(false);
	for(int i = 0; i < MAX_K; ++i){
		int c = 0, x = i;
		while(x > 0){
			c += x % 10;
			x /= 10;
		}
		table[i] = c;
	}
	int k;
	cin >> k;
	while(k % 2 == 0){ k /= 2; }
	while(k % 5 == 0){ k /= 5; }
	for(int i = 0; i < MAX_K; ++i){ dp[0][i] = INF; }
	for(int j = 1; j < 10; ++j){
		const int t = k * j;
		const int hi = t / 10, lo = t % 10;
		const int s = table[hi] + lo;
		dp[0][hi] = min(dp[0][hi], s);
	}
	int answer = INF;
	for(int i = 0, r = 1; i < MAX_K; ++i){
		r = (r * 10) % k;
		if(r == k - 1){ answer = 2; }
	}
	for(int d = 0; d < 700; ++d){
		const int cur = d % 2, next = 1 - cur;
		for(int i = 0; i < MAX_K; ++i){
			answer = min(answer, dp[cur][i]);
			dp[next][i] = INF;
		}
		for(int i = 0; i < MAX_K; ++i){
			if(dp[cur][i] >= INF){ continue; }
			for(int j = 0; j < 10; ++j){
				const int t = i + k * j;
				const int hi = t / 10, lo = t % 10;
				const int s = dp[cur][i] - table[i] + table[hi] + lo;
				dp[next][hi] = min(dp[next][hi], s);
			}
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 1536
n,x,y = gets.split.map {|i| i.to_i-1 }
a = Array.new(n+=1) {|i| i.downto(1).to_a } << Array.new(n-1,0)
v = n.downto(1).to_a
f = proc {|a,i,d;b| d < b=a[i] and v[a[i]=d]+=1 and v[b]-=1 }
d = [-1,1]
0.upto(n) {|r|
  d.reject! {|d|
    next 1  if !f[b=a[y+r*d],x,r+1] && r>0
    d = [-1,1]
    1.upto(n) {|c|
      d.reject! {|d| !f[b,x+c*d,r+c+1] }
      break  if !d[0]
    }
  }
  break  if !d[0]
}
puts v[1,n]

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

using namespace std;

typedef complex<double> Point;
const double epx = 1e-10;

bool eq(double a,double b)
{
    return abs(a-b)<epx;
}

bool onSeg(Point a,Point b,Point c)
{
    return eq(abs(a-b),abs(a-c)+abs(b-c));
}

double getArg(Point a,Point b,Point c)
{
    b -= a; c -= a;
    a = c*conj(b);
    return arg(a);
}

int contain(const vector<Point> &points,int sz,Point p)
{
    if(sz<3) return 0;
    for(int i=0;i<sz;i++)
    {
        if(onSeg(points[i],points[(i+1)%sz],p)) return 1;
    }
    double angle = 0;
    for(int i=0;i<sz;i++)
    {
        angle += getArg(p,points[i],points[(i+1)%sz]);
    }
    if(eq(angle,0)) return 0;
    return 2;
}

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

    int n;
    cin>>n;
    vector<Point> points;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        points.emplace_back(x,y);
    }

    int q;
    cin>>q;
    while(q--)
    {
        int x,y;
        cin>>x>>y;
        cout<<contain(points,n,Point(x,y))<<endl;
    }

    return 0;
}



Measured memory_bytes: 3400
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    
    ll ans = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i+1; j < n; j++) if (a[i] > a[j]) ans++;
    }
    ans = ans * k % MOD;

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

    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        auto itr = lower_bound(a.begin(), a.end(), a[i]);
        cnt += itr - a.begin();
        cnt %= MOD;
    }

    ll t = k * (k - 1) / 2 % MOD;
    ans += cnt * t % MOD;
    cout << ans % MOD << endl;
}

Measured memory_bytes: 3268
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<iomanip>
using namespace std;

int main() {
	int N,X;
	cin >> N >> X;
	int tmp;
	int min=1000;
	int sum=0;
	int d=N;
	for(int i=0;i<N;i++){
		cin >> tmp;
		if(tmp < min){
			min=tmp;
		}
		sum += tmp;
	}
	X -= sum;
	d += (X/min);
	cout << d << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define maxn 200010
char s[maxn];
int main() {
    int n, l, r, cnt;
    scanf("%d%s", &n, s + 1);
    l = 1, r = n, cnt = 0;
    while (l < r) {
        while (s[l] == 'R')l++;
        while (s[r] == 'W')r--;
        if (l < r)cnt++,l++,r--;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1916
#include <cstdio>
#include<string>
#include<stack>
#include<queue>
#include<stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include<set>
#include<vector>

#define _CRT_SECURE_NO_WARNINGS

using namespace std;
struct Human
{
	int age;
	double weight;
	char name[256];
};

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) { // n が 0 になるまで
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main()
{
	int l[10000];
	int n = 6;

	string s; // s.size() to_string char string %s
	int a,b,c,d;
	int sum = 0;
	vector<string> lang;
	vector<int> data;


	//cin>>N;
	// for (int i = 0; i < N; ++i) cin >> A[i];
	//while(true){break; ++res;}
	//cout << res << endl;
	//sort(a, a+N, greater<int>()) 大きい順ソート
	//set<int>values; values.insert() values.size()
	//map<string,int>salary; salary["John"] = 1400;
	// string num = to_string(counter);

	int count=0;
	int kari = 0;
	int N, K;

	cin >>a>>b;

	if (a < b)
	{
		cout << "a < b" << endl;
	}
	else if (a == b)
	{
		cout << "a == b" << endl;
	}
	else
	{
		cout << "a > b" << endl;
	}




	return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		while(true){
		//Scanner scan = new Scanner(System.in);


		int H = scan.nextInt();
	    int W = scan.nextInt();


	    if(H == 0 && W == 0)break;
	    for(int i = 0;i < H ;i++){
	    	for(int j = 0;j < W; j++){

	    		//sb.append("#");
	    		System.out.print("#");
	    	}
	    	System.out.println();
	    	//sb.append("\n");
	    }
	    //sb.append(" \n");
	    System.out.println();
	   }
		//System.out.print(sb);
	}
}

Measured memory_bytes: 34500
#include <iostream>
using namespace std;
/*
中間試験、期末試験のいずれかを欠席した場合成績は F。
中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 
ただし、再試験の点数が 50 以上ならば成績は C。
中間試験と期末試験の合計点数が 30 未満ならば成績は F。
*/
int main(void){
  int m,f,r,s;
  
  while (1){
    cin >> m >> f >> r;
    s = m+f;
    if (m==-1 && f==-1 && r==-1) break;
    if (m==-1 || f==-1) cout << "F" << endl;
    else if (s>=80) cout << "A" << endl;
    else if (s>=65) cout << "B" << endl;
    else if (s>=50) cout << "C" << endl;
    else if (s>=30) cout << (r>=50?"C":"D") << endl;
    else cout << "F" << endl;
  }
  return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 5; i >= 0; i--){
        int s = 1;
        for(int j = 0; j < i; j++){
            s = s*10;
        }
        int q;
        q = n/s;
        n = n-q*s;
        if(q != 0) v.push_back(q);
    }
    if(v.size() == 1 && v[0] == 1) {cout << 10 << endl;
    }
    else{
        int sum = 0;
        while(v.size() != 1){
        sum += v[0];
        v.erase(v.begin());
        }
        sum += v[0];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Set<Integer> set = new HashSet<>();

		for(int i = 0; i < k; i++) {
			int d = sc.nextInt();
			for(int j = 0; j < d; j++) {
				int a = sc.nextInt();
				if(!set.contains(a)) set.add(a);
			}
		}

		System.out.println(n - set.size());

		sc.close();
	}
}


Measured memory_bytes: 37596
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;
 
typedef long long LL;
typedef pair < int, int > pa;
 
const int MAXN = 100010;
 
int n, x[MAXN], a[MAXN], w[MAXN], L, T;
LL cur;
 
int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d%d%d", &n, &L, &T );
	for( int i = 0 ; i < n ; i++ )
	{
		scanf( "%d%d", &a[ i ], &w[ i ] );
		if( w[ i ] == 1 )
		{
			x[ i ] = ( a[ i ] + T ) % L;
			cur += ( a[ i ] + T ) / L;
		}
		else
		{
			x[ i ] = ( a[ i ] - T ) % L;
			cur += ( a[ i ] - T ) / L;
			if( x[ i ] < 0 ) x[ i ] += L, cur--;
		}
	}
	cur = ( cur % n + n ) % n;
	sort( x, x + n );
	for( int i = cur ; i < n ; i++ ) printf( "%d\n", x[ i ] );
	for( int i = 0 ; i < cur ; i++ ) printf( "%d\n", x[ i ] );
}


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

#define ll long long 

using namespace std;

int n;
string s,t;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>s>>t;
    for (int i=0; i<n; i++)
        cout<<s[i]<<t[i];
    
    
    
    return 0;
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define debug(x) cout<<#x<<" "<<x<<endl;
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

ll addmod(ll a,ll b)
{
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a %=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    ll x  = a-b;
    if(x<0)x+=mod;
    x%=mod;
    return x;
}
bool comp(pair<pi,ll>a,pair<pi,ll>b)
{
    if(a.fi.fi==b.fi.fi)return a.fi.se<b.fi.se;
    return a.fi.fi<b.fi.fi;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s; cin>>s;
    reverse(all(s));
    ll n = s.size();
    vi arr(n);

    for(ll i=0;i<n;i++)
    {
        arr[i] = ((s[i]-'0')*modexp(10,i,2019))%2019;
    }
    vi pref(n);
    pref[0] = arr[0];
    rep(i,1,n)pref[i]= (pref[i-1]+arr[i])%2019;
    map<ll,ll>mp;
    ll ans = 0;
    for(ll i=0;i<n;i++)
    {
    	//cout<<pref[i]<<endl;
        if(pref[i]==0)ans++;
        ans+=mp[pref[i]];
        mp[pref[i]]++;
        //debug(ans);
    }
    cout<<ans<<endl;
    return 0;
}



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

int keta(string n) {
    int res;
    res = 0;
    for(int i = 0; i < n.size(); i++){
        res += n[i] - '0';
    }
    return res;
}

int main(void) {
    string s;
    int d;
    cin >> s;
    d = stoi(s);
    if(d % keta(s) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

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

  sum[n-1] = 0;
  for(int i=n-2;i>=0;--i){
    sum[i] = (sum[i+1] + a[i+1]) % 1000000007;
  }

  ll ans = 0L;
  for(int i=0; i<n;++i){
    ans = (ans + a[i] * sum[i]) % 1000000007;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6320
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int N, K;
ll A[1000];
ll ruisekiwa[1001];
vector<ll> candidate;
vector<ll> tmp;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> A[i], ruisekiwa[i + 1] = ruisekiwa[i] + A[i];
	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++)candidate.push_back(ruisekiwa[j + 1] - ruisekiwa[i]);
	}

	ll ans = 0;
	int cnt = 0;
	ll MSB = 0;
	ll M = (*max_element(candidate.begin(), candidate.end()));
	while ((1LL << MSB) <= M)MSB++;
	MSB--;

	for (; MSB >= 0; MSB--) {
		for (int i = 0; i < candidate.size(); i++) {
			if (candidate[i] & (1LL << MSB)) {
				cnt++;
				tmp.push_back(candidate[i]);
			}
		}
		if (cnt >= K) {
			ans += (1LL << MSB);
			candidate = tmp;
		}
		tmp.clear();
		cnt = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6124
import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;
import java.awt.Point;

class Comp implements Comparator<Point>{
	public int compare(Point a,Point b){
		return a.x==b.x?a.y-b.y:a.x-b.x;
	}
}

class Main{
	boolean exists(List<Point> ps,Point key){
		return Collections.binarySearch(ps,key,new Comp())>=0;
	}
	int solve(List<Point> ps){
		Collections.sort(ps,new Comp());
		int res=0;
		for(int i=0;i<ps.size();i++) for(int j=i+1;j<ps.size();j++){
			int dx=ps.get(j).y-ps.get(i).y,dy=ps.get(i).x-ps.get(j).x;
			if(exists(ps,new Point(ps.get(i).x+dx,ps.get(i).y+dy)) && exists(ps,new Point(ps.get(j).x+dx,ps.get(j).y+dy)))
				res=Math.max(res,dx*dx+dy*dy);
		}
		return res;
	}
	void run()throws IOException{
		for(int n;(n=nextInt())!=0;){
			List<Point> ps=new ArrayList<Point>(n);
			for(int i=0;i<n;i++)
				ps.add(new Point(nextInt(),nextInt()));
			writer.println(solve(ps));
		}
	}
	
	// ---------- begin template ----------
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	boolean hasNext()throws IOException{
		while(tokenizer==null || !tokenizer.hasMoreTokens()){
			String s=reader.readLine();
			if(s==null)
				return false;
			tokenizer=new StringTokenizer(s);
		}
		return true;
	}
	String next()throws IOException{
		while(tokenizer==null || !tokenizer.hasMoreTokens())
			tokenizer=new StringTokenizer(reader.readLine());
		return tokenizer.nextToken();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(next());
	}
	long nextLong()throws IOException{
		return Long.parseLong(next());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(next());
	}
	BigInteger nextBigInteger()throws IOException{
		return new BigInteger(next());
	}
	void main(){
		try{
			reader=new BufferedReader(new InputStreamReader(System.in));
			tokenizer=null;
			writer=new PrintWriter(System.out);
			run();
			reader.close();
			writer.close();
		}
		catch(Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public static void main(String[] args){
		new Main().main();
	}
	// ---------- end template ----------
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string s;
	cin>>s;
	int si=s.size();
	for(int i=0;i<si;i++)
    {
        if(s[i]=='?')
            s[i]='D';
    }
    cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3740
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
 
void solve()
{
  int n;
  cin >> n;
  int a[n+1];
  fp(i,1,n)
    cin >> a[i];
  int cst[n+1];
  cst[0]=0;
  cst[1]=0;
  cst[2]=cst[1]+abs(a[2]-a[1]);
  fp(i,3,n)
    cst[i]=min(cst[i-2]+abs(a[i-2]-a[i]),cst[i-1]+abs(a[i-1]-a[i]));
  cout << cst[n] << '\n';
  return ;
}

signed main()
{
   FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new  Scanner(System.in);
		String s = sc.next();
		char[] c = s.toCharArray();
		int n = s.length();
		String answer ="";
		for(int i=0;i<n; i++) {
			if(i%2==0 && (c[i]=='R'||c[i]=='U'||c[i]=='D')) {
			   answer="Yes";
			}else if(i%2!=0 && (c[i]=='L'||c[i]=='U'||c[i]=='D')) {
				answer="Yes";
			}else {
				answer="No";
				break;
			}
		}
		System.out.println(answer);
	}

}


Measured memory_bytes: 23764
#include<stdio.h>
int main (void)
{
	int x[10000],y[10000],empty,i=0,j;
	do {
		scanf("%d %d",&x[i],&y[i]);
		if(x[i]>y[i]){
			empty=x[i];
			x[i]=y[i];
			y[i]=empty;
		}
		i++;
	}while(!(x[i-1]==0 && y[i-1]==0));
	for(j=0;j<i-1;j++){
	printf("%d %d\n",x[j],y[j]);
	}
	return 0;
}
	

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



int main() {
int a,N;
  
  cin >> N ;
vector<int> umai(N);
  for(int q = 0;q<N;q++){
  cin >> umai.at(q);
  }
  a = 0;
 for (int i=0;i<N;i++){
 for (int j=0;j<N;j++){
 a += umai.at(i)*umai.at(j);
 }
 }
  for (int k=0;k<N;k++){
  a -= umai.at(k)*umai.at(k);
  }
  
  a = a / 2;
  cout << a << endl;
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())

x = list(map(int,input().split()))
y = list(map(int,input().split()))

x.sort(reverse=True) # x[0]が最大
y.sort() # y[0]が最小

# xの最大がyの最小以上はWar
if(x[0] >= y[0]):
    print("War")
else:
    if(y[0] <= X or x[0] >= Y):
        print("War")
    else:
        print("No War")

Measured memory_bytes: 3060
#include<stdio.h>
int x[2000000],y[2000000];
int main(){
  int i,j,k,n,m,min,nx,ny,r,t;
  int X[]={0,1,0,-1};
  int Y[]={1,0,-1,0};
  while(scanf("%d %d",&n,&m),n||m){
    char d[102][102]={0};
    int c[102][102]={0};
    for(i=1;i<=m;i++){
      for(j=1;j<=n;j++){
	scanf(" %c",&d[i][j]);
	if(d[i][j]=='&'){
	  y[t=0]=i;
	  x[t=0]=j;
	  d[i][j]='.';
	  c[i][j]=1;
	}
      }
    }
    for(r=1;r-t;t++){
      for(k=0;k<4;k++){
	ny=y[t]+Y[k];
	nx=x[t]+X[k];
	if(!d[ny][nx])continue;
	if(d[y[t]][x[t]]==d[ny][nx]){
	  if(c[y[t]][x[t]]<c[ny][nx]||c[ny][nx]==0){
	    c[ny][nx]=c[y[t]][x[t]];
	    x[r  ]=nx;
	    y[r++]=ny;
	  }
	}
	else{
	  if(c[y[t]][x[t]]+1<c[ny][nx]||c[ny][nx]==0){
	    c[ny][nx]=c[y[t]][x[t]]+1;
	    x[r  ]=nx;
	    y[r++]=ny;
	  }
	}
      }
    }
    /*for(i=1;i<=m;i++){
      for(j=1;j<=n;j++)printf("%d ",c[i][j]);
      printf("\n");
      }*/
    min=1000;
    for(i=1;i<=m;i++){
      if(min>c[i][1])min=c[i][1];
      if(min>c[i][n])min=c[i][n];
    }
    for(i=1;i<=n;i++){
      if(min>c[1][i])min=c[1][i];
      if(min>c[m][i])min=c[m][i];
    }
    printf("%d\n",min/2);
  }
  return 0;
}

Measured memory_bytes: 5400
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  105
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l,r,a=0,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n >> m;
    cout << n*m;

}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 3648
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n = int(input())
graphx = []
graphy = []

for i in range(n):
    x,y = map(int,input().split())
    graphx.append((x,y,i))
    graphy.append((x,y,i))
graphx = sorted(graphx, key=lambda x:x[0])
graphy = sorted(graphy, key=lambda x:x[1])
graph = []


for k in range(n-1):
    i,j = graphx[k][2], graphx[k+1][2]
    x0,x1 = graphx[k][0],graphx[k+1][0]
    m = abs(x0-x1)
    graph.append((m,i,j))

for k in range(n-1):
    i,j = graphy[k][2], graphy[k+1][2]
    y0,y1 = graphy[k][1],graphy[k+1][1]
    m = abs(y0-y1)
    graph.append((m,i,j))


graph.sort()
#print(graph)

ans = 0
uf = UnionFind(n)
for c,i,j in graph:
    if not uf.same(i,j):
        ans += c
        uf.union(i,j)
print(ans)

Measured memory_bytes: 52220
#include <stdio.h>

int main(void){
    int i, n, input[20], count=0;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d ", &input[i]);
    }
    for(i=1;i<n-1;i++){
        if((input[i]<input[i+1]&&input[i]>input[i-1])||(input[i]>input[i+1]&&input[i]<input[i-1]))
        count++;
    }
    
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
//↓Union-Find Tree
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
//↑Union-Find Tree
int main(){
	int N,M;
	cin>>N>>M;
	vint A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	UnionFind U(SIZE);
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		U.unionSet(a,b);
	}
	int count=0;
	for(int i=0;i<N;i++){
		if(U.findSet(i+1,A[i])){
			//cout<<A[i]<<endl;
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1144
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>

using namespace std;

int main(){
	int n,d;
	cin>>n>>d;
	int arr[n][d];
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++)
			cin>>arr[i][j];
	}
	int count=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			long long sum = 0;
			for(int k=0;k<d;k++){
				sum += pow((arr[i][k] - arr[j][k]),2);
			}
			int b = sqrt(sum);
			b = pow(b,2);
			if(b==sum)
				count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int K;
	cin >> K;
	if(K % 2 == 0){
		cout << K / 2 * K / 2 << endl;
	}
	else{
		cout << ((K / 2) + 1) * (K / 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<char> v(4);
    rep(i, 4) cin >> v[i];
  SORT(v);
  if(v[0]!=v[3]&&v[1]!=v[2]&&v[0]==v[1]&&v[2]==v[3]){
    cout << "Yes";}else{
    cout << "No";}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,no[51],i,j,s,g,flag;
	
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		
		for(i=0;i<n;i++){
			scanf("%d",&no[i]);
		}
		if(n==1){
			printf("%d\n",no[0]);
			continue;
		}
		
		s=g=no[0];
		flag=0;
		for(i=0;i<n;i++){
			
			if(i==n-1){
				if(no[i]-g==1){
					if(flag==1)printf(" ");
					printf("%d-%d",s,no[i]);
					continue;
				}else{
					if(flag==1)printf(" ");
					if(s==g){
						printf("%d %d",s,no[i]);
						continue;
					}else{
						printf("%d-%d %d",s,g,no[i]);
						continue;
					}
				}
			}
			
			if(no[i]-g>1){
				if(s==g){
					if(flag==1)printf(" ");
					flag=1;
					printf("%d",s);
					s=g=no[i];
					continue;
				}else{
					if(flag==1)printf(" ");
					flag=1;
					printf("%d-%d",s,g);
					s=g=no[i];
					continue;
				}
			}
			g=no[i];
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  ll N;
  cin >> N;
  vector<ll> l(N,0),r(N,0);//r->(  l->)

  FOR(i,0,N){
    string s;
    cin >> s;
    int cnt=0; // ( のあまり
    FOR(j,0,s.size()){
      if(s[j] == '(')cnt++;
      else{
        if(cnt==0)l[i]++;
        else cnt--;
      }
    }
    r[i] = cnt;
  }


  vector<P> p,m;

  ll r_sum = 0;
  ll l_sum = 0;
  FOR(i,0,N){
    if(r[i]==0){
      l_sum += l[i];
    }else if(l[i]==0){
      r_sum += r[i];
    }else{
      if(r[i] > l[i]){
        p.push_back({l[i],r[i]});
      }else{
        m.push_back({-l[i],r[i]});
      }
    }
  }
  SORT(p);
  SORT(m);
  
  bool ok = true;
  ll cntr = r_sum;
  FOR(i,0,p.size()){
    //p[i].second *= -1;
    cntr -= p[i].first;
    if(cntr<0)ok = false;
    cntr += p[i].second;
  }
  FOR(i,0,m.size()){
    m[i].first *= -1;
    cntr -= m[i].first;
    if(cntr<0)ok = false;
    cntr += m[i].second;
  }


  if(ok && cntr==l_sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 18680
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p,int q){
  int x,i,j,k;
  x = A[q];
  i = p-1;
  for(j=p;j<q;j++){
    if(A[j]<=x){
      i++;
      k = A[i];
      A[i] = A[j];
      A[j] = k;
    }
  }

  k = A[i+1];
  A[i+1] = A[q];
  A[q] = k;
  return i+1;
}


int main(){
  int i,q;

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

  q = partition(0,n-1);

  for(i=0;i<n;i++){
    if(i)printf(" ");
    if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q)printf("]");
  }

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


Measured memory_bytes: 2100
#include<stdio.h>

#define N 100001

int parent(int);
int right(int);
int left(int);

int main() {
  int i,x;
  int A[N];

  scanf("%d",&x);
  for(i = 1; i < x + 1; i++) {
    scanf("%d",&A[i]);
  }

  for(i = 1; i < x + 1; i++) {
    printf("node %d: key = %d, ",i,A[i]);

    if(parent(i) > 0) {
      printf("parent key = %d, ",A[parent(i)]);
    }

    if(left(i) < x + 1) {
      printf("left key = %d, ",A[left(i)]);
    }

    if(right(i) < x + 1) {
      printf("right key = %d, ",A[right(i)]);
    }

    printf("\n");
  }

  return 0;
}

int parent(int a) {
  return a / 2;
}

int right(int a) {
  return a * 2 + 1;
}

int left(int a) {
  return  a * 2;
}

    



Measured memory_bytes: 2108
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]),i,a[]=new int[n],t[]=new int[n];
        s=bu.readLine().split(" ");
        ArrayList<ArrayList<Integer>> al=new ArrayList<>();
        for(i=0;i<n;i++)
        {
            a[i]=Integer.parseInt(s[i]);
            ArrayList<Integer> temp=new ArrayList<>();
            al.add(temp);
        }
        for(i=0;i<m;i++)
        {
            s=bu.readLine().split(" ");
            int l=Integer.parseInt(s[0])-1,r=Integer.parseInt(s[1])-1;
            t[l]++; t[r]++;
            if(a[l]>a[r]) al.get(l).add(r);
            else if(a[l]<a[r]) al.get(r).add(l);
        }
        int c=0;
        for(i=0;i<n;i++)
            if(al.get(i).size()==t[i]) c++;
        System.out.print(c);
    }
}


Measured memory_bytes: 64140
#include <stdio.h>
typedef long long ll;ll d[1<<17];int k,m;void f(int a,int n,int o){if(n>45||d[a]&(ll)1<<n)return;d[a]|=(ll)1<<n;if(!a&&n&&n<m)m=n;for(int i=0;i<10;i++)f((a*10+i)%o,n+i,o);}int main(){scanf("%d",&k);m=45;f(0,0,k);printf("%d\n",m);}


Measured memory_bytes: 155648
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

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

int N, a[200001];

int main() {
    cin >> N;
    REP (i, N) {
        cin >> a[i];
    }
    int acc = 1;
    REP (i, N) {
        if (a[i] == acc) {
            acc++;
        }
    }
    if (acc == 1) {
        cout << -1 << endl;
    }
    else {
        cout << N - acc  + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=405;
const int mod=1e9+7;
int dp1[Maxn][Maxn][144],dp2[Maxn][Maxn][144],dp3[Maxn][Maxn][144];
int n,p1[Maxn],p2[Maxn],pos1[Maxn],pos2[Maxn];
int cnt[Maxn][Maxn];
void Add(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}
void Update(int i,int j,int k){
	if (j)dp2[i][j][k]=dp2[i][j-1][k];
	if (!j || cnt[i][j]==cnt[i][j-1]){
		Add(dp2[i][j][k],dp1[i][j][k]);
	}
	else{
		int Use=cnt[i][j]-2*k-1;
		dp2[i][j][k]=1ll*dp2[i][j][k]*max(0,(k-Use))%mod;
		Add(dp2[i][j][k],dp1[i][j][k]);
	}
	
	if (i){
		dp3[i][j][k]=dp3[i-1][j][k]; 
	}
	if (!i || cnt[i-1][j]==cnt[i][j]){
		Add(dp3[i][j][k],dp2[i][j][k]);
	}
	else{
		int Use=cnt[i][j]-2*k-1;
		dp3[i][j][k]=1ll*dp3[i][j][k]*max(0,(k-Use))%mod;
		Add(dp3[i][j][k],dp2[i][j][k]);
	}
}
int main(){
//	freopen("c.in","r",stdin);
//	freopen("c.out","w",stdout);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&p1[i]),pos1[p1[i]]=i;
	for (int i=1;i<=n;i++) scanf("%d",&p2[i]),pos2[p2[i]]=i;
	
	for (int i=1;i<=n;i++){
		cnt[0][i]=i;cnt[i][0]=i;
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			cnt[i][j]=cnt[i-1][j];
			if (pos2[p1[i]]>j) cnt[i][j]++;
		}
	}
	dp1[0][0][0]=1;
	int ans=0;
	for (int i=0;i<=n;i++){
		for (int j=0;j<=n;j++){
			for (int k=0;k<=n/3;k++){
				
				if (i && j && k && cnt[i][j]==cnt[i-1][j-1]+2){
					dp1[i][j][k]=dp3[i-1][j-1][k-1];
				}
				Update(i,j,k);
			}
		}
	}
	ans=dp3[n][n][n/3];
	for (int i=1;i<=n;i++){
		if (i%3==0) continue;
		ans=1ll*ans*i%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 276864