akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    char b; cin >> b;
    if(b == 'A') {
        cout << "T" << endl;
    } else if(b == 'T') {
        cout << "A" << endl;
    } else if(b == 'G') {
        cout << "C" << endl;
    } else {
        cout << "G" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')


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

if y % 2 == 1:
    print('No')
else:
    if x * 2 <= y <= x * 4:
        print('Yes')
    else:
        print('No')


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

int main(void) {
  ll M, N;
  while(cin >> M >> N, N && M) {
    vector<string> S(N);
    REP(i, 0, N) cin >> S[i];

    const ll INF = 1LL << 50;
    ll m2 = M * 2;
    vector<ll> dp(1LL << m2, INF);
    REP(i, 0, N) {
      ll s = 0;
      REP(j, 0, M) {
        ll x = S[i][j] - '0';
        s = s | (x << (j * 2));
      }
      dp[s] = 0;
    }

    REP(s, 0, 1LL << m2) {
      bool skip = false;
      REP(i, 0, M) if(((s >> (i * 2)) & 3LL) == 3) skip = true;
      if(skip) continue;

      REP(i, 0, M) if(s & (1LL << (i * 2 + 1))) {
        ll s0 = s - (1LL << (i * 2 + 1));
        ll s1 = s - (1LL << (i * 2 + 1)) + (1LL << (i * 2));
        ll v0 = dp[s0];
        ll v1 = dp[s1];

        if(v0 < INF && v1 < INF) dp[s] = min(dp[s], max(v0, v1) + 1);
        else if(v0 < INF) dp[s] = min(dp[s], v0);
        else if(v1 < INF) dp[s] = min(dp[s], v1);
      }
    }

    ll ans_s = 0;
    REP(i, 0, M) ans_s = ans_s | (1LL << (i * 2 + 1));
    cout << dp[ans_s] << endl;
  }
}


Measured memory_bytes: 36208
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  int SUM = 0;
  rep(i, N) {
    cin >> A[i];
    SUM += A[i];
  }
  int AVG1 = SUM / N;
  int AVG2 = AVG1 + 1;

  int ANS1 = 0;
  int ANS2 = 0;
  rep(i, N) {
    int diff1 = A[i] - AVG1;
    ANS1 += diff1 * diff1;
    int diff2 = A[i] - AVG2;
    ANS2 += diff2 * diff2;
  }
  cout << min(ANS1, ANS2) << endl;
  return 0;
}


Measured memory_bytes: 256
let input_price() = Scanf.scanf "%f %s\n" @@ fun x u ->
  if u = "JPY" then x
  else x *. 380000.
;;

let () = Scanf.scanf "%d\n" @@ fun n ->
  let price = Array.init n @@ fun _ -> input_price() in
  Printf.printf "%f\n" @@ Array.fold_right (+.) price 0.
;;

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());
	string s;
	cin >> s;
	int n;
	cin >> n;
	REP(i,n)
	{
		string order,p;
		int a,b;
		cin >> order;
		if(order == "print")
		{
			cin >> a >> b;
			string tmp = s;
			cout << tmp.substr(a,b+1 - a) << endl;

		}
		else if(order == "reverse")
		{
			cin >> a >> b;
			reverse(s.begin() + a, s.begin() + b+1);
		}
		else//replace
		{
			cin >> a >> b >> p;
			s.replace(a,b+1-a,p);
		}
		//cout << i << endl;
		//cout << s << endl;
	}
	
	return 0;
}




Measured memory_bytes: 3212
# 10進数の取扱い

n, a, b = gets.chomp.split(' ').map(&:to_i)

def digit_sum(num)
    result = 0
    while num != 0
        result += num % 10
        num /= 10
    end
    return result
end

result = 0

for num in 1..n
    s = digit_sum(num)
    if a <= s  && s <= b
        result += num
    end
end

p result

Measured memory_bytes: 1916
#include <stdio.h>
#include <queue>
using namespace std;


int main()
{
	int map[102][102];		//数値変換した果樹園のマップ
	char in[101];			//入力文字列
	int y,x;				//果樹園の大きさh,w
	int i,j,r;				//ループ用変数
	int ty[4] = {1,-1,0,0},tx[4] = {0,0,1,-1};	//四方向の移動量
	int temp;				//作業用
	queue< pair<int,int> > que;	//幅優先探索用のキュー
	pair<int,int> P,NP;		//pair型:任意の型２つをまとめて扱うことのできる型

	scanf("%d%d",&y,&x);
	
	while(y != 0 && x != 0){
		//初期化
		for(i = 0; i <= y+1; i++){
			map[0][i] = 0;
			map[x+1][i] = 0;
		}
		for(i = 0; i <= x+1; i++){
			map[i][0] = 0;
			map[i][y+1] = 0;
		}
		
		//入力
		for(j = 1; j <= y; j++){
			scanf("%s",in);
			//マップの数値化
			//しなくてもいいけど私はこうした方が分かり易いのでやる
			for(i = 1; i <= x; i++){
				if(in[i-1] == '#'){
					map[i][j] = -1;
				}
				else if(in[i-1] == '*'){
					map[i][j] = -2;
				}
				else if(in[i-1] == '@'){
					map[i][j] = -3;
				}
			}
		}
		
		//連続した部分の探索
		int c = 0;	//c:連続した区間の数
		for(j = 1; j <= y; j++){
			for(i = 1; i <= x; i++){
				if(map[i][j] < 0){
					//printf("現在地:%d,%d\n",i,j);
					c++;
					//幅優先開始
					//P:現在地 NP:移動後の地点
					//temp:スタート地のマップの種類
					P.first = i;
					P.second = j;
					temp = map[P.first][P.second];
					map[P.first][P.second] = c;
					que.push(P);
					while(!que.empty()){
						P = que.front();
						//4方向を見る
						for(r = 0; r < 4; r++){
							//もし現在地の果物の種類が移動後の位置の果物の種類と同じなら
							if(temp == map[P.first + tx[r]][P.second + ty[r]]){
								NP.first = P.first + tx[r];
								NP.second = P.second + ty[r];
								map[NP.first][NP.second] = c;
								que.push(NP);
							}
						}
						que.pop();
					}
				}
			}
		}
		
		/*デバッグ用出力:mapの出力
		for(i = 0; i <= y+1; i++){
			for(j = 0; j <= x+1; j++){
				printf("%2d",map[j][i]);
			}
			printf("\n");
		}*/

		printf("%d\n",c);


		scanf("%d%d",&y,&x);
	}

	return 0;
}

Measured memory_bytes: 1096
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[][] a = new int[n][m];
    int[] b = new int[m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        a[i][j] = sc.nextInt();
      }
    }
    for (int i = 0; i < m; i++) {
      b[i] = sc.nextInt();
    }
    int[] c = new int[n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        c[i] += a[i][j] * b[j];
      }
    }
    for (int i = 0; i < n; i++) {
      System.out.println(c[i]);
    }
  }
}



Measured memory_bytes: 40384
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    L = int(input())
    edges = []
    vertex = 1
    flag = True
    before = -1
    for i in range(19,-1,-1):
        if (L>>i)&1:
            if flag:
                flag = False
                vertex = i + 1
                for j in range(1,vertex):
                    edges.append((j,j + 1,0))
                    edges.append((j,j + 1,1<<(j - 1)))
                before = 1<<i
            else:
                edges.append((i + 1,vertex,before))
                before += 1<<i
    print(vertex,len(edges))
    for t in edges:
        print(*t)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9264
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    String T = sc.next();
    char[]ss = S.toCharArray();
    char[]tt = T.toCharArray();

    for(int i=0; i<N; i++) {
      System.out.print(ss[i]);
      System.out.print(tt[i]);
    }
}
}

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

int main() {
    int n,m,c;
	cin >> n >> m >> c;
	vector<int> a(m);
	for(int i=0;i<m;i++){
	    cin >> a.at(i);
	}
	int r=0;
	for(int i=0;i<n;i++){
        int s=0;
	    for(int j=0;j<m;j++){
		     
			 int d;
			 cin >> d;
			 s+= a.at(j)*d;
		}
		s+=c;
		if(s>0) r++;
	}
	cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pr printf
#define sc scanf

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef long double ld;
int n;
int a[100010];
int b[100010];

int main () {
    sc("%d", &n);
    ll total = 0LL;
    for(int i = 0; i <= n; i++) {
        sc("%d", a+i);
    }
    for(int i = 0; i < n; i++) {
        sc("%d", b+i);
        total += min(a[i], b[i]);
        b[i] -= min(a[i], b[i]);
        total += min(b[i], a[i+1]);
        a[i+1] -= min(b[i], a[i+1]);
    }
    pr("%lld\n", total);
    return 0;
}


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


int main(){
  
  int n, p[10]={};
  
  cin >> n;
  for(int i=0; i<n; ++i){
    cin >> p[i]; 
  }
  sort(p, p+n, greater<int>());

  p[0] /= 2;

  int ans = 0;
  for(int i=0; i<n; ++i){
    ans += p[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
 
from itertools import permutations as per
tuples = per(range(1, N+1))
 
a = 0
b = 0
for i, t in enumerate(tuples):
    if t == P:
        a = i
    if t == Q:
        b = i
print(abs(a - b))

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

int main(){
string s; cin >>s;
int n = s.size();

string t;
for(int i = 0; i< (n-1)/2; i++)t += s[i];
string u = t;
reverse(t.begin(), t.end());
bool ans = true;
for(int i = 0; i< (n-1)/2; i++){
   if(u[i]==t[i])continue;
   else ans = false;
}

string v;
for(int i = (n+1)/2; i < n; i++)v += s[i];
string w = v;
reverse(v.begin(), v.end());
for(int i = 0; i < (n-1)/2 ; i++){
   if(w[i]==v[i])continue;
   else ans = false;
}

if(v != t) ans = false;

if(ans) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

int main()
{
    int64_t a,b,c;
    std::cin>> a;
    std::cin>> b;
    std::cin>> c;

    std::vector< std::string > cake( a );
    std::vector< std::vector< int64_t > > result;
    std::vector< bool > check_list;

    for( int i = 0; i < a; i++ )
    {
        std::cin>> cake[i];
    }

    int count = 1;
    
    for( int i = 0; i < a; i++ )
    {
        std::vector< int64_t > test( b );
        bool check = false;
        
        for( int r = 0; r < b; r++ )
        {
            if( cake[i][r] == '#' )
            {
                test[r] = count;
                count += 1;
                check = true;
            }
            else
            {
                test[r] = 0;
            }
        }

        
        result.push_back( test );
        check_list.push_back( check );
    }


    for( int i = 0; i < a; i++ )
    {
        for( int r = 0; r < b; r++ )
        {
            if( result[i][r] != 0 )
            {
                for( int s = r + 1; s < b; s++ )
                {
                    if( result[i][s] != 0 )
                    {
                        break;
                    }
                    else
                    {
                        result[i][s] = result[i][r];
                    }
                }

                for( int s = r - 1; s >= 0; s-- )
                {
                    if( result[i][s] != 0 )
                    {
                        break;
                    }
                    else
                    {
                        result[i][s] = result[i][r];
                    }                    
                }
            }
        }
    }

    for( int i = 0; i < a; i++ )
    {
        if(  !check_list[i] )
        {
            bool f = false;
            int cc1 = 10000;
            int cc2 = 10000;

            for( int r = i+1; r < a; r++ )
            {
                if( check_list[r] )
                {
                    cc1 = r;
                    break;
                }
            }

            for( int r = i-1; r >= 0; r-- )
            {
                if( check_list[r] )
                {
                    cc2 = r;
                    break;
                }
            }

            int cc;

            if( abs( cc2 - i ) < abs( cc1 - i ) )
            {
                cc = cc2;
            }
            else
            {
                cc = cc1;
            }

            //std::cout<< i << " " << cc1 << " " << cc2 <<"\n";
            for( int r = 0; r < b; r++ )
            {
                result[i][r] = result[cc][r];
            }
        }
    }

    for( int i = 0; i < a; i++ )
    {
        for( int r = 0; r < b; r++ )
        {
            std::cout<< result[i][r] <<" ";
        }

        std::cout<< "\n";
    }
}


Measured memory_bytes: 1664
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;


typedef unsigned long long ULL;

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ULL n, x;
	cin >> n >> x;

	ULL res = n, y = n - x;
	if (x > y) swap(x, y);
	while (x != 0 && y != 0) {
		ULL newy = y % x;
		res += x * (y / x) * 2ULL;
		y = newy;
		swap(x, y);
	}
	res -= y;
	cout << res << endl;
}


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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine().toUpperCase();
		int count = 0;
		while(true){
			String req = br.readLine();
			String [] s = req.split(" ");
			if(req.endsWith("END_OF_TEXT")){
				break;
			}
			for(int i = 0; i < s.length; i++){
				String res = s[i].toUpperCase();
				if(res.equals(str)){
					count++;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 24264
import math
import sys
h = int(input())
ans = 0
num = 0
if h == 1:
    print(1)
    sys.exit()
for i in range(41,0,-1):
    if 2**i <= h:
        num = 2**i
        rep = i
        # print(i)
        break
for i in range(rep+1):
    ans += 2**i
# print(num)
print(ans)



Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
	double x[4],y[4];
	int n,i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3]);
		
		if(((y[1]-y[0])/(x[1]-x[0])) == ((y[3]-y[2])/(x[3]-x[2])))printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}
	

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n,l;
  string s[105];
  cin>>n>>l;
  rep(i,n)cin>>s[i];
  sort(s,s+n);
  rep(i,n)cout<<s[i];
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int ans = 0;
    rep(i, n) {
        vbool x(26, false), y(26, false);
        rep(j, i) x[s[j]-'a'] = true;
        srep(j, i, n) y[s[j]-'a'] = true;
        int tmp = 0;
        rep(j, 26) if (x[j] & y[j]) tmp++;
        ans = max(ans, tmp);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define foreach(c,itr) for(__typeof(c)::iterator itr=c.begin();itr!=c.end();itr++)
typedef long long ll;
int i,j;

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int n;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
	}
	ll ans=0;
	for(i=1;i<n;i++){
		if(a[i]<a[i-1]){
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5172
n = int(input())
a_list = [int(x) for x in input().split()]
a_dict = {}

for a in a_list:
  if a in a_dict.keys():
    a_dict[a] += 1
  else:
    a_dict[a] = 1


sum_value = sum([int((v*(v-1))/2)for v in a_dict.values()])

for a in a_list:
  print(sum_value-a_dict[a]+1)

Measured memory_bytes: 24748
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            
            if(a<b && b<c){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 26164
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x)
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here

    readb(n, k);
    int d, a; set <int> s;

    fori (i, 1, k)
    {
    	cin >> d;
    	fori (j ,1, d) {cin >> a; s.insert(a);}
    }

    cout << n - sz(s);

    return 0;
}


Measured memory_bytes: 3676
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back   
#define sz(a) ((int)a.size())
using namespace std;
typedef long long ll ; 
const ll inf = 1e18 ;
const int mod = 1e9 + 7;
const int N = 3e5 + 5; 
const int SZ = 101;
ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}


void solve(){
    int n , k ;
    cin >> n >> k;
    ll ans = 0 ;
    if(!k){
        cout << 1LL * n * n ;
        return ;
    }
    for(int i = k + 1 ; i <= n ; ++i){
        int b = i ;
        if(b <= k){
            continue ;
        }
        int rem = (n % b) ;
        int cnt = n / b ;
        ans += (1LL * cnt * (b - k));
        if(rem) ans += (rem - min(k - 1 , rem));
        // cout << ans << ' ';
    }
    // ans = n * n - ans ;
    cout << ans ;
}

int main()
{
    ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
    int TC = 1, t = 0;
    // cin >> TC ;
    while(t++ < TC)
    {
        // cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	string s;
	cin >> s >> s;
	printf("A%cC\n", s[0]);
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using L64 = int64_t;

/* {x,y}という表現で格納される[x^y] */
inline vector<pair<L64, int>> prime_factorize(L64 N) {
  vector<pair<L64, int>> res;
  for (int a = 2; a * a <= N; ++a) {
    if (N % a != 0) {
      continue;
    }
    int ex = 0;
    while (N % a == 0) {
      ex++;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main(void) {
  int N, K, ex, point;
  long double res = 0;
  cin >> N >> K;

  int count = 0;
  int a = 1;
  while (a < K) {
    a *= 2;
    count++;
  }
  ex = count;
  point = 1;
  for (int i = 2; i <= N; i++) {
    a = i;
    count = 0;
    while (a < K) {
      a *= 2;
      count++;
    }
    point += pow(2, (ex - count));
  }

  res = point / (pow(2, ex) * N);
  cout.precision(15);
  cout << res;
  return 0;
}

Measured memory_bytes: 4180
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

int N;
pll list[2100];

const long long INF = 1LL<<60;
long long dp[2100][2100];

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    while (cin >> N) {
        for (int i = 0; i < N; ++i) cin >> list[i].second >> list[i].first;
        sort(list, list+N);
        
        for (int i = 0; i < 2100; ++i) for (int j = 0; j < 2100; ++j) dp[i][j] = INF;
        dp[0][0] = 0;
        
        int res = 0;
        for (int i = 0; i <= N; ++i) {
            for (int j = 0; j <= N; ++j) {
                if (dp[i][j] < INF) chmax(res, j);
                                         
                long long alt = dp[i][j] + list[i].second;
                if (alt <= list[i].first) {
                    chmin(dp[i+1][j+1], alt);
                }
                chmin(dp[i+1][j], dp[i][j]);
            }
        }
        
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 35660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define int long long
signed main() {
    ios::sync_with_stdio;
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    vector<int>a(n),dp(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    cout<<dp[n-1];

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  pb push_back
#define f first
#define s second
#define INF_INT 1e9+5
#define INF_LONG 1e18

///shortcuts
///ctr+alr+T
ll my_max(ll a, ll b)
{
    return a>b? a: b;
}

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

    int n , w; cin>>n>>w;
    vector< pair<ll,ll> > v;
    v.pb({0,0});
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        ll ww;
        ll  vv;
        cin>>ww>>vv;
        v.pb({vv,ww});
        sum+=vv;
    }

    vector<vector<ll> > dp(n+1,vector<ll>(sum+1,INF_LONG));
    //sort(v.begin(),v.end());
   /* for(auto itr : v)
        cout<<itr.f<<" ";
    cout<<endl;
    for(auto itr : v)
        cout<<itr.s<<" ";
    cout<<endl;*/

   dp[0][0] = 0 ; //minimum possible  weight;

    ll mx  = 0;
   // cout<<"haha"<<endl;
    for (ll item = 1; item <= n ; item++) {
        for (ll value = 0; value <= sum; value++)
        {
            if (v[item].f <= value) {
             //find the minimum weight
                dp[item][value] = min (v[item].s + dp[item - 1][value - v[item].f], dp[item - 1][value]);
            }
            else {
                dp[item][value] = dp[item - 1][value];
            }
           //cout<<dp[item][value]<<" ";
            if(dp[item][value]<=w)
            mx = my_max(mx  ,value);
        }
        //cout<<endl<<endl;
    }
   cout<<mx<<endl;






}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
	string s;
	int k;
	cin >> s >> k;
	vector<int> cnt;
	int tmp = 1;
	for (int i = 1; i < s.size(); ++i) {
		if (s[i - 1] == s[i])++tmp;
		else {
			cnt.push_back(tmp);
			tmp = 1;
		}
	}
	cnt.push_back(tmp);
	if (s.front() == s.back()) {
		if (cnt.size() == 1) cout << cnt[0] * k / 2 << endl;
		else {
			int ans = 0;
			for (int i = 0; i < cnt.size(); ++i) {
				if (i == 0)ans += cnt[i] / 2;
				else if (i == cnt.size() - 1) {
					ans += cnt.back() / 2;
					ans += ((cnt.front() + cnt.back()) / 2) * (k - 1);
				}
				else ans += cnt[i] / 2 * k;
			}
			cout << ans << endl;
		}
	}
	else {
		int ans = 0;
		for (auto x : cnt)ans += x / 2 * k;
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define VJ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mp make_pair()
#define vi(x) vector<int>x
#define vl vector<long long int>
#define vc vector<char>
#define max 100001 
using namespace std;


void solve(){
	int n,x,t;cin>>n>>x>>t;
	int ans=ceil(1.0*n/x);
	cout<<ans*t;
}

int main(){
	 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	 #endif
	VJ
	solve();
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    int n;
    cin >> n;
    vector<int> a(n-1);
    rep(i,n-1) cin >> a[i];
    a.push_back(0);
    vector<vector<int>> d(5000,vector<int>(2,inf));
    int ans=inf;
    d[1][0]=0;
    rep(i,n-1){
        vector<vector<int>> dd(5000,vector<int>(2,inf));
        for (int j=n/2-1;j>=0;j--){
            if (j==n/2-1){
                ans=min(ans,d[j][0]+a[i+1]);
                ans=min(ans,d[j][0]+a[i]+a[i+1]);
            }
            else{
                dd[j+1][0]=min(dd[j+1][0],d[j][0]);
                dd[j+1][0]=min(dd[j+1][0],d[j][1]+a[i]);
                dd[j][1]=min(dd[j][1],d[j][1]);
                dd[j][1]=min(dd[j][1],d[j][0]+a[i]);
            }
        }
        d=dd;
    }
    cout << ans << endl;
}


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

int main()
{
    int n;
    cin >> n;
    V b(n - 1);
    rep(i, n - 1) cin >> b[i];
    ll ans = 0;
    rep(i, n)
    {
        if (i == 0)
            ans += b[i];
        else if (i == n - 1)
            ans += b[n - 2];
        else
        {
            ans += min(b[i - 1], b[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <cmath>
int main(){
  int n,m,i,j,l,c=0,b=1,temp;
  std::cin >> n>>m;
  int a[m][10],k[m],p[m],s[n],q[m];
  for (i = 0; i <m; i++){
    std::cin >>k[i];
    for (j=0;j<k[i];j++)std::cin >>a[i][j];
  }
  for (i = 0; i <m; i++)std::cin >> p[i];
  for (l=2048;l<std::pow(2,n)+2048;l++){
    b=1;
    for (i = 0; i <m; i++)q[i]=p[i];
    for (i = 0; i <m; i++){
      for (j=0;j<k[i];j++){
        temp=std::pow(2,a[i][j]);
        if (l%temp>=temp/2)q[i]++;
      }
      if (q[i]%2){
        b=0;
        break;
      }
    }
    c+=b;
  }

  std::cout << c << '\n';

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double N;
double a, x;
int main()
{
#ifdef hk_cnyali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif
	scanf("%lf%lf%lf", &N, &a, &x);
	double Ans = 0;
	double M = 2 * N;
	while (M)
	{
		Ans += (2 * a + (M - 1) * x) / 2;
		a = ((M + 2) * a + 5 * x ) / M;
		x = (M + 4) * x / M;
		M -= 2;
	}
	printf("%.20lf\n", Ans);
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    t = [[int(t)for t in input().split()]for _ in [0]*n]

    

    if n%2==1:
        t_1 = sorted(t,key=lambda a: a[0])
        t_2 = sorted(t,key=lambda b:b[1],reverse=True)
        ans = t_2[n//2][1]-t_1[n//2][0]+1
        print(ans)
    else:
        t_1 = sorted(t,key=lambda a: a[0])
        t_2 = sorted(t,key=lambda b:b[1])

        a0,a1 = t_1[n//2][0],t_2[n//2][1]

        t_1 = sorted(t,key=lambda a: a[0],reverse=True)
        t_2 = sorted(t,key=lambda b:b[1],reverse=True)
        
        b0,b1 = t_1[n//2][0],t_2[n//2][1]
        ans = a1-a0+b1-b0 + 1
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 49996
import sys
input=sys.stdin.buffer.readline
n=int(input())
l=list(map(int,input().split()))
f=1
from fractions import gcd

for i in l:
    f=f*i//gcd(f,i)
mod=10**9+7
ans=0
for i in l:
  ans+=f//i
print(ans%mod)


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

int main(int argc, char *argv[]){
        int a,b;
        char op;
        while(1){
                int ans;
                cin >> a >> op >> b;
                if (op == '?') break;
                if (op == '+') ans = a + b;
                if (op == '-') ans = a - b;
                if (op == '/') ans = a / b;
                if (op == '*') ans = a * b;
                cout << ans << "\n";
        }
        return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
string s,s1,s2;
char q;
int gg;
int n;
int t,f;
string ans;
int main(){
	cin>>s;
	cin>>n;
	gg=1;
	for (int i=0;i<n;i++){
		cin>>t;
		if (t==1) gg=-gg;
		else{
			cin>>f>>q;
			if (f==1){
				if (gg==1){
					s.insert(s.begin(),q);
				}
				else{
					s.insert(s.end(),q);
				}
			}
			else{
				if (gg==1){
					s.insert(s.end(),q);
				}
				else{
					s.insert(s.begin(),q);
				}
			}
		} 
	}
	if (gg==-1){
		reverse(s.begin(), s.end());
	}
	cout<<s<<endl;
	return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  int n;
  cin >> n;
  
  vector<int> d(n);
  REP(i,n)
    cin >> d[i];
  
  sort(d.begin(), d.end());
  cout << d[n/2] - d[n/2-1] << endl;
  
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int s = scan.nextInt();

		int x = 0;
		int y = 0;
		int z = s-(x+y);
		int yz = y+z;
		int count = 0;
		for(x=0;x<=k;x++) {
			for(y=0;y<=k;y++) {
					if(x+y<=s&&x+y+k>=s) {
						count++;
					}
				}
		}
		/*
		for(y=0;y<=k;y++) {
			for(z=0;z<=k;z++) {
					if(y+z==s) {
						count++;
					}
				}
		}*/

		if(s==k*3) {
			count =1;
		}
		System.out.println(count);
	}

}




/*import java.util.Scanner;

public class B051 {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int s = scan.nextInt();

		int x = 0;
		int y = 0;
		int z = 0;

		int countS = 0;
		int countK = 0;
		countS = (s + 2) * (s + 1) / 2; //0以上で合計がｓになる３つの数
		//System.out.println(countS);

		//あとは→ｋ以上を使っているのを排除
		for(x=k;x<=s;x++) {
			for(y=k;y<=s;y++) {
				for(z=k;z<=s;z++) {
					if(x+y==s-z) {
						countK++;
					}
				}
			}
		}

		int show = countS;
		if(s==3*k) {
			show=1;
		}




		System.out.println(show);
	}
}
*/


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
const int INF = 1e6;
const int MAX = 1e5+10;
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define print(a) cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define sortvec(a) sort(a.begin(),a.end())
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1;x = x % mod; while (y > 0){if (y & 1) res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
lli llipowerp(lli x, lli y,lli p){lli res = 1;x = x % p; while (y > 0){if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	} 
	return -1;
}

template <typename T>
void printvec(vector<T> inp){
	for(int i=0;i<inp.size();i++){
		cout<<inp[i]<<" ";
	}
	cout<<endl;
}
template <typename T>
T ceildiv(T x, T y){
	return 1 + ((x - 1) / y);
}
lli modInverse(lli a, lli m){//m is PRIME 
    lli g = gcd(a, m); 
    if (g != 1) return -1;
    else return llipowerp(a, m-2, m);
} 
int n;
const int MAXN=1e5+1;
vector<int> g[MAXN] ;
bool used[MAXN] ;
vector<int> comp ;
vector<int> corr(MAXN,-1);
void dfs(int v) {
    used[v] = true ;
    comp.push_back(v);
    for (size_t i = 0; i < (int) g[v].size(); ++i) {
        int to = g[v][i];
        if (!used[to])
            dfs(to);
    }
}

int find_comps() {
	int curr_comp=0;
    for (int i = 0; i < n ; ++i)
        used [i] = false;
    for (int i = 0; i < n ; ++i)
    {
        if (!used[i]) {
            comp.clear();
            dfs(i);
            
            for (size_t j = 0; j < comp.size(); ++j)
                corr[comp[j]]=curr_comp;
            curr_comp++;
        }  
	}
	return curr_comp;
}	
int main(){
	cin>>n;
	int m,k;
	cin>>m>>k;
	int temp1,temp2;

	fori(m){
		cin>>temp1>>temp2;
		g[temp1-1].pb(temp2-1);
		g[temp2-1].pb(temp1-1);
	}
	int n_comps;
	n_comps=find_comps();
	vector<int> nums(n_comps,0);
	fori(n){
		if(corr[i]!=-1) nums[corr[i]]++;
	}
	vector<int> ans(n,0);
	fori(n){
		ans[i]=nums[corr[i]]-1-g[i].size();
	}
	fori(k){
		cin>>temp1>>temp2;
		if(corr[temp1-1]==corr[temp2-1]){
			ans[temp1-1]--;
			ans[temp2-1]--;
		}
	}

	fori(n) cout<<ans[i]<<" ";
	cout<<endl;
}
 
 

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  ll a[3];
  cin >> a[0] >> a[1] >> a[2];
  if (a[0] == a[1] && a[1] == a[2]){
    cout << 1 << endl;
  }else if (a[0] == a[1] || a[1] == a[2] || a[2] == a[0]){
    cout << 2 << endl;
  }else{
    cout << 3 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

typedef long double ld;

int N;
ll K;
vector<ll> A;

bool check(ll lim){
  ll ans=0;
  for(int i=0;i<N;i++){
    ans+=(A[i]-1)/lim;
  }
  if(ans<=K) return true;
  else return false;
}

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

  cin>>N>>K;
  A.resize(N);
  rep(i,N) cin>>A[i];

  ll ok=2e9,ng=0;
  while(abs(ok-ng)>1){
    ld mid=(ok+ng)/2;
    if(check(mid)) ok=mid;
    else ng=mid;
  }

  ll ans=ok;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4772
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int a, b;
void in(){
    cin>> a >> b;
}

void solve(){

    if(a * b % 2 == 1){
        print("Odd");
    }else{
        print("Even");
    }
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
s = input()

count1 = count2 = 0
for i in range(len(s)):
    after = str(i % 2)
    if s[i] != after:
        count1 += 1

for i in range(len(s)):
    after = str((i+1) % 2)
    if s[i] != after:
        count2 += 1
print(min(count1,count2))

Measured memory_bytes: 3188
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	cout<<(n*(n-1)/2)+(m*(m-1))/2;
	
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int s, w;
	cin >> s >> w;
	if (w >= s)cout << "unsafe" << endl;
	else cout << "safe" << endl;
}


Measured memory_bytes: 3636