akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long MOD = 998244353;

int count(vector<vector<int> > &mat, int i1, int j1, int i2, int j2) {
    return mat[i2][j2] - mat[i2][j1 - 1] - mat[i1 - 1][j2] + mat[i1 - 1][j1 - 1];
}

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

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];

    vector<vector<int> > mat(h + 1, vector<int>(w + 1, 0));

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            mat[i][j] = mat[i - 1][j] + mat[i][j - 1] - mat[i - 1][j - 1];
            if (s[i - 1][j - 1] == '1') mat[i][j]++;
        }
    }

    int pos = (1 << (h - 1));

    int ans = INT_MAX;

    for (int x = 0; x < pos; x++) {
        int temp_ans = 0;
        vector<pair<int, int> > bor;
        int l = 1, r = 1;
        while (l <= h) {
            if (((1 << (r - 1)) & x) || r == h) {
                bor.push_back({l, r});
                l = r = r + 1;
            } else {
                r++;
            }
        }
        // cout << "hor_cuts: " << (int)bor.size() - 1 << endl;
        temp_ans = (int)bor.size() - 1;
        bool poss = true;
        vector<int> ctr((int)bor.size(), 1);
        int last = 0;
        while (last < w && poss) {
            int mn = 10000;
            for (int i = 0; i < (int)bor.size(); i++) {
                while (ctr[i] <= w && count(mat, bor[i].first, last + 1, bor[i].second, ctr[i]) <= k) ctr[i]++;
                ctr[i]--;
                mn = min(mn, ctr[i]);
                if (ctr[i] == last) {
                    poss = false;
                    break;
                }
            }
            if (mn == last) {
                poss = false;
                break;
            }
            last = mn;
            temp_ans++;
        }
        temp_ans--;
        if (poss) {
            // cout << "ver_cuts" << temp_ans - (int)bor.size() + 1 << endl;
            if (temp_ans <= ans) {
                ans = min(ans, temp_ans);
                // cout << "hor cuts: " << (int)bor.size() - 1 << endl;
            }
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 384
S=list(str(input()))
A=''
B=''
while len(S)>0:
    A+=S.pop()
    if len(S)>0:
        B+=S.pop()
if (len(A)+len(B))%2!=0:
    print('No')
elif len(set(A))==len(set(B))==1:
    if 'h' in A or 'i' in A:
        if 'h' in B or 'i' in B:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 3064
package main

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

var writer = bufio.NewWriter(os.Stdout)

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	if (N + 1) >= K*2 {
		fmt.Fprintf(writer, "YES\n")
	} else {
		fmt.Fprintf(writer, "NO\n")
	}
	writer.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;x=x*x%mod;y>>=1;}return res;}
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
inline ll lcm(ll a,ll b){return a * b / __gcd(a, b);}
int t,n,m,k;
char a[maxn];
int main()
{
    scanf("%d%s",&n,a+1);
    int s=strlen(a+1);
    a[n+1]=0;
    if(n<s){
        printf("%s",a+1);
        puts("...");
    }
    else printf("%s\n",a+1);
    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>

using namespace std;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main() {
   int N;
   cin >> N;
   string str(to_string(N));

   int sum = 0;
   for (int i = 0; i < str.size(); i++) {
      sum += ctoi(str[i]);
   }
   
   if (N%sum == 0) cout << "Yes" << endl;
   else cout << "No" << endl;
   
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  string s;
  cin>>s;
  int n = s.size();
  int a=n;
  rep(i,n-1) {
    if(s[i]!=s[i+1])
      a=min(a,max(i+1,n-i-1));
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 512
H,W = map(int,input().split())
s = [list(input()) for i in range(H)]
for i in range(H):
	for j in range(W):
		if s[i][j] == "#":
			if s[max(0,i-1)][j] == "." and s[min(H-1,i+1)][j] == "." and s[i][max(0,j-1)] == "." and s[i][min(W-1,j+1)] == ".":
			    print("No")
			    exit()
print("Yes") 


Measured memory_bytes: 3064
n = int(input())
v = list(map(int, input().split()))

odd = {}
even = {}
for d, i in enumerate(v):
    if d % 2 == 1:
        if i in even:
            even[i] += 1
        else:
            even[i] = 1
    else:
        if i in odd:
            odd[i] += 1
        else:
            odd[i] = 1
even_sorted = sorted(even.items(), key=lambda x:x[1])
odd_sorted = sorted(odd.items(), key=lambda x:x[1])
if even_sorted[-1][0] == odd_sorted[-1][0]:
    try:
        second_o = odd_sorted[-2][1]
    except:
        second_o = 0
    try:
        second_e = even_sorted[-2][1]
    except:
        second_e = 0
    print(min(n- even_sorted[-1][1] -second_o, n- second_e -odd_sorted[-1][1] ))
else:
    print(n - max(even.values()) - max(odd.values()))

Measured memory_bytes: 26116
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n*2){
    ll a;
    cin>>a;
    v.pb(a);
  }
  sort(all(v));
  reverse(all(v));
  ll ans = 0;
  rep(i,0,v.sz-v.sz%2){
    if(i%2==1){
      ans += v[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

int dp[100100];

int rec(int v,vvi &G){
    if(dp[v]!=-1)return dp[v];
    int res=0;
    for(int i=0;i<G[v].size();i++){
        chmax(res,rec(G[v][i],G)+1);
    }
    return dp[v]=res;
}

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

    int n,m;
    cin>>n>>m;
    vvi G(n,vi());
    int from,to;
    rep(i,m){
        cin>>from>>to;
        G[from-1].push_back(to-1);
    }
    for(int i=0;i<n;i++)dp[i]=-1;
    int res=0;
    for(int i=0;i<n;i++){
        chmax(res,rec(i,G));
    }
    fin(res);
    
    

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 8192
while 1:
    a = input()
    if a == ".":
        break
    b = input()
    if a == b:
        print("IDENTICAL")
    else:
        a = a.split("\"")
        b = b.split("\"")
        if len(a) != len(b):
            print("DIFFERENT")
        else:
            key = [0,0]
            for i in range(len(a)):
                if a[i] != b[i]:
                    key[i%2] += 1
            print("CLOSE" if key == [0,1] else "DIFFERENT")



Measured memory_bytes: 5580
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int T;
int t[110];
int v[110];
int w[50000];

int main () {
  cin >> N;
  T = 0;
  for (auto i = 0; i < N; ++i) {
    cin >> t[i];
    t[i] *= 2;
    T += t[i];
  }
  for (auto i = 0; i < N; ++i) {
    cin >> v[i];
    v[i] *= 2;
  }
  for (auto i = 0; i <= T; ++i) {
    w[i] = min(i, T - i);
  }
  int sum = 0;
  for (auto i = 0; i < N; ++i) {
    int all = sum + t[i];
    for (auto j = 0; sum-j >= 0; ++j) {
      w[sum-j] = min(w[sum-j], v[i]+j);      
    }
    for (auto j = sum; j <= all; ++j) {
      w[j] = min(w[j], v[i]);
    }
    for (auto j = 0; all+j <= T; ++j) {
      w[all+j] = min(w[all+j], v[i]+j);      
    }
    sum += t[i];
  }
  double ans = 0;
  for (auto i = 0; i < T; ++i) {
    ans += ((double)w[i] + (double)w[i+1])/2;
  }
  cout << fixed << setprecision(10) << ans/4 << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N; cin>>N;
  
  vector<int> A(N),B(N);
  for(int i=0; i<N; i++){
    cin>>A[i];
    B[i]=A[i];
  }
  
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  
  for(int i=0; i<N; i++){
    if(A.at(i)==B.at(0)){
      cout<<B.at(1)<<endl;
    }
    else{
      cout<<B.at(0)<<endl;
    }
  }
}

Measured memory_bytes: 3200
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#include<climits>
#include<cstring>
#include<string>
#include<cmath>
#include<bitset>

using namespace std;

#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define f first
#define s second
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mx 1000001

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );
    #endif
    int n,cnt=0;
    cin>>n;
    int ar[n+5];
    for(int i=1;i<=n;i++)
        {
            cin>>ar[i];
        }
    for(int i=1;i<=n;i+=2)
        {
            if(ar[i]&1)
                cnt++;
        }
    cout<<cnt<<"\n";


    return 0;
}


Measured memory_bytes: 3648
houses = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    houses[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in houses[b]:
        print("", *f)
    if b != 3:
        print("#" * 20)


Measured memory_bytes: 5624
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
signed main(){
	cin >> N;
	for(int i=1; i<=N; i++){
		int c = i*108/100;
		if(c == N){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

Measured memory_bytes: 256
h,w=[int(i) for i in input().split()]
s=[[i for i in input()] for _ in range(h)]
flg=True
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            flg=False
            for y,x in [(1,0),(-1,0),(0,1),(0,-1)]:
                try:
                    if s[i+y][j+x]=="#":
                        flg=True
                except:
                    pass
        if not flg:
            break
    if not flg:
        break
print("Yes" if flg else "No")

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

int main(int argc, char **argv)
{
	int *a1, *a2, *r, n, w, i, j, a, b;
	
	while(scanf("%d", &w) != EOF){
		scanf("%d", &n);
		a1 = (int *)calloc(n, sizeof(int));
		a2 = (int *)calloc(n, sizeof(int));
		r = (int *)calloc(w ,sizeof(int));
		for(i = 0; i < n; i++){
			scanf("%d,%d", &a, &b);
			a1[i] = a;
			a2[i] = b;
		}
		
		for(i = 1; i <= w; i++){
			a = i;
			for(j = 0; j < n; j++){
				if(a1[j] == a){
					a = a2[j];
				} else if(a2[j] == a){
					a = a1[j];
				}
			}
			r[a-1] = i;
		}
		
		for(i = 0; i < w; i++){
			printf("%d\n", r[i]);
		}
		
		free(a1);
		free(a2);
		free(r);
	}
	
	return 0;
}

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

int main()
{
    int  a,b,x,y,z;
    cin>>a>>b;
    x=a+b;
    y=a-b;
    z=a*b;

    a=max(x,y);
    b=max(a,z);
    cout<<b<<endl;


    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]
 
// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }
 
// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};
 
// Functions
 
// Main
fn main(){
    input!{
        N: usize,
        _L: usize,
        mut S: [String; N],
    }
    S.sort();
    for s in S{
        print!("{}", s);
    }
}


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

int main() {
  int N, k;
  cin >> N;
  vector<int> vec(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    vec.at(i)--;
  }
  
  k = vec.at(0);
  for (int i = 0; i < N; i++) {
    if (k == 1) {
      cout << i + 1 << endl;
      break;
    } else if (i == N - 1) {
      cout << -1 << endl;
    } else {
      k = vec.at(k);
    }
  }
}


Measured memory_bytes: 3776
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

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

  ll ans1 = 0;
  ll ans2 = 0;
  REP(i, S.size()) {
    if (i % 2 == 0 && S[i] != '0') {
      ans1 += 1;
    }
    if (i % 2 == 1 && S[i] != '1') {
      ans1 += 1;
    }
    if (i % 2 == 0 && S[i] != '1') {
      ans2 += 1;
    }
    if (i % 2 == 1 && S[i] != '0') {
      ans2 += 1;
    }
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}


Measured memory_bytes: 3752
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;


int main(){
	
	while(true){
		int n;
		cin >> n;
		if(n == 0){
			break;
		}
		
		vector<int> v;
		
		string str1, str2;
		cin >> str1 >> str2;
		
		int num = (str1[0] - str2[0] + 10) % 10;
		if(num != 0){
			v.push_back(num);
		}
		
		for(int i = 1; i < n; i++){
			int d1 = str1[i] - str1[i - 1];
			int d2 = str2[i] - str2[i - 1];
			num = (d1 - d2 + 100) % 10;
			if(num != 0){
				v.push_back(num);
			}
		}
		
		num = (str2[n - 1] - str1[n - 1] + 10) % 10;
		if(num != 0){
			v.push_back(num);
		}
		
		sort(v.begin(), v.end());
		
		int ans = 10000;
		
		do{
			int cnt = 0;
			int pre = 0;
			int S = 0;
			for(int i = 0; i < v.size(); i++){
				S += v[i];
				if(S % 10 == 0){
					cnt += i - pre;
					pre = i + 1;
				}
			}
			ans = min(ans, cnt);
		}while(next_permutation(v.begin(), v.end()));
		
		cout << ans << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<algorithm>

void dmove(char c, int count)
{
	for (int i{};i < count;++i)
	{
		std::cout << c;
	}
}

int main()
{
	int sx, sy, tx, ty;
	std::cin >> sx >> sy >> tx >> ty;
	int X = tx - sx;
	int Y = ty - sy;
	dmove('U', Y);
	dmove('R', X + 1);
	dmove('D', Y + 1);
	dmove('L', X + 1);
	dmove('U', 1);
	dmove('L', 1);
	dmove('U', Y + 1);
	dmove('R', X + 1);
	dmove('D', Y + 1);
	dmove('L', X);
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int sum = 0;
        int[] a = new int [7];
        int[] b = new int [7];
        char name[] =in.next().toCharArray();
        a[0] = 1; a[3] = 0; a[4] = 0; a[6] = 0;
        a[1] = 0; a[2] = 0; a[5] = 0;
        for(int i = 0;i < N;i++){
        	sum = 0;
        	if(name[i] == 'J'){
        		b[0] = a[0] + a[3] + a[4] + a[6];
        		b[3] = a[0] + a[1] + a[3] + a[4] + a[5] + a[6]; 
        		b[4] = a[0] + a[2] + a[3] + a[4] + a[5] + a[6];
        		b[6] = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6];
        		b[1] = 0;b[2] = 0;b[5] = 0;
        	}
        	if(name[i] == 'O'){
        		b[1] = a[1] + a[3] + a[5] + a[6];
        		b[3] = a[0] + a[1] + a[3] + a[4] + a[5] + a[6]; 
        		b[5] = a[1] + a[2] + a[3] + a[4] + a[5] + a[6];
        		b[6] = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6];
        		b[0] = 0;b[2] = 0;b[4] = 0;
        	}
        	if(name[i] == 'I'){
        		b[2] = a[2] + a[4] + a[5] + a[6];
        		b[4] = a[0] + a[2] + a[3] + a[4] + a[5] + a[6]; 
        		b[5] = a[1] + a[2] + a[3] + a[4] + a[5] + a[6];
        		b[6] = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6];
        		b[0] = 0;b[1] = 0;b[3] = 0;
        	}
        	for(int j = 0;j < 7;j++){
        		a[j] = b[j];
        		if(a[j] > 10070000){
        			a[j] = a[j] % 100070000;
        		}
        	}
        }
        for(int j = 0;j < 7;j++){
        	sum = sum + a[j];
        }
    	sum = sum % 10007;
        System.out.println(sum);
	}
}

Measured memory_bytes: 17168
N,X=map(int,input().split())
p=[1]
a=[1]
for i in range(1,1+N):
    b=2*p[i-1]+1
    p.append(b)
    c=2*a[i-1]+3
    a.append(c)

ans=[]
if X==1:
    print(0)
    exit()
def f(n,x):
    #print(n)
    if n==0:
        return 0 if x<=0 else 1
    elif x<=(1+a[n-1]):
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(N,X))


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

int main(){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--;B--;C--;D--;
    string s;
    cin >> s;
    bool cross;
    if (C > D) cross = true;
    while (A < C || B < D) {
        if (cross && A+1==B && s[A+2] == '.') {
            A += 2;
            cross = false;
            continue;
        }
        if (A+1 <= C && s[A+1] == '.' && A+1 != B) {
            A++;
            continue;
        }else if (A+2 <= C && s[A+2] == '.' && A+2 != B) {
            A += 2;
            continue;
        }else if (B+1 <= D && s[B+1] == '.' && B+1 != A) {
            B++;
            continue;
        }else if (B+2 <= D && s[B+2] == '.' && B+2 != A) {
            B += 2;
            continue;
        }
        break;
    }
    if (A==C && B==D) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
using System;
class Program {
  static void Main (string[] args) {
    // スペース区切りの整数の入力
    string[] input = Console.ReadLine ().Split (' ');
    int N= int.Parse (input[0]);
    int X= int.Parse (input[1]);

    int[] a = new int[N];
    int max=0;
    int min =1000000;
    for (int i = 0; i < N; i++) {
      a[i] = int.Parse (Console.ReadLine ());
      max += a[i];
      if (min>a[i])min=a[i];//最小値
    }



    
    int count=N;
    while(true){
      if (max+min<=X){
        max+=min;
        count++;
      }else{
        break;
      }
    }

  Console.WriteLine (count);

  }

}

Measured memory_bytes: 13140
#!/usr/bin/env python3
s = list(input())
k = int(input())
n = len(s)
if s.count(s[0]) == n:
    print(n * k // 2)
    exit()
c = 0
t = s * 3
for i in range(n * 3 - 1):
    if t[i + 1] == 'X':
        continue
    if t[i] == t[i + 1]:
        t[i + 1] = 'X'
ans = t[0:n].count('X') + t[n:2 * n].count('X') * (k - 2) + t[2 * n:3 * n].count('X')
print(ans)


Measured memory_bytes: 3064
use std::collections::BTreeMap;

fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    handle.read_line(&mut buf).unwrap();
    let info: Vec<usize> = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
    let (n, p) = (info[0], info[1]);
    let primarys = trivial_division(p as u64);
    let mut prim_map = BTreeMap::new(); 
    for i in primarys {
        let entry = prim_map.entry(i).or_insert(0);
        *entry += 1;
    }
    let mut ans = 1;
    for mut i in prim_map.into_iter().filter(|a| a.1 >= n) {
        while i.1 >= n {
            ans *= i.0;
            i.1 -= n;
        }
    }
    println!("{}", ans);
}

fn trivial_division(n: u64) -> Vec<u64> {
    let mut result = n;
    for i in 2..((n as f64).sqrt() as u64)+1 {
        if n % i == 0 {
            result = i;
            break;
        }
    }

    if result == n {
        return vec![n];
    } else {
        let mut v1 = vec![result];
        let mut v2 = trivial_division(n / result);

        v1.append(&mut v2);

        return v1;
    }
}


Measured memory_bytes: 4352
import java.util.*;

public class Main{
//public class abc164_b{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		
		while(a > 0 && c >0){
			c -= b;
			if(c <= 0){
				System.out.println("Yes");
				break;
			}
			a -= d;
			if(a <= 0)System.out.println("No");
		}
		
	}

}

Measured memory_bytes: 27084
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RD;
	auto B = RD;

	writeln(abs(A-B) % 2 == 0 ? "Alice" : "Borys");
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
// AOJ 009

#include <iostream>
#define MAX_NUMBER 1000000
using namespace std;

bool isPrime[MAX_NUMBER];

void SetFalseToMultiples (int prime) {
	for (int i = prime*2; i < MAX_NUMBER;i+=prime) {
		isPrime[i] = false;
	}
	return;
}	

int CountPrimes(int n) {
	int count = 0;
	for (int i = 1;i <= n;i++) {
		if (isPrime[i]) count++;
	}
	return count;
}

int main() {
	for (int i = 0;i < MAX_NUMBER;i++) {
		isPrime[i] = true;	
	}
	isPrime[1] = false;
	
	for (int i = 1;i < MAX_NUMBER;i++) {
		if (isPrime[i]) {
			SetFalseToMultiples(i);
		}
	}
	int n;
	while (cin >> n) {
		cout << CountPrimes(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define ll	        long long
#define all(v)      (v).begin() , (v).end()
#define vi          vector <ll>
#define vii         vector <pair<ll,ll>>
#define ii          pair<int,int>
#define lp(i,a,b)	for(int i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
const ll mod=1e9+7,MAX=2e3+5;

void fast();
int main()
{
    fast();
    int a,b,c,d,i=0;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        if(i&1){
            a-=d;
        }
        else{
            c-=b;
        }
        i++;
    }
    if(a<=0)
        cout<<"No";
    else
        cout<<"Yes";
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  
  for(int i=B-A+1; i<=B+A-1; ++i){
    cout<<i<<" ";
  }
  cout<<endl;
}


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

int main(){
  char c;
  cin >> c;
  string s ="abcdefghijklmnopqrstuvwxyz";
  
  for(int i=0;i<26;i++){
    if(c==s.at(i)){
      cout << s.at(i+1) << endl;
    }
  }
}

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

string rotate(string S, int a){
  for(int i=0; i<S.length(); i++){
    if(S[i] != ' ' && S[i] !=  '.'){
      S[i] = (S[i] -'a' + a) % 26 + 'a';
    }
  }
  return S;
}





int main(){
  string S;
  
  while(getline(cin, S)){
    for(int i=0; i<26; i++){
      string T = rotate(S, i); bool flag = false;

      for(int j=0; j<S.length(); j++){
        if(T[j] == 't' && T[j+1] == 'h' && T[j+2] == 'e'){
          cout << T << endl; flag = true; break;
        } else if (T[j] == 't' && T[j+1] == 'h' && T[j+2] == 'i' && T[j+3] == 's'){
          cout << T << endl; flag = true; break;
        } else if (T[j] == 't' && T[j+1] == 'h' && T[j+2] == 'a' && T[j+3] == 't'){
          cout << T << endl; flag = true; break;
        }
      }

      if (flag) break;
    }
  }
}
  
  


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		
		if (N > 999) {
			System.out.println("ABD");
		} else {
			System.out.println("ABC");
		}
		
	}

}


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

using namespace std;

#define REP(a, b, c) for (int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (int a = head[b]; a; a = edge[a].nxt)

inline int rd () {
	int x = 0; char IO = getchar();
	bool f = 0;
	while ((IO < '0' || IO > '9') && IO != '-') IO = getchar();
	if (IO == '-') f = 1, IO = getchar();
	while (IO >= '0' && IO <= '9') x = (x << 3) + (x << 1) + (IO ^ 48), IO = getchar();
	return f ? -x : x;
}

const int SIZE = 1005;

int n;
int a[SIZE][SIZE], b[SIZE][SIZE];

int deg[SIZE][SIZE];

struct Node {
   int x, y;
};
vector<Node> E[SIZE][SIZE];

int dep[SIZE][SIZE];

int main () {
   n = rd();

   memset(a, 127, sizeof a);

   REP (i, 1, n) {
      int num = 0;
      REP (j, 1, n) if (i ^ j) {
         ++num;
         a[i][num] = rd();
         b[i][a[i][num]] = num;
      }
   }

   queue<Node> Q;

   REP (i, 1, n) REP (j, i + 1, n) {
      if (b[i][j] != 1) {
         int t1 = min(i, a[i][b[i][j] - 1]);
         int t2 = max(i, a[i][b[i][j] - 1]);
         E[t1][t2].push_back((Node) { i, j});
         ++deg[i][j];
      }
      //printf ("%d %d\n", b[i][j], b[j][i]);
      if (b[j][i] != 1) {
         int t1 = min(j, a[j][b[j][i] - 1]);
         int t2 = max(j, a[j][b[j][i] - 1]);
         E[t1][t2].push_back((Node) { i, j});
         ++deg[i][j];
      }
      if (deg[i][j] == 0) {
         Q.push((Node) { i, j}), dep[i][j] = 1;
      }
   }

   int odd = n * (n - 1) / 2, ans = 1;
   while (!Q.empty()) {
      int x = Q.front().x, y = Q.front().y;
      Q.pop();
      ans = max(ans, dep[x][y]);
      --odd;
      FOR (i, 0, E[x][y].size()) {
         int tx = E[x][y][i].x, ty = E[x][y][i].y;
         --deg[tx][ty];
         dep[tx][ty] = max(dep[tx][ty], dep[x][y] + 1);
         if (deg[tx][ty] == 0)
            Q.push((Node) { tx, ty});
      }
   }

   if (!odd) printf ("%d\n", ans);
   else puts("-1");

   return 0;
}


Measured memory_bytes: 55296
#include <cstdio>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
  while(true){
    map<char, char> mp;
    int n, m;
    scanf("%d", &n);
    if(n == 0){
      return 0;
    }
    for(int i = 0; i < n; i++){
      char ci, co;
      cin >> ci >> co;
      mp[ci] = co;
    }
    scanf("%d", &m);
    string str = "";
    for(int i = 0; i < m; i++){
      char c;
      cin >> c;
      if(mp.find(c) == mp.end())
        str.push_back(c);
      else
        str.push_back(mp[c]);
    }
    cout << str << endl;
  }
}

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

int main() {
    ll L, R;
    int ans = 2018;
    cin >> L >> R;
    if (R - L > 2019) R = L + 2019;
    for (ll i = L; i < R; i++) {
        for (ll j = i + 1; j <=R; j++) {
            ll r = (i * j) % 2019;
            if (r < ans) ans = r;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int dp[3010][3010] = {};
int main(){
	string s,t,u;
	cin >> s >> t;
	int i,j;
	for(i=1;i<=s.size();i++){
		for(j=1;j<=t.size();j++){
			dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
		}
	}
	i = s.size(), j = t.size();
	while(i>0 && j>0){
		if(dp[i-1][j]==dp[i][j]) i--;
		else if(dp[i][j-1]==dp[i][j]) j--;
		else{
			i--; j--;
			u.push_back(s[i]);
		}
	}
	for(i=0;i<u.size();i++){
		cout << u[u.size()-1-i] ;
	}
	cout << endl;
}

Measured memory_bytes: 35584
n=int(input())
s=list(map(int,input().split()))
ans=0
s.sort()
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if s[i]!=s[j]!=s[k]:
        if s[k]<s[j]+s[i]:
          ans+=1
print(ans)
  
  

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  cin >> n;
  vector<double> a(n);
  rep(i, n)
    cin >> a[i];
  sort(all(a));
  rep(i, n - 1)
    a[i + 1] = (a[i] + a[i + 1]) / 2.00000000;
  kono(7);
  cout << a[n - 1];
  memi;
}

Measured memory_bytes: 256
fn gcd(x: u32, y: u32) -> u32 {
    let mut x = x;
    let mut y = y;
    while y != 0 {
        let t = y;
        y = x % y;
        x = t;
    }
    x
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: u32 = iter.next().unwrap().parse().unwrap();
    let b: u32 = iter.next().unwrap().parse().unwrap();
    let mut k: u32 = iter.next().unwrap().parse().unwrap();

    let ab_gcd = gcd(a, b);

    for i in (0..ab_gcd+1).rev() {
        if ab_gcd % i == 0 {
            k -= 1;
        }
        if k == 0 {
            println!("{}", i);
            break;
        }
    }
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

ll comb(ll n, ll k) {
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    ll result = n;
    for( ll i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, P;
    cin >> N >> P;

    int even = 0, odd = 0;
    rep(i, N) {
        int A;
        cin >> A;
        if (A%2) odd++;
        else     even++;
    }

    // DUMP2(even, odd);

    ll ans = pow(2, even);

    ll tmp = 0;
    for (int i=P; i<=odd; i+=2) {
        tmp += comb(odd, i);
        // DUMP2(i, tmp);
        // cerr << comb(odd, i) << endl;
    }
    ans *= tmp;

    //if (P == 1 && odd == 0) {
    //     cout << 0 << endl;
    // } else {
        cout << ans << endl;
    //}
}

Measured memory_bytes: 256
a,b,c,k = map(int, input().split())

ans = 0
if (a>=k):
    ans += k
    print(ans)
    exit()
elif a+b >= k:
    ans += a
    print(ans)
    exit() 
else:
    ans += a+(-1)*(k-a-b)
    print(ans)

Measured memory_bytes: 9180
#include <stdio.h>

int main(){
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(a!=b && b!=c && a!=c){
        printf("3\n");
    }
    
    else if((a==b && a!=c)||(a==c && a!=b)||(b==a && b!=c)||(b==c && b!=a)||(c==a && c!=b)||(c==b && c!=a)){
        printf("2\n");
    }
    
    else if(a==b && a==c && b==c){
        printf("1\n");
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
struct UF{
    vector<int> par, rank, size;

    void init(int n){
        par.assign(n, 0);
        rank.assign(n, 0);
        size.assign(n, 1);
        for(int i=0;i<n;i++){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x != y){
            if(rank[x] < rank[y]){
                par[x] = y;
                size[y] += size[x];
            }else{
                par[y]=x;
                size[x] += size[y];
                if(rank[x]==rank[y]) rank[x]++;
            }
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int get_size(int x){
        return size[find(x)];
    }
};

int main(void){
    int n, m, k;
    UF uf;
    vector<int> f;
    cin >> n >> m >> k;
    uf.init(n);
    f.assign(n, -1);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
        f[a]--;
        f[b]--;
    }
    for(int i=0;i<k;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(uf.same(a, b)){
            f[a]--;
            f[b]--;
        }
    }

    for(int i=0;i<n;i++){
        f[i] += uf.get_size(i);
    }

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


Measured memory_bytes: 2432
/**
 *      ABC 91 A
 *      author  : kyomukyomupurin
 *      created : 2018-08-31 03:43:14
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, C; cin >> A >> B >> C;
    A + B >= C ? cout << "Yes" << '\n' : cout << "No" << '\n';
    
    return 0;
} 


Measured memory_bytes: 256
# A - RGB Cards

# 整数r,g,bを入力し、左から並べてできた3桁の整数が4の倍数であるか判定する


r,g,b = map(str,input().split())

answer = int(r + g + b)

if answer % 4 == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 9064
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let arr = input.split("\n").map(Number);
for (let i = 0; i < arr.length; i ++) {
    if (arr[i] === 0) break;
    console.log("Case %d: %d", i + 1, arr[i]);
}


Measured memory_bytes: 23232
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int main(void){
    LL x;
    cin>>x;
    LL r=(x/11)*2;
    x%=11;
    if(1<=x&&x<=6)
        r++;
    else if(7<=x)
        r+=2;
    cout<<r<<endl;
     return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	M := make(map[int]int)
	for i := 0; i < n; i++ {
		var k, t int
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			fmt.Scan(&t)
			M[t]++
		}
	}
	ans := 0
	for _, p := range M {
		if p == n {
			ans++
		}
	}
	fmt.Print(ans)
}

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

int main() {
    int n,w;
    cin>>n>>w;
    long long val[n];
    long long  weight[n];
    
    int i,j;
    for(i= 0 ;i < n; i++)
    {
        cin>>weight[i];
        cin>>val[i];
    }
    
    long long dp[2][w+1];
    memset(dp, 0, sizeof(dp));
    
    for(i= 1 ;i <= n; i++)
    {
        for(j= 1; j <= w ;j++)
        {
            if(weight[i-1] <= j)
            {
                dp[i % 2][j] = max(val[i-1] + dp[(i-1) % 2][j - weight[i-1]], dp[(i-1) % 2][j]);
            }
            else
                dp[i % 2][j] = dp[(i-1) % 2][j];
        }
    }

    cout<<dp[n % 2][w];
}

Measured memory_bytes: 1920
arr = input().split()

arr2 = list(map(int, input().split()))

n,m,count,sum = int(arr[0]),int(arr[1]),0,0

for i in arr2:
  sum += i
  

for i in arr2:
  if i >= sum/(4*m): count+= 1
    
if count >= m: print("Yes")
else: print("No")

Measured memory_bytes: 9136
import math
d, n = map(int, input().split())
listT = []
index=0
while index < d:
    listX = list(map(int, input().split()))
    listT.append(listX)
    index+=1

index2=0
count=0
while index2 < len(listT):
    index3=index2+1
    while index3 < len(listT):
        sumA=0
        index4=0
        while index4 < len(listT[index2]):
            sumA+=(listT[index2][index4]-listT[index3][index4])**2
            index4+=1
        if math.sqrt(sumA).is_integer():
            count+=1
        index3+=1
    index2+=1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll x1 = a * c;
	ll x2 = a * d;
	ll x3 = b * c;
	ll x4 = b * d;
	cout << max({x1, x2, x3, x4});
}


Measured memory_bytes: 3648
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


ll LCM(ll a, ll b) {
	return a / GCD(a, b) * b;

}

int main() {
	int n;
	cin >> n;
	vector<ll> t(n,0);
	rep(i, n) {
		cin >> t[i];
	}

	ll ans = t[0];
	for(int i = 1; i < n; ++i) {
		ans = LCM(ans, t[i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

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

    vector<int> evens;
    vector<int> odds;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (i%2 == 0)
            evens.push_back(a);
        else
            odds.push_back(a);
    }

    if (n % 2 == 0) {
        reverse(odds.begin(), odds.end());
        for (int i = 0; i < odds.size(); i++) {
            if (i != 0) cout << " ";
            cout << odds[i];
        }
        for (int i = 0; i < evens.size(); i++) {
            cout << " ";
            cout << evens[i];
        }
    } else {
        reverse(evens.begin(), evens.end());
        for (int i = 0; i < evens.size(); i++) {
            if (i != 0) cout << " ";
            cout << evens[i];
        }
        for (int i = 0; i < odds.size(); i++) {
            cout << " ";
            cout << odds[i];
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll h;
	cin >> h;
	ll cnt = 1;
	ll ans = 1;
	while (h > 1) {
		cnt *= 2;
		ans += cnt;
		h/=2;
	}
	cout << ans;
}
 

Measured memory_bytes: 384