akhauriyash/Code-Regression huggingface dataset:
/**
 *   created: 21 July 2019  12:00:05
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		vi v(n);
		rep(i,0,n)
			cin>>v[i];
			sort(all(v));
		cout<<v[n/2]-v[n/2-1];
	}

	return 0;
}


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

int W,H;
char str[32][32];
bool is_exist;

void print_map(){
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			printf("%c",str[i][j]);
		}
		puts("");
	}
}

bool is_movable(int x,int y){
	return str[x][y] == '.' || str[x][y] == 'X';
}

bool change_dir(int x,int y){
	switch(str[x][y]){
		case 'E' :
			if(is_movable(x+1,y)){
				str[x][y] = 'S';
			}
			else if (is_movable(x,y+1)){
				str[x][y] = 'E';
			}
			else if (is_movable(x-1,y)){
				str[x][y] = 'N';
			}
			else if (is_movable(x,y-1)){
				str[x][y] = 'W';
			}
			is_exist = true;
			break;
		case 'N' :
			if(is_movable(x,y+1)){
				str[x][y] = 'E';
			}
			else if(is_movable(x-1,y)){
				str[x][y] = 'N';
			}
			else if (is_movable(x,y-1)){
				str[x][y] = 'W';
			}
			else if (is_movable(x+1,y)){
				str[x][y] = 'S';
			}
			is_exist = true;
			break;
		case 'W' :
			if(is_movable(x-1,y)){
				str[x][y] = 'N';
			}
			else if(is_movable(x,y-1)){
				str[x][y] = 'W';
			}
			else if (is_movable(x+1,y)){
				str[x][y] = 'S';
			}
			else if (is_movable(x,y+1)){
				str[x][y] = 'E';
			}
			is_exist = true;
			break;
		case 'S' :
			if(is_movable(x,y-1)){
				str[x][y] = 'W';
			}
			else if (is_movable(x+1,y)){
				str[x][y] = 'S';
			}
			else if(is_movable(x,y+1)){
				str[x][y] = 'E';
			}
			else if (is_movable(x-1,y)){
				str[x][y] = 'N';
			}
			is_exist = true;
			break;
		default :
			break;
	}
}

void move(int x,int y){
	if(str[x][y] == '.'){
		if(str[x][y+1] == 'W'){
			str[x][y+1] = '*';
			str[x][y] = 'w';
		}
		else if (str[x-1][y] == 'S'){
			str[x-1][y] = '*';
			str[x][y] = 's';
		}
		else if(str[x][y-1] == 'E'){
			str[x][y-1] = '*';
			str[x][y] = 'e';
		}
		else if(str[x+1][y] == 'N'){
			str[x+1][y] = '*';
			str[x][y] = 'n';
		}
	}
	else if(str[x][y] == 'X'){
		if(str[x][y+1] == 'W'){
			str[x][y+1] = '*';
		}
		else if (str[x-1][y] == 'S'){
			str[x-1][y] = '*';
		}
		else if(str[x][y-1] == 'E'){
			str[x][y-1] = '*';
		}
		else if(str[x+1][y] == 'N'){
			str[x+1][y] = '*';
		}
	}
}


void update(){
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			if(str[i][j] == '*'){
				str[i][j] = '.';
			}
			else if(str[i][j] == 'w'){
				str[i][j] = 'W';
			}
			else if(str[i][j] == 'n'){
				str[i][j] = 'N';
			}
			else if (str[i][j] == 'e'){
				str[i][j] = 'E';
			}
			else if(str[i][j] == 's'){
				str[i][j] = 'S';
			}
		}
	}
}

int main(){
	while(scanf("%d%d",&W,&H),W != 0 && H != 0){
		bool flg = true;
		for(int i = 0; i < 32; i++){
			memset(str[i],0,32);
		}
		for(int i = 1; i <= H; i++){
			scanf("%s",str[i]+1);
		}
		for(int t = 0; t <= 180; t++){
			//1
			is_exist = false;
			for(int i = 1; i <= H; i++){
				for(int j = 1; j <= W; j++){
					change_dir(i,j);
				}
			}
			if(!is_exist){
				printf("%d\n",t);
				flg = false;
				break;
			}
			//2
			for(int i = 1; i <= H; i++){
				for(int j = 1; j <= W; j++){
					move(i,j);
				}
			}
			update();
			//print_map();
		}
		if(flg){
			printf("NA\n");
		}
	}
	return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	if(n / 100 == n % 10)cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


constexpr int N = 1000;
constexpr int mod = 1e9 + 7;
std::array<std::array<lli, N + 1>, 2> A;

struct faster{
    lli Power[N+1], invP[N+1];
    constexpr faster(): Power(), invP(){
        Power[0] = 1;
        for(int i = 1; i <= N; ++i) Power[i] = (Power[i-1] * i) % mod;
        invP[N] = inverse(Power[N]);
        for(int i = N; i > 0; --i) invP[i-1] = (invP[i] * i) % mod;
    }
    constexpr void swap(lli &a, lli &b) const {
        a ^= b; b ^= a; a ^= b;
    }
    constexpr lli inverse(lli a) const noexcept{
        lli b = mod, u = 1, v = 0;
        while (b != 0) { 
            lli t = a / b; a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= mod; if (u < 0) u += mod;
        return u;
    }
};

// 累乗の余りを求める関数
inline lli power(lli a, int n, lli mod_number___ = mod){
    lli res = 1, waiting = a;
    while(n){ if(n & 1){ 
        (res *= waiting) %= mod_number___;}
        (waiting *= waiting) %= mod_number___; 
        n >>= 1;
    }
    return res;
}

/* n人でp人グループを k 個作る分け方は
    nCpk * pkCp * (k-1)pCp * ... * pCp / k!
    = {n!/(n-pk)!pk!} * {pk!/(k-1)p!p!} * {(p-1)k!/(k-2)p!p!} * ... * pCp / k!
    = {n!/(n-pk)!pk!} * pk! / (p!)^k / k!
    = n! / { (n - pk)! * (p!)^k * k! }
*/

constexpr faster Init;

int main(void){
    int n, a, b, c, d; scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);

    A[0][0] = 1;
    for(int p = a; p <= b; ++p){
        for(int j = 0; j <= n; ++j) A[1][j] = A[0][j];
        for(int j = 0; j <= n; ++j){
            lli C = power(Init.invP[p], c) * Init.invP[j] % mod;
            int ptr = j + c * p; 
            // j + kp ≤ n <=> kp ≤ (n - j)
            int e = (n - j) / p; if(e > d) e = d;
            for(int k = c; k <= e; ++k, ptr += p){
                lli c = (Init.Power[ptr] * Init.invP[k] % mod) * C % mod;
                (A[1][ptr] += c * A[0][j]) %= mod;
                (C *= Init.invP[p]) %= mod;
            }
        }
        std::swap(A[0], A[1]);
    }
    printf("%lld\n", A[0][n]);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        String[] inputs = input.split(" ");
        int a = Integer.valueOf(inputs[0]);
        int b = Integer.valueOf(inputs[1]);
        int c = Integer.valueOf(inputs[2]);
      	int max = 0;
      	int restNum1 = 0;
      	int restNum2 = 0;
    
      	if(a>=b) {
        	max = a;
          	restNum1 = b;
          	restNum2 = c;
        }
        else {
          max = b;
          restNum1 = a;
          restNum2 = c;
      	}
      
      	if(c>=max) {
        	max= c;
          	restNum1 = a;
          	restNum2 = b;
        }
      
      int diff1 = max -restNum1 ;
      int diff2 = max -restNum2 ;
      int answer= 0;
 		if( (diff1%2==0 && diff2%2==1) || (diff1%2==1 && diff2%2==0) )
        {
           answer = ((diff1+diff2+1)/2) + 1;
        }
        else {
      	   answer = (diff1+diff2)/2;
        }
      	
      	System.out.println(answer);
          
    }
        
}

Measured memory_bytes: 23124
require 'set'
a,b,k = gets.chomp.split(" ").map(&:to_i)

set = Set.new

(0..(k-1)).each do |i|
  set << a + i if a + i <= b
  set << b - i if b - i >= a
end

set.to_a.sort.each do |i|
  puts i
end



Measured memory_bytes: 2044
#include <bits/stdc++.h>
 
using namespace std;
 
#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923


ll dfs(int u, vector<bool> &vis, vvi &g){
    if(vis[u]) return 0;
    vis[u] = 1;

    ll sz = 0;
    for(auto &z: g[u]){
        sz += dfs(z, vis, g);
    }
    sz++;
    
    return sz;
}

int main() {
    ll tt = 1, n, m, l, r, c, i, j, k, w, x, y;
    boost;
    
    // cin >> tt;
    ll ans = 1001;

    for(int _ = 1; _ <= tt; _++) {
        // cout << "Case #" << _ << ": ";
        cin >> n >> m;
        vvi g(n);
        set<pii> st;

        for(i = 0; i < m; i++){
            cin >> x >> y;
            x--, y--;
            if(x > y) swap(x, y);

            if(st.find({x, y}) == st.end()){
                g[x].push_back(y);
                g[y].push_back(x);
                st.insert({x, y});
            }
        }

        vector<bool> vis(n, 0);
        ans = 0;
        for(i = 0; i < n; i++){
            if(vis[i]) continue;
            ans = max(ans, dfs(i, vis, g));
        }

        cout << ans << nl;
    }
}

Measured memory_bytes: 33008
#include <cstdio>
#include <queue>
#include <algorithm>

//FILE *fin = fopen("a.in", "r"), *fout = fopen("a.out", "w");
#define fin stdin
#define fout stdout

#define ll long long

int main() {
    int n;
    ll l, d;
    fscanf(fin, "%d%lld%lld", &n, &l, &d);
    d -= l;

    std::priority_queue < ll > left;
    std::priority_queue < ll, std::vector < ll > , std::greater < ll > > right;
    ll lazyLeft = 0, lazyRight = 0, ans = 0;
    /// valoarea reala a lui left.top() este left.top() + lazyLeft
    /// valoarea reala a lui right.top() este right.top() + lazyRight

    left.push(l);
    right.push(l);
    for (int i = 1; i < n; i++) {
        lazyRight += d;
        fscanf(fin, "%lld%lld", &l, &d);
        d -= l;
        lazyLeft -= d;

        ll realLeft = left.top() + lazyLeft, realRight = right.top() + lazyRight;
        if (l <= realLeft) {
            ans += realLeft - l;
            left.pop();
            right.push(realLeft - lazyRight);
            left.push(l - lazyLeft);
            left.push(l - lazyLeft);
        } else if (l < realRight) {
            left.push(l - lazyLeft);
            right.push(l - lazyRight);
        } else {
            ans += l - realRight;
            right.pop();
            left.push(realRight - lazyLeft);
            right.push(l - lazyRight);
            right.push(l - lazyRight);
        }
    }

    fprintf(fout, "%lld\n", ans);

    fclose(fin);
    fclose(fout);
    return 0;
}


Measured memory_bytes: 2036
t,*s=input().split('T')
x,y=map(int,input().split())
dx,dy={len(t)},{0}
for a in map(len,s[1::2]):dx=set(t+a for t in dx)|set(t-a for t in dx)
for b in map(len,s[::2]):dy=set(t+b for t in dy)|set(t-b for t in dy)
if x in dx and y in dy:print('Yes')
else:print('No')

Measured memory_bytes: 93660
# -*- Coding: utf-8 -*-
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
N = 1
x, y = [0]*N, [0]*N#N個の空のリストを作成
l = list(range(N))#範囲がNのリストを作成する
sum=0
#print(x[0])

for i in range(N):
  x[i], y[i] = map(int, input().split())

if x[0] <= 3:
   sum=sum+100000*(4-x[0])
else:
    pass

if y[0]<= 3:
   sum=sum+100000*(4-y[0])
else:
    pass

if x[0]==1 and y[0]==1:
    sum=sum+400000

else:
    pass

print(sum)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var t = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var T = Console.ReadLine();
            var N = s[0];
            var K = s[1];
            var R = t[0];
            var S = t[1];
            var P = t[2];
            var ans = 0;
            var li = new List<char>();

            for (var i = 0; i < T.Length; i++)
            {
                if (T[i] == 'r')
                {
                    if (K <= i && li[i - K] == 'p')
                    {
                        ans += 0;
                        li.Add('#');
                    }
                    else
                    {
                        ans += P;
                        li.Add('p');
                    }
                }
                else if (T[i] == 's')
                {
                    if (K <= i && li[i - K] == 'r')
                    {
                        ans += 0;
                        li.Add('#');
                    }
                    else
                    {
                        ans += R;
                        li.Add('r');
                    }
                    
                }
                else
                {
                    if (K <= i && li[i - K] == 's')
                    {
                        ans += 0;
                        li.Add('#');
                    }
                    else
                    {
                        ans += S;
                        li.Add('s');
                    }                   
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>

#define INF 1000000
#define WHITE 0
#define GLAY 1
#define BLACK 2

int *d, *f, *color;
int n, t;
int mat[128][128];

void dfs(int);
void dfs_init();

int main(){
        int u, k, num;
        int i, j;

        for(i = 1 ; i <= n ; i++){
                for(j = 1 ; j <= n ; j++){
                        mat[i][j] = 0;
                }
        }

        scanf("%d", &n);

        d = malloc((n + 2) * sizeof(int));
        f = malloc((n + 2) * sizeof(int));
        color = malloc((n + 2) * sizeof(int));

        for(i = 1 ; i <= n ; i++){
                scanf("%d %d", &u, &k);
                for(j = 0 ; j < k ; j++){
                        scanf("%d", &num);
                        mat[u][num] = 1;
                }
        }

        dfs_init();

        for(i = 1; i <= n ; i ++){
                printf("%d %d %d\n", i, d[i], f[i]);
        }

        return 0;
}

void dfs(int u){
        int i;
        color[u] = GLAY;
        d[u] = ++t;
        for(i = 1 ; i <= n ; i++){
                if((mat[u][i] == 1) && (color[i] == WHITE))dfs(i);
        }
        color[u] = BLACK;
        f[u] = ++t;
}

void dfs_init(){
        int i;
        for(i = 1 ; i <= n ; i++){
                color[i] = WHITE;
        }
        for(i = 1 ; i <= n ; i++){
                if(color[i] == WHITE)dfs(i);
        }
}



Measured memory_bytes: 2128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a;
  cin >> a;
  cout << a * a << "\n";
}

Measured memory_bytes: 3648
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int A = nextInt();
		int B = nextInt();

		out.println(Math.max(A + B, Math.max(A - B, A * B)));
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 1000000007

using namespace std;

llint k, n;
llint ans[505][505];

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

  cin >> k;

  if(k <= 500){
    n = k;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        ans[i][j] = (i+j)%n+1;
      }
    }
  }
  else{
    n = 500;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        ans[i][j] = (i+j)%n+1;
      }
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        if(ans[i][j] <= k-500 && i % 2) ans[i][j] += 500;
      }
    }
  }

  cout << n << endl;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>

using namespace std;

vector<pair<long long int, long long int>> getPrimeElements(long long int num) {

	long long int firstnum = num;

	vector<pair<long long int, long long int>> result;
	pair<long long int, long long int> wk;

	if (num % 2 == 0) {
		wk.first = 2;
		wk.second = 0;
		while (num % 2 == 0) {
			wk.second++;
			num /= 2;
		}

		result.push_back(wk);
	}

	long long int waru = 3;

	while (true) {

		if (num % waru == 0) {
			wk.first = waru;
			wk.second = 0;
			while (num % waru == 0) {
				wk.second++;
				num /= waru;
			}

			result.push_back(wk);
		}
		waru += 2;

		if (waru * waru > num) break;

	}

	if (num != 1) {
		wk.first = num;
		wk.second = 1;
		result.push_back(wk);

	}

	return result;
}


int getKeta(int num) {

	if (num == 0)return 1;

	int res = 0;

	while (num > 0) {
		num /= 10;
		res++;
	}

	return res;
}

vector<int> bunkai(int num) {

	string str = to_string(num);
	vector<int> res;

	for (int i = 0; i < str.size(); i++) {
		int a = str[i] - '0';
		res.push_back(a);
	}

	return res;

}


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

	vector<long long int> a(n);
	for (auto& i : a)cin >> i;

	int ans = 0;

	for (int i = 0; i < a.size(); i++) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}

	cout << ans << endl;


	return 0;

}




Measured memory_bytes: 384
# 三角形の面積 S、周の長さ L, a を底辺としたときの高さ h
import math

a, b, angle = map(int, input().split(" "))
angle_rad = math.radians(angle)
h = b * math.sin(angle_rad)
S = a * h / 2

c = (a**2 + b**2 - 2 * a * b * math.cos(angle_rad)) ** (1 / 2)

L = a + b + c

print(f"{S:.5f} {L:.5f} {h:.5f}")




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

const int MAX=105;
const long long int INF=(1LL<<32);

long long int D[MAX][MAX];
int N;

void floyd(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            if(D[i][k]==INF) continue;
            for(int j=0;j<N;j++){
                if(D[k][j]==INF) continue;
                D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
            }
        }
    }
}

int main(){

    int E;cin>>N>>E;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) D[i][j]=0;
            else D[i][j]=INF;
        }
    }
    for(int i=0;i<E;i++){
        int s,t,d;
        cin>>s>>t>>d;
        D[s][t]=d;
    }
    
    floyd();
    
    bool ans=true;
    
    for(int i=0;i<N;i++){
        if(D[i][i]<0){
            cout<<"NEGATIVE CYCLE"<<endl;
            ans=false;
            break;
        }
    }
    
    if(ans){
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(j) cout<<" ";
            if(D[i][j]==INF) cout<<"INF";
            else cout<<D[i][j];
        }
        cout<<endl;
    }
    }
    
}




Measured memory_bytes: 3168
#include<iostream>
using namespace std;
int a, b, c, d, e, k;
int main(){
  cin >> a >> b >> c >> d >> e >> k;
  int l = e-a;
  if (l<=k){
    cout << "Yay!" << endl;
  }
  else cout << ":(" <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second

int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int __ch;
int x;
int num(){
  x=0;
  while(!isdigit(__ch=getchar()));
  x=__ch-'0';
  while(isdigit(__ch=getchar()))x=(x<<3)+(x<<1)+__ch-'0';
  return x;
}

PI V[30][30];
int Vs[30];
bool vis[1<<8][30];
int ti[30];

int main(){
  while(true){
    int n=num(),m=num(),p=num(),a=num()-1,b=num()-1;
    if(!n)break;
    rep(i,n)ti[i]=num();

    rep(i,m)Vs[i]=0;

    rep(i,p){
      int x=num()-1,y=num()-1,z=num();
      V[x][Vs[x]++]=mp(y,z);
      V[y][Vs[y]++]=mp(x,z);
    }

    priority_queue<pair<double,PI> > Q;
    Q.push(mp(0,mp(a,0)));
    memset(vis,0,sizeof(vis));
    double ans=-1;

    while(!Q.empty()){
      int v=Q.top().S.F,cst=Q.top().S.S;
      double cc=-Q.top().F;
      Q.pop();
      if(vis[cst][v])continue;
      vis[cst][v]=true;
      if(v==b){
        ans=cc;
        break;
      }

      rep(i,n){
        if(cst>>i&1)continue;
        rep(j,Vs[v]){
          int nv=V[v][j].first;
          int tc=V[v][j].second;
          int nst=cst|(1<<i);
          if(vis[nst][nv])continue;
          double nc=cc+1.0*tc/ti[i];
          Q.push(mp(-nc,mp(nv,nst)));
        }
      }
    }
    if(ans<0)puts("Impossible");
    else printf("%f\n",ans);
  }
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int N,K;
  cin >> N >> K;
  VLL a(N);
  rep(i,N) cin >> a[i];

  VLL plusSum(N);
  VLL arraySum(N);
  rep(i,N){
    plusSum[i]  = (a[i]>0?a[i]:0);
    arraySum[i] =  a[i];
  }

  rep(i,N-1){
    plusSum[i+1]  += plusSum[i];
    arraySum[i+1] += arraySum[i];
  }
  ll ans = -1;
  // 0     [i i+1 ....i+K-1] i+K ...... N-1
  rep(i,N-K+1){
    ll sum = 0;


    if(i != 0){
      sum += plusSum[i-1];
      sum += max(0LL, arraySum[i+K-1] - arraySum[i-1]) ;
    } else{
      sum += max(0LL, arraySum[i+K-1]) ;
    }
    sum += plusSum[N-1] - plusSum[(i+K-1)];
    ans = max(ans,sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
from sys import stdin


def dfs(a):
    def func(a):
        if len(a) == N + 1:
            now = 0
            for i in range(Q):
                if a[B[i]] - a[A[i]] == C[i]:
                    now += D[i]
            addn(now)
            return

        a = a + [a[-1]]
        while a[-1] <= M:
            func(a)
            a[-1] += 1

    ret = set()
    addn = ret.add
    func(a)
    return max(ret)


def main():
    ans = dfs([1])
    print(ans)


input = lambda: stdin.readline()[:-1]
N, M, Q = map(int, input().split())
A, B, C, D = zip(*[map(int, input().split()) for _ in [0] * Q])
main()


Measured memory_bytes: 9240
#include<cstdio>
#include<algorithm>
#include<numeric>
using namespace std;

int m,n,a[110],lim;

int check(int b){
  int cnt = 1, rem = b;
  for(int i=0;i<n;i++){
    if(rem<a[i]){
      cnt++; rem = b - a[i];
    }else rem -= a[i];
  }
  return cnt;
}

int main(){
  while(scanf("%d%d",&m,&n),m){
    for(int i=0;i<n;i++)scanf("%d",a+i);
    
    int l = *max_element(a,a+n)-1, r = accumulate(a,a+n,0);
    while(r-l>1){
      int mid = (l+r)/2;
      if(check(mid)<=m)r = mid;
      else l = mid;
    }
    printf("%d\n",r);
  }
}

Measured memory_bytes: 1028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		new Solution().solve(in, out);
		out.close();
	}

	private static class Solution {
		private void solve(InputReader in, PrintWriter out) {
			int k = in.nextInt();
			long ans = 0;
			for (int a = 1; a <= k; ++a)
				for (int b = 1; b <= k; ++b)
					for (int c = 1; c <= k; ++c)
						ans += gcd(gcd(a, b), c);
			out.println(ans);
		}
		
		private long gcd(long a, long b) {
			while (b != 0) {
				long m = a % b;
				a = b;
				b = m;
			}
			return a;
		}
	}
	

	private static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32678);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		private int nextInt() {
			return Integer.parseInt(next());
		}
	}

}


Measured memory_bytes: 25960
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

int cnv(char c) {
	if (c == '?') return inf;
	else return c - '0';
}

void solve() {
	string s[3]; cin >> s[0]; if (s[0] == "0") exit(0);
	cin >> s[1] >> s[2];
	for (int i = 0; i < 3; i++) reverse(s[i].begin(), s[i].end());
	int n = s[0].size();
	vector<vector<mint>> dp(n + 1, vector<mint>(2));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			if (i + 1 == n and j == 0) continue;
			if (cnv(s[0][i]) != inf and cnv(s[0][i]) != j) continue;
			for (int k = 0; k < 10; k++) {
				if (i + 1 == n and k == 0) continue;
				if (cnv(s[1][i]) != inf and cnv(s[1][i]) != k) continue;
				for (int l = 0; l < 2; l++) {
					int sm = j + k + l;
					int r = sm % 10;
					int f = sm / 10;
					if (i + 1 == n and r == 0) continue;
					if (cnv(s[2][i]) == inf or cnv(s[2][i]) == r) {
						dp[i + 1][f] += dp[i][l];
					}
				}
			}
		}
	}
	cout << dp[n][0].x << "\n";
}

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int kkt = 89;
	while (kkt) {
		solve();
	}
}




Measured memory_bytes: 3132
#include<iostream>
#include<cstring>
using namespace std;
long N,ans=0LL;
string S;
int main(){
    cin>>N>>S;
    int RGB[3][N];
    memset(RGB,0,sizeof RGB);
    for(int i=0;i<N;i++){
        switch (S[i]){
            case 'R':RGB[0][i]++;break;
            case 'G':RGB[1][i]++;break;
            case 'B':RGB[2][i]++;break;
        }
    }
    for(int i=1;i<N;i++){
        RGB[0][i]+=RGB[0][i-1];
        RGB[1][i]+=RGB[1][i-1];
        RGB[2][i]+=RGB[2][i-1];
    }
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            if(S[i]==S[j])continue;
            int rgb=-1;
            char c;
            if(S[i]=='G'&&S[j]=='B'||S[i]=='B'&&S[j]=='G')rgb=0,c='R';
            if(S[i]=='R'&&S[j]=='B'||S[i]=='B'&&S[j]=='R')rgb=1,c='G';
            if(S[i]=='R'&&S[j]=='G'||S[i]=='G'&&S[j]=='R')rgb=2,c='B';
            ans+=RGB[rgb][N-1]-RGB[rgb][j];
            if(j*2-i<N&&S[j*2-i]==c)ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
#include<string>
using namespace std; 
int main(){
	string s;
	char p[101];
	char x[101];
	int c=0;
	cin>>p;
	while(1){
		cin>>s;
		if(s=="END_OF_TEXT")break;
		for(int i=0;i<s.length();i++){
			if(s[i]<97)s[i]=(char)(s[i]+32);
		}
		if(s==p)c++;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
typedef long long ll;
#define endl "\n"

using namespace std;

//ll const N = 100000;

int main()
{
    int N, one, two, three;

    cin >> N;

    one = N % 10;
    N /= 10;

    two = N % 10;
    N /= 10;

    three = N % 10;
    N /= 10;

    if(one == 7 || two == 7 || three == 7)
    {
        cout << "Yes";
    }

    else cout << "No";

    return 0;
}


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

#define pb push_back
#define ll long long
#define inf 1e9

using namespace std;


int main(int argc, char const *argv[])
{
	int n;
	scanf("%d ", &n);
	std::vector<double> dp(n+1, 0.0);
	double currentProb;
	dp[0]=1;
	for (int coin = 0; coin < n; ++coin)
	{
		scanf("%lf" , &currentProb);
		// cout<<"in i as "<< coin<<endl<<endl; 

		for(int i = coin +1; i >= 0 ; i--){
			if (i == 0)
			{
				dp[i] = dp[i]*(1-currentProb);
			}
			else{
				dp[i] = dp[i-1]*currentProb + dp[i] * (1-currentProb);
			}

			// for(auto i  : dp){
			// 	cout<<i<<" ";
			// }
			// cout<<endl;
		}

	}
	double add = 0.0;
	for (int heads = 0; heads <= n; ++heads)
	{
		int tails = n-heads;
		if(heads > tails){
			add += dp[heads];
		}
	}
	printf("%.10lf\n", add);

}




Measured memory_bytes: 384
#include <iostream>
#include <list>

using namespace std;

#define W (0)
#define B (1)

int main(void)
{
	while (1){
		list<pair<int, int> > st;
		pair<int, int> add;
		int n;
		
		cin >> n;
		if (n == 0)break;
		cin >> add.first;
		add.second = 1;
		st.push_back(add);
		for (int i = 2; i <= n; i++){
			int s;
			cin >> s;
			if (i % 2 == 1){
				if (st.back().first == s){
					st.back().second++;
				}
				else {
					add.first = s;
					add.second = 1;
					st.push_back(add);
				}
			}
			else {
				if (st.back().first == s){
					st.back().second++;
				}
				else {
					if (st.size() == 1){
						st.back().first = s;
						st.back().second++;
					}
					else {
						int c = st.back().second;
						st.pop_back();
						st.back().second += c + 1;
					}
				}
			}
		}
		
		list<pair<int, int> >::iterator it;
		int count = 0;
		for (it = st.begin(); it != st.end(); it++){
			if (it->first == W){
				count += it->second;
			}
		}
		
		cout << count << endl;
	}
	return (0);
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int maxlength = 0;
        int count = 0;
        for(int i = 0; i < a.length(); i++) {
            if (containACGT(a.charAt(i))) {
                count++;
                if (maxlength < count) {
                    maxlength = count;
                }
                continue;
            }
            count = 0;
        }
        System.out.println(maxlength);
    }

    private static Boolean containACGT(char c) {
        if (Arrays.stream("ACGT".split("")).anyMatch(s -> s.contains(Character.toString(c)))) {
            return true;
        }
        return false;
    }
}


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

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

int dx[] = { 0,0,1,-1,-1,-1,1,1 };
int dy[] = { 1,-1,0,0,-1,1,1,-1 };

template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }



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

	long long n, m;
    cin >> n >> m;

	vector<pair<long long, long long>> items(n);

	for (int i = 0; i < n; i++)
	{
		cin >> items[i].first >> items[i].second;
	}

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

	long long res = 0;

	int cnt = 0;

	for (int i = 0; i < items.size(); i++)
	{
		int rem =m-cnt;

		if (rem<=items[i].second)
		{
			res += rem*items[i].first;

			break;
		}
		else
		{
			cnt += items[i].second;

			res += items[i].second*items[i].first;
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int k,x;
    cin >> k >> x;
    rep(i,k*2-1){
        cout << x - k + 1 + i << " ";
    }
    cout << endl;
    return 0;
}

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

int a[100009];
int acc = 0;
int N;
int bo(int i) {
	acc++;
	if (acc==2*N) {
		return -1;
	}
	if (a[i] == 2) {
		return acc;
	}

	return bo(a[i]);
}

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

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	cout << bo(1);
}


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

namespace contest_Csharp
{
    class Program
    {
        static long power(long a, long b, long modulo)
        {
            long result = 1;
            long buff = a;
            for (long i = 1; i <= b; i *= 2)
            {
                result = result * ((b / i % (2) == 1) ? buff : 1) % modulo;
                buff = (buff * buff) % modulo;
            }
            return result % modulo;
        }
        
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
            var K = vals[0];
            var S = Console.ReadLine();

            string ans =(S.Length>K)?S.Substring(0,K)+"...":S;

            
            
            Console.WriteLine(ans);
        }



    }
    class PriorityQueue<T> where T : IComparable<T>
    {
        private List<T> heap = new List<T>();
        private int lastindex = -1;
        private void swap(int n, int m)
        {
            T wait = heap[n];
            heap[n] = heap[m];
            heap[m] = wait;
        }
        public int Count()
        {
            return lastindex + 1;
        }
        public void Enqueue(T data)
        {
            int p;
            if (lastindex + 1 < heap.Count())
            {
                heap[lastindex + 1] = data;
            }
            else
            {
                heap.Add(data);
            }
            lastindex++;
            p = lastindex;

            while (true)
            {
                if (p > 0 && heap[p].CompareTo(heap[(p - 1) / 2]) <= -1)
                {
                    swap(p, (p - 1) / 2);
                    p = (p - 1) / 2;
                }
                else
                {
                    break;
                }
            }
        }
        public T Peek()
        {
            return heap[0];
        }
        public T Dequeue()
        {
            T result = Peek();
            heap[0] = default(T);
            swap(0, lastindex);
            lastindex--;
            int p = 0;
            while (true)
            {
                int np;
                if (2 * p + 1 > lastindex)
                {
                    break;
                }
                else
                {
                    np = ((2 * p + 1 == lastindex) || heap[2 * p + 1].CompareTo(heap[2 * p + 2]) <= -1)
                        ? (2 * p + 1) : (2 * p + 2);
                }
                if (heap[p].CompareTo(heap[np]) >= 1)
                {
                    swap(p, np);
                    p = np;
                }
                else
                {
                    break;
                }
            }

            return result;
        }





    }
}


Measured memory_bytes: 28168
#include<cstdio>

int a = 0,b = 0;
int flag = 0;
int suji[11] = {0};

void saiki(int cnt);

using namespace std;
int main(void)
{
	int kaisu;
	scanf("%d",&kaisu);
	for(int i = 0;i<kaisu;i++)
	{
		for(int j = 0;j<10;j++) scanf("%d",&suji[j]);
		saiki(0);
		if(flag == 1)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
		flag = 0;
		a = 0;
		b = 0;
	}
	return 0;
}

void saiki(int cnt)
{
	if(cnt == 10)
	{
		flag = 1;
		return;

	}

	if(a < suji[cnt])
	{
		a = suji[cnt];
		saiki(cnt+1);
	}
	if(b < suji[cnt])
	{
		b = suji[cnt];
		saiki(cnt+1);
	}


}

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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct bipartite_matching {
private:
    int V;
    vector<vector<int>> G;
    vector<int> match;
    vector<bool> used;
public:
    bipartite_matching(int n) {
        V = n;
        G.resize(n);
        match.resize(n);
        used.resize(n);
    }

    void add_edge(int u,int v) {
        G[u].push_back(v);
        G[v].push_back(u);
    }

    bool dfs(int v) {
        used[v] = true;
        for (int& u : G[v]) {
            int w = match[u];
            if (w < 0 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

    int count() {
        int res = 0;
        match = vector<int>(V,-1);
        for (int v = 0;v < V;++v) if (match[v] < 0) {
            used = vector<bool>(V,false);
            if (dfs(v)) res++;
        }
        return res;
    }
};
int main() {
    int n;
    cin >> n;
    int a[n],b[n];
    bipartite_matching m(2*n);
    for (int i = 0;i < n;++i) cin >> a[i] >> b[i];
    for (int i = 0;i < n;++i) {
        int c,d;
        cin >> c >> d;
        for (int j = 0;j < n;++j) if (c > a[j] && d > b[j]) m.add_edge(j,i+n);
    }
    cout << m.count() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	int n = int(s.size());
	string t = s;
	reverse(t.begin(), t.end());
	if(s != t){
		cout << "No";
		return 0;
	}
	string a = s.substr(0, n / 2);
	string b = a;
	reverse(a.begin(), a.end());
	if(a != b){
		cout << "No";
		return 0;
	}
	a = s.substr((n + 1) / 2);
	b = a;
	reverse(b.begin(), b.end());
	if(a != b){
		cout << "No";
	}
	else cout << "Yes";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    cin >> N;
    ll ans = IN();
    REP(i, N - 1) {
        LCIN(a);
        ll g = gcd(ans, a);
        ans = a*(ans/ g);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
S = input()
ans1 = 0
ans2 = 0
flag = True
for s in S:
    if flag:
        flag = False
        if s == '0':
            ans1 += 1
        else:
            ans2 += 1
    else:
        flag = True
        if s == '0':
            ans2 += 1
        else:
            ans1 += 1
print(min(ans1, ans2))


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;

int main() {
	ll n, ans = 0;
	map<ll, ll> cnt;
	cin >> n;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		cnt[a]++;
	}
	for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
		ll s = itr->first, t = itr->second;
		if (s > t)
			ans += t;
		else 
			ans += t - s;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6272
from collections import Counter
n,m = map(int, input().split())
ka = []
for i in range(n):
    ka1 = list(map(int, input().split()))
    ka += ka1[1:]
ka = Counter(ka).most_common()
num = 0
for h in range(len(ka)):
    if ka[h][1] == n:
        num += 1
    else:
        break
print(num)

Measured memory_bytes: 9316