akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

public class Class1
{
	public static void Main()
	{
        int n = int.Parse(Console.ReadLine());
        string[] a = Console.ReadLine().Split(' ');

        /* This code is TLE

        List<string> b = new List<string>();

        for (int i = 0; i < a.Length; i++)
        {
            b.Add(a[i]);

            writeList(b);

            b.Reverse();

            writeList(b);
            Console.WriteLine("-------");
        }

        for (int i = 0; i < b.Count; i++)
        {
            Console.Write(b[i] + " ");
        }

        */


        string[] b1, b2;

        if(n%2 == 0)
        {
            b1 = new string[(int)(n / 2)];
            b2 = new string[(int)(n / 2)];
        }
        else
        {
            b1 = new string[(int)(n / 2) + 1];
            b2 = new string[(int)(n / 2)];
        }

        int b1ind = 0;
        int b2ind = 0;


        for(int i = 0; i < a.Length; i++)
        {
            if (i % 2 == 0)
            {
                b1[b1ind] = a[i];
                b1ind++;
            }
            else
            {
                b2[b2ind] = a[i];
                b2ind++;
            }
        }

        if(n%2 == 0)
        {
            downWrite(b2);
            upWrite(b1);
        }
        else
        {
            downWrite(b1);
            upWrite(b2);
        }








    }

    static void downWrite(string[] st)
    {
        for(int i = 0 ; i < st.Length; i++)
        {
            Console.Write(st[st.Length - 1 - i] + " ");
        }
    }

    static void upWrite(string[] st)
    {
        for (int i = 0; i < st.Length; i++)
        {
            Console.Write(st[i] + " ");
        }
    }


    static void writeList(List<string> b)
    {
        for (int i = 0; i < b.Count; i++)
        {
            Console.Write(b[i] + " ");
        }

        Console.WriteLine();
    }
}


Measured memory_bytes: 38324
#include<stdio.h>
int main() {
	int A, B, sum=0;
	scanf("%d %d", &A, &B);
	if(B%A == 0) {
	  sum = A + B;
	} else {
	  sum = B - A;
	}
	printf("%d", sum);
  
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s,t,u;cin >> s >> t >> u;
  cout << 'A' << t[0] << 'C' << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main(){
    int a,b;
    cin >> a >> b;
    int cnt = 1,ans=0;
    while(cnt<b){
        cnt += a - 1;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
def turukame(a, b, num, remain)
  y = (remain - a * num) / (b - a)
  x = num - y

  return [-1, -1] if remain != a * x + b * y

  [x, y]
end

N = gets.to_i

(1..25).each do |num|
  x, y = turukame(4, 7, num, N)

  next if x < 0 || y < 0

  puts 'Yes'
  exit
end

puts 'No'


Measured memory_bytes: 1788
var input = "";
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", (chunk) => {
  input += chunk;
});
process.stdin.on("end", () => {
  input = input.split("\n");
  main();
});

function main(){
  var numbers = input[0].split("");
  var sum = 0;
  numbers.forEach( inp => {
    sum += Number(inp);
  });  
  if(Number(input[0]) % sum == 0){
    console.log("Yes");
  } else {
    console.log("No");
  }
}

Measured memory_bytes: 7500
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k, n;
  cin >> k >> n;
  vector<ll> a;
  for(int i=0; i<n; i++) {
    ll tp; cin >> tp;
    a.push_back(tp);
  }
  ll m = 0, s = 0;
  for(int i=0; i<n-1; i++) {
    m = max(a[i+1] - a[i], m); 
    s += a[i+1] - a[i];
  }
  ll t = k - a[n-1] + a[0];
  m = max(m, t);
  s += t;
  cout << s - m << '\n'; 
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL << 62;
const int INF = 1 << 30;
const double PI = acos(-1);
int main()
{
	int d, n;
	int dis[] = {1, 100, 10000};
	int ans = 0;
	cin >> d >> n;
	ans = n * dis[d];
	if(n==100){
		ans+=dis[d];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = gets.split

num = {}
[0, 2, 5, 5, 4, 5, 6, 3, 7, 6].each_with_index{|i, idx| num[idx.to_s] = i }

INF = 1e8.to_i
dp = Array.new(n+1, -INF)
dp[0] = 0

for i in 1..n
    maxcol = -INF
    for aj in a
        num_aj = num[aj]

        next if i - num_aj < 0

        if dp[i - num_aj] + 1 > maxcol
            maxcol = dp[i - num_aj] + 1
        end
    end

    if maxcol > 0
        dp[i] = maxcol
    end
end

a = a.sort.reverse
match = n
remcol = dp[n]
ans = ""
while match > 0
    for ai in a
        num_ai = num[ai]

        next if match - num_ai < 0

        if dp[match - num_ai] == remcol - 1
            ans += ai
            remcol -= 1
            match -= num_ai
            break
        end
    end
end

puts ans


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

main(){
  int n; cin >> n;
  int x, p = 0;
  for ( int i = 0; i < n; i++ ){
    char ch; cin >> ch >> x;
    if ( ch == '(' ) p += x;
    else p -= x;
    if ( p < 0 ){
      cout << "NO" << endl; return 0;
    }
  }
  cout << (p == 0?"YES":"NO") << endl;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        final String c = sc.next();
        
        int w = c.indexOf('W');
        int r = c.lastIndexOf('R');
        
        int count = 0;
        while (0 <= w && 0 <= r && w < r) {
            count++;
            w = c.indexOf('W', w + 1);
            r = c.lastIndexOf('R', r - 1);
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 40416
/*
 * 	Roses are red
 * 		Violets are blue
 * 			I cried
 * 				And so did you
*/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
//typedef double f80;
#define double long double
#define pii pair<int,int>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
#define deb cout<<"Line: "<<__LINE__<<" plz "
typedef long long ll;
const ll inf=1e18;
const ll mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powm(ll a, ll b, ll m);

int a[100001];
void solve()
{
	int n;
	cin>>n;
	int odd=0;
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		if(a[i]&1)
			odd++;
	}
	if(odd>0)
		cout<<"first"<<endl;
	else
		cout<<"second"<<endl;

}
signed main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
	auto clk=clock();
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	clk=clock()-clk;
	cout<<endl<<endl<< "Time Elapsed: " << ((double)clk)/CLOCKS_PER_SEC <<endl;
#endif
	return 0;
}
ll powm(ll a,ll b, ll m) {
	ll te=1;
	while(b) {
		if(b&1) te=(te*a)%m;
		a=(a*a)%m;
		b>>=1;
	}
	return te;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int a[n];
  for(int loop=0;loop<n;loop++){
    scanf("%d",&a[loop]);
  }
  int rev[n];
  for(int loop=0;loop<n;loop++){
    rev[a[loop]-1]=loop+1;
  }
  for(int loop=0;loop<n;loop++){
    printf("%d\n",rev[loop]);
  }
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    lint dp[13][100005];
  int main(){
      string s;
      cin>>s;
      reverse(all(s));
      lint mul=10;
      if(s[0]!='?')dp[s[0]-'0'][0]=1;
      else{
          rep(i,10)dp[i][0]=1;
      }

        rep(i,s.size()-1){
            if(s[i+1]=='?'){
                rep(j,10){
                    lint x=j*mul;
                    x%=13;
                    rep(k,13){
                        dp[(k+x)%13][i+1]+=dp[k][i];
                        dp[(k+x)%13][i+1]%=MOD;
                    }
                }
            }else{
                lint x=s[i+1]-'0';
                x*=mul;
                x%=13;
                rep(j,13){
                    dp[(j+x)%13][i+1]+=dp[j][i];
                    dp[(j+x)%13][i+1]%=MOD;
                }
            }
            mul*=10;
            mul%=13;
        }
       cout<<dp[5][s.size()-1];
  }
  
     


Measured memory_bytes: 10752
#include<bits/stdc++.h>//偷懒专用库 
#define MAXN 99999
#define INF 101//两个宏定义 
using namespace std;
inline int read(){
 char c=getchar();int x=0,f=1;
 while(c>'9'||c<'0'){if(c!='-')f=-1;c=getchar();}
 while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
 return x*f;
}//快读，想学习的可以借鉴 
char s[INF][INF];//用来存字符 
int n,m,tot,pop;//n代表行，m代表列，tot和pop用来判断 
int main()
{
    n=read();
    m=read();//读入行和列 
    for(int i=1;i<=n;++i)
     for(int j=1;j<=m;++j)
      cin>>s[i][j];//读入字符 
    s[0][1]=s[1][0]='#';//很关键，如果不写，输出结果全部都是Impossible 
    for(int i=1;i<=n;++i)
     for(int j=1;j<=m;++j)
      {
        tot=0;
        pop=0;//初始化 
        if(s[i][j]=='#')
         {
            if(s[i][j+1]=='#')
             tot++;
            if(s[i+1][j]=='#')
             tot++;//判断下面和右面有一个还是两个，按照题意，两个位置只能存在一个 
            if(s[i-1][j]!='#')
             pop++;
            if(s[i][j-1]!='#')
             pop++;//这个是判断上面或者左边有没有，也就是确定有没有方法能到达 
         }
        if(tot==2||pop==2)
         {
            cout<<"Impossible\n";
            return 0;//只要不满足其中一种，就输出不可能，然后直接结束 
         }
      }
    cout<<"Possible\n";//否则输出可能 
    return 0;//别忘了打return 0 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int cost[n];
  int A[n][m];
  rep(i, n) {
    cin >> cost[i];
    rep(j, m) cin >> A[i][j];
  }
  int ans = INF;
  for (int bit = 0; bit < (1 << n); bit++) {
    int res[m];
    rep(i, m) res[i] = 0;
    int o = 0;
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        rep(j, m) res[j] += A[i][j];
        o += cost[i];
      }
    }
    int c = 0;
    rep(j, m) {
      if (res[j] >= x) c++;
    }
    if (c == m) ans = min(ans, o);
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <deque>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 * 1e9 + 100;

vector<ll> pr, xr;
vector<ll> vec, srt;
vector<ll> nw;
vector<pair<ll, ll>> ps;

ll n, k, q, tree[SIZE * 4];

void build(int v, int l, int r) {
    if (l == r - 1) {
        tree[v] = vec[l];
    }
    else {
        int m = (l + r) / 2;
        build(v * 2 + 1, l, m);
        build(v * 2 + 2, m, r);
        tree[v] = min(tree[v * 2 + 1], tree[v * 2 + 2]);
    }
}

ll get(int v, int l, int r, int askl, int askr) {
    if (l >= askr || r <= askl) return INT64_MAX;

    if (l >= askl && r <= askr) return tree[v];

    ll mid = (l + r) / 2;
    return min(get(v * 2 + 1, l, mid, askl, askr), get(v * 2 + 2, mid, r, askl, askr));
}
ll check(ll lft) {
    ll vl = 0;

    ll pr = 0, s = 0, ans= 0;
    ll mx = 0, mn = 0;
    vector<ll> kt;
    vector<ll> added;
    for (int i = 0; i < vec.size(); i++) {
        if (vec[i] < lft) {
            sort(kt.begin(), kt.end());
            
            for (int t = 0; t < s - k + 1; t++) {
                added.push_back(kt[t]);
            }
            vl += (s - k + 1);
            s = 0;
            pr = 0;
            kt.clear();
        }
        else {
            s++;
            kt.push_back(vec[i]);
            pr = 1;
        }
    }

    sort(added.begin(), added.end());
    mn = INT64_MAX;
    for (int i = 0; i < q && i < added.size(); i++) {
        mx = max(mx, added[i]);
        mn = min(mn, added[i]);
    }
    if (added.size() >= q) return mx - mn;
    else {
        return -1;
    }
}

int main() {
    fastInp;

    cin >> n >> k >> q;
    vec.resize(n);

    for (int i = 0; i < n; i++) cin >> vec[i];
    vec.push_back(-1);
    srt = vec;
    sort(srt.begin(), srt.end());
    ll mxNm = 0, ans = INT64_MAX;
    for (int i = 1; i < srt.size(); i++) {
        int l = i, r = n - 1;

        if (check(srt[i]) != -1) {
            ans = min(ans, check(srt[i]));
        }
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(b / a, c) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	ll a,b;
	cin>>a>>b;
	vector<ll> s(n+1), dp(n+1,0),sum(n+2);
	ll nonzero=0;
	s[0] = -1145141919123456789;
	for(int i=1;i<=n;i++){
		cin>>s[i];
	}
	dp[0]=1;
	sum[0]=0;
	sum[1]=1;
	if(a>b){
		ll x = a;
		a = b;
		b = x;
	}
	for(int i=2;i<=n;i++){
		if(s[i]-s[i-2]<a){
			cout<<0<<endl;
			return 0;
		}
	}
	
	for(int i=1;i<=n;i++){
		vector<ll>::iterator itr = upper_bound( s.begin(), s.end() , s[i] - b);
		int num = itr - s.begin();
		num--;
		if(nonzero<=num){
			dp[i] = (sum[num+1]-sum[nonzero]+mod)%mod;
		}
		//cout<<nonzero<<" "<<num<<" "<<dp[i]<<endl;
		sum[i+1] = (sum[i] + dp[i]) % mod;
		if(s[i]-s[i-1]<a){
			nonzero = i-1;
		}
	}
	cout<<(sum[n+1]-sum[nonzero]+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
int main()
{
    int N;
    std::cin >> N;
    if (N == 3) { return std::cout << "2 3 25" << std::endl, 0; }
    std::cout << "2 4 3 9", N -= 4;
    for (int i = 1; i <= 4999 and N >= 2; i++, N -= 2) { std::cout << " " << 6 * i + 2 << " " << 6 * i + 4; }
    for (int i = 1; i <= 2499 and N >= 2; i++, N -= 2) { std::cout << " " << 12 * i + 3 << " " << 12 * i + 9; }
    for (int i = 1; i <= 5000 and N > 0; i++, N--) { std::cout << " " << 6 * i; }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <fstream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	int* H = new int[N + 1];
	for (int i = 1; i <= N; i++)
		cin >> H[i];

	int* good = new int[N + 1];
	for (int i = 1; i <= N; i++) {
		good[i] = 1;
	}

	int a, b;
	for (int i = 1; i <= M; i++) {
		cin >> a >> b;
		if (H[a] == H[b])
			good[a] = good[b] = 0;
		else {
			int tmp = H[a] < H[b] ? a : b;
			good[tmp] = 0;
		}
	}

	int cnt = 0;
	for (int i = 1; i <= N; i++) {
		//cout << good[i] << " ";
		if (good[i] == 1)
			cnt++;
	}
	//cout << endl;
	cout << cnt << endl;
}


Measured memory_bytes: 4420
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    int na, nb, nc;
    na = a.size();
    nb = b.size();
    if(a[na-1] == b[0] && b[nb-1] == c[0]) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  string s; cin >> s;
  if (s.size()%2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<s.size(); i+=2) {
    if (s[i] == 'h' && s[i+1] == 'i') continue;
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

// EOF

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int n, m;
	while (scanf("%d %d", &m, &n), n)
	{
		int thick[100];
		for (int i = 0; i < n; ++i)
			scanf("%d", thick+i);

		int maxThick = 0;
		for (int i = 0; i < n; ++i)
			maxThick = max(maxThick, thick[i]);

		int l, r;
		l = maxThick;
		r = 1500000;
		while (l < r)
		{
			int t = (l + r) / 2;

			int step = 0;
			int sum = 0;
			int i;
			for (i = 0; i < n && step < m; ++i)
			{
				if (sum + thick[i] > t)
				{
					sum = 0;
					++step;
				}
				sum += thick[i];
			}
			bool ok = i == n && step < m;
			if (ok)
				r = t;
			else
				l = t + 1;
		}
		printf("%d\n", l);
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 50;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}
 
int main(void){
 
  COMinit();
 
  ll n, p;
  cin>>n>>p;
  ll gu = 0;
  ll ki = 0;
 
  REP(i, n){
    ll x;
    cin>>x;
    if(x%2==0) gu++;
    else ki++; 
  }
 
  ll ans = 0;
 
  if(p==0){
    ll gu_num = 0;
    ll ki_num = 0;
    ll count = 1;
    while(1){
      if(gu < count) break;
      gu_num += COM(gu, count);
      count++;
    }
    count = 1;
    while(1){
      if(ki < count*2) break;
      ki_num += COM(ki, count*2);
      //cout<<ki<<count*2<<endl;;
      count++;
    }
    //cout<<gu_num<<" "<<ki_num<<endl;
    ans = (gu_num+1) * (ki_num+1);
 
  }else{
    ll gu_num = 0;
    ll ki_num = 0;
    ll count = 1;
    while(1){
      if(gu < count) break;
      gu_num += COM(gu, count);
      count++;
    }
    count = 1;
    while(1){
      if(ki < count) break;
      ki_num += COM(ki, count);
      count+=2;
    }
    ans = (gu_num+1) * (ki_num);
  }
 
  cout<<ans<<endl;
  return 0;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std; 
	#define max(a, b) (a < b ? b : a) 
	#define min(a, b) ((a > b) ? b : a) 
	#define mod 1e9 + 7 
	#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
	#define FORL(a, b, c) for (int(a) = (b); (a) < (c); (a)++) 
	#define FORR(a, b, c) for (int(a) = (b); (a) > (c); (a)--) 
	#define INF 1000000000000000003 
	typedef long long int ll; 
	typedef vector<int> vi; 
	typedef vector<long long int> vl; 
	typedef pair<int, int> pi; 
	typedef pair<long long int, long long int> pl; 
	#define F first 
	#define S second 
	#define pb push_back 
	#define POB pop_back 
	#define mp make_pair 
	
	int main()
	 {ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	 	
	 	ll n,k;
	 	cin>>n>>k;
	 	vector<pi>a;
	 	k*=k;
	 	int x,y,c=0;
	 	FOR(i,n)
	 	{cin>>x>>y;
	 	a.pb(mp(x,y));
	 	if(pow(x,2)+pow(y,2)<=k)
	 	c++;
	 	}
	 	cout<<c;
		
	return 0;
	}



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

int main(){
	bool is_prime[1000000];
	
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<1000000;i++){
		is_prime[i]=true;
	}
	
	for(int i=2;i*i<1000000;i++){
		if(is_prime[i]){
			for(int j=i*i;j<1000000;j+=i){
				is_prime[j]=false;
				}
			}
		}
		
		int n_prime[1000000];
		
		int cnt=0;
		for(int i=0;i<1000000;i++){
			if(is_prime[i]){
				cnt++;
			}
			n_prime[i]=cnt;
		}
		
		while(true){
			int n;
			cin>>n;
			if(cin.eof())
				break;
				
			cout<<n_prime[n]<<endl;
		}
		
		return 0;
}								

Measured memory_bytes: 7960
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    set<ll> setik;
    ll temp;
    rp(i,3){
        cin >> temp;
        setik.insert(temp);
    }
    cout << setik.size()<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long a[90];
int main()
{
    int n;
    cin>>n;

    a[0]=2;
    a[1]=1;
    for(int i=2;i<=86;i++) a[i]=a[i-1]+a[i-2];
    cout<<a[n]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

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

    string s; cin >> s;
    int q; cin >> q;
    string a, b; bool rev = false;
    while(q--) {
        int t; cin >> t;
        if(t == 1) { swap(a, b); rev = !rev; }
        else {
            int f; char c; cin >> f >> c;
            if(f == 1) a += c;
            else b += c;
        }
    }
    reverse(begin(a), end(a));
    if(rev) reverse(begin(s), end(s));
    cout << a << s << b << endl;
}

Measured memory_bytes: 1040
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int A[200010];

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

	int N;
	int ans[3] = { 0 };
	double sum = 0.0;
	int sumi;
	cin >> N;
	rep(i, 0, N)
	{
		cin >> A[i];
		A[i] -= (i+1);
	}
	
	sort(A, A + N);

	rep(i, 0, N)
	{
		ans[0] += abs(A[i] - A[N / 2]);
	}

	cout << ans[0] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;

int alphabet[26] = {};

int main(){
    string S; cin >> S;
    
    char answer;
    
    for (int i =0; i <S.size(); ++i) {
        ++alphabet[S[i] - 'a'];
    }
    
    int index;
    for (index =0; index <27; ++index) {
        if (index == 26) {
            cout << "None" << endl;
        }else if (alphabet[index] == 0) {
            answer = 'a' + index;
            cout << answer << endl;
            break;
        }
    }
    
    return 0;
}

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

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n,m;
  int a,b;
  int cc[SIZE] = {};

  scanf("%d%d",&n,&m);
  
  for(int i=0;i<m;i++){
    scanf("%d%d",&a,&b);
    cc[a-1]++;
    cc[b-1]++;
  }
  
  bool flag = true;

  for(int i=0;i<n;i++){
    flag &= cc[i]%2 == 0;
  }
  
  if(flag){
    puts("YES");
  }else{
    puts("NO");
  }
  
  
  return 0;
}


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

int main() {
        string s;
        cin >> s;
        int ans = 0;
        if (s == "SUN") {
                ans = 7;
        }
        if (s == "MON") {
                ans = 6;
        }
        if (s == "TUE") {
                ans = 5;
        }
        if (s == "WED") {
                ans = 4;
        }
        if (s == "THU") {
                ans = 3;
        }
        if (s == "FRI") {
                ans = 2;
        }
        if (s == "SAT") {
                ans = 1;
        }
        printf("%d\n", ans);

        return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#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 srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}

void display_bit(const int& t) {
  for (int c = 1;c > 0;c<<=1) {
    if (t & c) cout << '1';
    else cout << '0';
  }
  cout << '\n';
}
int cnt_bit(const int& t) {
  int cnt {};
  for (int c = 1;c > 0;c<<=1) {
    if (t & c) ++cnt;
  }
  return cnt;
}

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

  int N, M;
  cin >> N >> M;
  int mask {};
  rep(i, N) {
    mask += (1<<i);
  }
  vector<int> board(M, 0);
  rep(i, M) {
    int k;
    cin >> k;
    rep(j, k) {
      int tmp;
      cin >> tmp;
      board[i] += 1<<(tmp-1);
    }
  }
  vector<int> answer(M, 0);
  rep(i, M) cin >> answer[i];

  int rep_cnt {1<<(N)};

  int cnt_answer {};
  rep(i, rep_cnt) {
    int made_answer {};
    for (int j=0;j<N;++j) {
      if ((1<<j)&i) made_answer += 1<<j;
    }
    bool is_ok = true;
    rep(i, M) {
      if (cnt_bit(made_answer&board[i])%2 != answer[i]) {
        is_ok = false;
        break;
      }
    }
    if (is_ok == true) ++cnt_answer;
  }
  cout << cnt_answer << '\n';
}


Measured memory_bytes: 632
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

ll n, m;
ll a[N];
ll cnt[N];
bool flag = true;

int main() {
    std::cin >> n >> m;
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (int i = 1; i <= n; i++) {
        a[i] /= 2;
        int num = 0, tmp = a[i];
        while (!(tmp % 2)) {
            num++;
            tmp /= 2;
        }
        cnt[i] = num;
        a[i] = tmp;
        if (i >= 2 && cnt[i] != cnt[i - 1]) flag = false;
    }
    if (!flag) puts("0");
    else {
        ll lcm = 1;
        while (cnt[1]) m /= 2, cnt[1]--;
        for (int i = 1; i <= n; i++) lcm = lcm * a[i] / std::__gcd(lcm, a[i]);
        printf("%lld\n", m < lcm ? 0ll : ((m / lcm + 1) / 2));
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

typedef long long ll;

long long int n, k;

void solve() {
  if(k < n) n = n % k;
  cout << min(abs(n - k) , n);
}

void input() {
  cin >> n >> k;
}
 
int main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int Alice=0;
  int Bob=0;
  vector<int> card;
  int n;
  int result=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    card.push_back(a);
  }
  
  sort(card.begin(),card.end(),greater<int>());
  for(int i=0;i<n;i=i+2) Alice+=card.at(i);
  for(int i=1;i<n;i=i+2) Bob+=card.at(i);
  result=Alice-Bob;
  cout<<result<<endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		
		//入力表示
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		
		//N.Mが同じか
		 if (N == M)
			System.out.println("Yes");
		else
			System.out.println("No");
	
		scanner.close();
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;


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

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int n, w[1000], c=1000, d, i, j, t, s1, s2;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&w[i]);
    
    for(t=1;t<n;t++){
        s1=s2=0;
        for(j=0;j<t;j++){
            s1+=w[j];
        }
        for(j=t;j<n;j++){
            s2+=w[j];
        }
        d=s1-s2;
        if(d<0) d=d*(-1);
        if(c>d) c=d;
    }
    printf("%d\n",c);
    return 0;
}

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

int main() {

     int A ,B;
    cin >> A >> B;
    
    if (A <= B * 2) {
        cout << 0 << endl;
    }
    
    if (A > B * 2) {
        cout << A - (B * 2) << endl;
    }
    
 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N;

int main() {
	cin >> N;
	ld sum = 0;
	for (ll n = 0; n < N; n++) {
		ld x;
		string u;
		cin >> x >> u;
		if (u == string("JPY"))sum += x;
		else sum += x * 380000;
	}
	cout << setprecision(12) << sum << 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 __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef gp_hash_table<int, null_type,hash<int>, equal_to<int>, direct_mask_range_hashing<int>, linear_probe_fn<>,
    hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>,true>> hash_set;
typedef gp_hash_table<int,null_type> hash_map;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 100005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

const ld PI = (ld)4*atanl(1);

mt19937 g1(chrono::steady_clock::now().time_since_epoch().count());

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,par[2*MAXN],cnt[2*MAXN][2];

inline int root(int node){
    while(node != par[node]){
        par[node] = par[par[node]];
        node = par[node];
    }
    return node;
}

int main(){
    scanf("%d",&len);
    for(int i=1; i<=2e5; i++){
        par[i] = i;
        cnt[i][0] = i<=1e5;
        cnt[i][1] = i>1e5;
    }
    for(int i=1; i<=len; i++){
        int x,y; scanf(" %d %d",&x,&y);
        int f = root(x), s = root(y+1e5);
        if(f == s) continue;
        cnt[s][0]+=cnt[f][0];
        cnt[s][1]+=cnt[f][1];
        par[f] = s;
    }
    ll res = -len;
    for(int i=1; i<=2e5; i++)
        if(root(i) == i)
            res+=1LL*cnt[i][0]*cnt[i][1];
    printf("%lld\n",res);
}

Measured memory_bytes: 2560
#pragma GCC optimize("O3") 
#include<bits/stdc++.h>
#define ll      				long long int
#define vi      				vector<int>
#define ii      				pair<int,int>
#define iii     				pair<ii,int>
#define iiii    				pair<ii,ii>
#define fi      				first
#define se      				second
#define unord_map				unordered_map
#define nxt_pmt					next_permutation
#define clr							clear
#define ALL(x) 					x.begin(),x.end()


#define pb      				push_back
#define pob     				pop_back

#define all(x)  				x.begin(), x.end()
#define len     				length()

#define db(x)					  cout << "!!!!!! " << #x << " => " << x << "\n"

#define fori(i, s, N)     for (int i = s; i <= N; i++)
#define ford(i, s, N)     for (int i = s; i >= N; i--)
using namespace std;

void init(int precision){
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

int t;
void cjam(int z){
	cout<<"Case #"<<z<<": ";
	
}

int main(){
//	init(10);
int a,b;
cin>>a>>b;
	if(b >= a) cout<<"unsafe\n";
	else cout<<"safe\n";
	return 0;
}

Measured memory_bytes: 3600
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    m = kwargs["m"]
    A = kwargs["A"]
    res = max(-1, n - sum(A))
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["n"], kwargs["m"] = [int(i) for i in cin]
    cin = input().split()
    kwargs["A"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 31448
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int k=sc.nextInt();
        int ans=n;
        for (int i = 0; i < n; i++) {
			if(sc.nextInt()<k)ans--;
		}
        
        out.println(ans);
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return p.a-a;//des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 31164
h, w, k = map(int, input().split())
c = [list(input()) for i in range(h)]

h1 = [list(f"{i:0{h}b}") for i in range(2**h)]
w1 = [list(f"{i:0{w}b}") for i in range(2**w)]

cnt = 0
for hh in h1:
    for ww in w1:
        black = 0
        x = [i for i in range(h) if hh[i]=='1']
        y = [i for i in range(w) if ww[i]=='1']
        for i in x:
            for j in y:
                if c[i][j] == '#':
                    black += 1
        if black == k:
            cnt += 1
            #print(x, y)

print(cnt)

Measured memory_bytes: 69032
#include<iostream>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	char a[105][105];
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> a[i][j];
		}
	}
	for (int j = 0; j <= w+1; j++) {
		a[0][j] = '#';
		a[h+ 1][j] = '#';
	}

	for (int i = 1; i <= h; i++) {
		a[i][0] = '#';
		a[i][w + 1] = '#';
	}
	for (int i = 0; i <= h + 1; i++) {
		for (int j = 0; j <= w + 1; j++) {
			if (j % (w + 2) == 0) {
				cout << endl;
			}
			cout << a[i][j];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


bool read(const vector<int>& w, const int siz, int& now)
{
	const int n = w.size();
	int cnt = 0;
	while (now < n && cnt<siz) {
		cnt += w[now];
		now++;
	}
	return (cnt == siz);
}

//計算
void calc(vector<int> w)
{
	int n = w.size();
	REP(start, n) {
		int now = start;
		if (!read(w, 5, now))continue;
		if (!read(w, 7, now))continue;
		if (!read(w, 5, now))continue;
		if (!read(w, 7, now))continue;
		if (!read(w, 7, now))continue;
		//cerr << "answer     ";
		cout << start + 1 << endl;
		return;
	}
	//cout << "ERROR" << endl;
}



//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	while (true) {
		int n;
		vector<int> w;
		string tmp;
		cin >> n;
		if (n == 0)break;
		REP(i, n) {
			cin >> tmp;
			w.push_back(tmp.size());
		}
		calc(w);
	}
	//debug();
	
	return 0;
}



Measured memory_bytes: 3196
#include <iostream>
#include <cctype> //is,to upper,lower
#include <string>
using namespace std;

int main(){
	string S;
	getline(cin, S);
	for(int i=0;S[i];i++){
		if(islower(S[i])){
			S[i]=toupper(S[i]);
		}
		else if(isupper(S[i])){
			S[i]=tolower(S[i]);
		}
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int X,N;
    cin>>X>>N;
    vector<int> p(N),A(110,1);
    rep(i,N){
        cin>>p[i];
        A[p[i]]=0;
    }
    rep(i,100){
        if (A[X-i]==1){
            cout<<X-i<<endl;
            break;
        }
        else if (A[X+i]==1){
            cout<<X+i<<endl;
            break;
        }
    }
    return 0;
}

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

#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    int m, d;
    cin>>m>>d;
    int a = 0;
    for(int j = 1;j<=m;j++)
        for(int i = 22;i<=d;i++)
        {
            if(i%10 >=2 && (i/10)*(i%10)==j)
                a++;
        }
    cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 256