akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  vector<int64_t> B(N);
  rep(i, N) cin >> A[i] >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  int64_t midA, midB;
  if (N % 2) {
    midA = A[N / 2];
    midB = B[N / 2];
  } else {
    midA = (A[N / 2 - 1] + A[N / 2]);
    midB = (B[N / 2 - 1] + B[N / 2]);
  }
  int64_t answer = midB - midA + 1L;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 6396
#include <stdio.h>
int main(void)
{
    int values[3];
    int i,j,t;
    for(i=0;i<3;i++)
    {
        scanf("%d",&values[i]);
    }
    for(i=0;i<3;i++)
    {
        for(j=i+1;j<3;j++)
        {
		if(values[i]>values[j])
		{
			t=values[i];
			values[i]=values[j];
			values[j]=t;
		}
	}
    }
	printf("%d %d %d\n",values[0],values[1],values[2]);
	return 0;
}

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

int main()
{
	vector<string> a(100010);
	vector<long long int> b;
	int N;
	cin >> N;
	for(int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		a[i] = s;
	}

	for(int i = 0; i < N; i++)
	{
		long long int c = 1;
		for(int j = 0; j < 10; j++)
		{
			int d = a[i][j] - 'a';
			if(d == 0) c *= 2;
			else if(d == 1) c *= 3;
			else if(d == 2) c *= 5;
			else if(d == 3) c *= 7;
			else if(d == 4) c *= 11;
			else if(d == 5) c *= 13;
			else if(d == 6) c *= 17;
			else if(d == 7) c *= 19;
			else if(d == 8) c *= 23;
			else if(d == 9) c *= 29;
			else if(d == 10) c *= 31;
			else if(d == 11) c *= 37;
			else if(d == 12) c *= 41;
			else if(d == 13) c *= 43;
			else if(d == 14) c *= 47;
			else if(d == 15) c *= 53;
			else if(d == 16) c *= 59;
			else if(d == 17) c *= 61;
			else if(d == 18) c *= 67;
			else if(d == 19) c *= 71;
			else if(d == 20) c *= 73;
			else if(d == 21) c *= 79;
			else if(d == 22) c *= 83;
			else if(d == 23) c *= 89;
			else if(d == 24) c *= 97;
			else if(d == 25) c *= 101;
		}
		b.push_back(c);
	}

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

	//for(int i = 0; i < N; i++) cout << b[i] << endl;

	vector<long long int> k;
	vector<long long int> kv;
	k.push_back(b[0]);
	kv.push_back(1);


	for(int i = 1; i < N; i++)
	{
		if(k[k.size()-1] == b[i])
		{
			kv[kv.size()-1]++;
		}
		else
		{
			k.push_back(b[i]);
			kv.push_back(1);
		}
	}

	long long int cnt = 0;
	for(int i = 0; i < kv.size(); i++)
	{
		for(int j = 1; j < kv[i]; j++) cnt += j;
	}

	cout << cnt << endl;

	return 0;
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){
  size_t len = s.length();
  if(len == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}


int gcd(int a, int b){
  int resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}





// substr(start, len)

int main(){

  int N;
  string S;

  cin >> N;
  cin >> S;

  ll r = 0, g = 0, b = 0;
  ll sum = 0;
  
  rep(i, 0, N){
    if(S[i] == 'R') r++;
    if(S[i] == 'G') g++;
    if(S[i] == 'B') b++;
  }

  sum = r*g*b;

  rep(i, 0, N){
    rep(s, 1, N){
      int j = i + s, k = j + s;
      if(k >= N) continue;

      char si = S[i], sj = S[j], sk = S[k];
      if(si != sj && si != sk && sj != sk) sum--;
    }
  }

  cout << sum << endl;



  // cout << setprecision(8) << ans << endl;  // For double
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)

using namespace std;
ll a[sz];
ll last;
vector <ll> ve;
ll steps = -1;
bool vis[sz];
void go(ll x){
  if(vis[x]){
    last = x;
    return;
  }
  vis[x] = true;
  ve.pb(x);
  steps++;
  go(a[x]);
  

}
void solve(){
  ll n,m;
  cin >> n >> m;

  for(ll i=1;i<=n;i++){
    cin >> a[i];
  }
  
  go(1);
  vector <ll> bad;
  ll szz = ve.size();
  ll j = szz-1;

  while(true){
    bad.pb(ve[j]);
    if(ve[j] == last)
      break;
    j--;
        }
        reverse(all(bad));
      //   g(last);
      //  g(steps);
      //  for(auto it:bad)
      //   cout << it << " ";
      // cout << endl;

  if(steps < m){
    m-= steps;
    
    ll szz = bad.size();

    ll idx = m%szz;
    idx--;
    if(idx<0)
      idx+=szz;
   // g(idx);
    g(bad[idx]);
  }
  else
  {
    g(ve[m]);

  }

}
int main()
{
#ifndef ONLINE_JUDGE
input_from_file
#endif
 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
   // cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
      solve();
        
    }
return 0;
}

Measured memory_bytes: 15332
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

int main(void){
 
  ll n, d;
  cin >> n >> d;
  ll x[n], y[n];
  REP(i,n){
    cin  >> x[i] >> y[i];
  }
  ll ans = 0;
  REP(i,n){
    if( x[i]*x[i] + y[i]*y[i] <= d*d ) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

int A, V, B, W, T;

int main() {
    cout << fixed << setprecision(10);
    cin >> A >> V >> B >> W >> T;

    if (V <= W) cout << "NO" << endl;
    else {
        double t = (double)(abs(A-B))/(double)(V-W);
        if (t <= (double)T) cout << "YES" << endl;
        else cout << "NO" << endl; 
    }
    
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main() {

  int a,b,c,m;

  while(1) {
    scanf("%d%d",&a,&b);
    if(a<1 || a>1000000001) {
      printf("error\n");
      continue;
    }
    if(b<1 || b>1000000001) {
      printf("error\n");
      continue;
    }
    else break;
  }

  if(a<b) {
    c = a;
    a = b;
    b = c;
  }

  while(1) {
    c = a%b;
    if(c==0) {
      m = b;
      break;
    }
    a = b;
    b = c;
  }

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

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <stack>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)

int main() {
  string s, t; cin >> s >> t;
  int N = s.size(), M = t.size();

  int dp[N+1][M+1];
  rep(i, N+1) rep(j, M+1) dp[i][j] = 0;

  rep(i, N) rep(j, M) {
    if (s[i] == t[j])
      dp[i+1][j+1] = 1 + dp[i][j];
    else
      dp[i+1][j+1] = max(dp[i][j+1], max(dp[i+1][j], dp[i][j]));
  }

  stack<char> st;
  int lcs = dp[N][M];
  int m = M;
  rrep(i, N) {
    if (dp[i][m] == lcs - 1) {
      st.push(s[i]);
      while (m >= 0 && dp[i][m] == lcs-1) --m;
      ++m;
      --lcs;
    }
  }
  while (!st.empty()) {
    cout << st.top();
    st.pop();
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 35456
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 値を取得
		String s = sc.next();
		int z = 0, o = 0;

		for (int i = 0; i < s.length(); i++) {
			if (s.substring(i, i + 1).equals("0")) {
				z++;
			} else {
				o++;
			}
		}

		System.out.println((2 * Math.min(z, o)));

		sc.close();
	}
}


Measured memory_bytes: 30704
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int main(){
  int n;
  cin>>n;
  while(n--){
    int left=-1,right=-1;
    bool flag = true;
    REP(i,10){
      int x;
      cin>>x;
      if(x>right){
        right = x;
      }else if(x>left){
        left = x;
      }else{
        flag = false;
      }
    }
    if(flag){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(void)
{
	int x;
	scanf("%d",&x);
	if(x==7){
		printf("YES\n");
	}
	if(x==5){
		printf("YES\n");
	}
	if(x==3){
		printf("YES\n");
	}
	if(!(x==7 || x==5 ||x==3)){
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, M) = Slice2<long>();
            var cnt = new long[M + 1];
            for (var i = 0; i < N; ++i)
            {
                var KA = Sarray();
                for (var j = 1; j < KA.Length; ++j)
                    ++cnt[KA[j]];
            }
            WriteLine(cnt.Count(c => c == N));
        }


        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28208
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll x,y,a,b,c=0,sum=0,ans,total,cnt,n,m,k,p,kase,i;
string s1,s2;
#define N 100001
#define MX 1000000001



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

    cout<<min(n%k,k-(n%k));




    return 0;
}
// Happy Coding  (:


Measured memory_bytes: 3632
a,b,c=[int(i) for i in input().split()]
k=int(input())
maximum=max(a,b,c)
for i in range(k):
    maximum*=2
if a==max(a,b,c):
    a=maximum
elif b==max(a,b,c):
    b=maximum
else:
    c=maximum
print(a+b+c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>  // ver2.2.8
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

VVi gr;
bool ok=true,ok2=true;
int ans;

void f(int i,int j,int k) {
        if(gr[i][j] > gr[i][k] + gr[k][j]) {cout<<-1<<endl;ok=false;}
        if(gr[i][j] == gr[i][k] + gr[k][j]) {ans -= gr[i][j];ok2=false;}
}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  gr = VVi(n,Vi(n));
  rep(i,0,n){
    rep(j,0,n){
      cin >> gr[i][j];
    }
  }
  ans = 0;
  /*rep(i,0,n){
    rep(j,i,n){
      ans += gr[i][j];
    }
  }*/
  //cerr<<ans<<endl;
  
  
  rep(i,0,n){
    rep(j,i+1,n){
      ans += gr[i][j];
      
      ok2 = true;
      rep(k,0,n){
        if(k==i||k==j) continue;
        
        f(i,j,k);
        
        if(ok2==false) break;
        if(ok==false) return 0;
        //cerr << ans << endl;
      }
      
      
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python

from sys import stdin, stderr

INF = 100000
def solve(N, rules):
   res = INF
   for num in xrange(10**N):
      snum = str(num)
      if len(snum) != N:
         continue
      ok = True
      for s, c in rules:
         if ord(snum[s-1])-ord('0') != c:
            ok = False
            break
      if ok:
         res = min(res, num)
   return res if res < INF else -1

def main():
   N, M = map(int, stdin.readline().split())
   rules = []
   for i in xrange(M):
      rules.append( map(int, stdin.readline().split()) )

   res = solve(N, rules)
   print(res)

   return 0

if __name__ == '__main__': main()


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

using namespace std;

#define ll long long
#define endl '\n'
const int N = 2e5 + 5;
vector<ll> node[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("GUARDS.INP", "r")){
                freopen("GUARDS.INP", "r", stdin);
                freopen("GUARDS.OUT", "w", stdout);
        }
        ll n;
        cin >> n;
        for (int i = 1; i < n; i++){
                ll u, v;
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        ll ccp = 0, ans = 0;
        for (int i = 1; i <= n; i++){
                ccp = ccp + i;
                for (auto j : node[i]){
                        if (j < i) ccp -= j;
                }
                ans += ccp;
        }
        cout << ans;
}
/*
*/



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

int main() {
  string S,T;
  cin>>S>>T;
  int count=0;
  
  if(S.at(0)==T.at(0)){
    count++;
  }
  if(S.at(1)==T.at(1)){
    count++;
  }
  if(S.at(2)==T.at(2)){
    count++;
  }
  cout<<count<<endl;
}



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

int main(){
  int i,N,M;
  cin >> N;
  vector<string> Blue(N);
  for(i=0;i<N;++i)
    cin >> Blue.at(i);
  cin >> M;
  vector<string> Red(M);
  for(i=0;i<M;++i)
    cin >> Red.at(i);
  int money,lastmoney=0;
  while(N--){
    money = 0;
    for(i=N;i>=0;--i)
      money += (Blue.at(i)==Blue.at(N));
    for(i=0;i<M;++i)
      money -= (Red.at(i)==Blue.at(N));
    if(money > lastmoney)
      lastmoney = money;
  }
  cout << lastmoney << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

int main(){
	ll x, a;
	cin >> x >> a;
	cout << (x < a ? 0 : 10) << endl;
}

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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=2e5+1, M=(ll)1e9+1 ;
const int mod = 998244353 ;
// struct node{
//   ll prefixsum,suffixsum,bettersum,totalsum;
//   void create(ll val){
//     prefixsum=suffixsum=bettersum=val;
//   }
//   void Merge(node& a,node &b){
//     prefixsum=max(a.prefixsum,a.totalsum+b.prefixsum);
//     suffixsum=max(b.suffixsum,a.suffixsum+b.sum);
//     totalsum=a.totalsum+b.totalsum;
    
//   }
// }
//ll dp[2][100];
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
// ll g[N][N],keep[N*N];
vl g[N],a(N),gc(N),dist(N,1),vis(N,0);

// ll solve(ll l,ll r){
//   if(l==r)
//     return l;
//   ll n1=solve(l,(l+r)/2);
//   ll n2=solve((l+r)/2 +1,r);
//   if(g[n1][n2]>0){
//     keep[g[n1][n2]]=true;
//     return n1;
//   }
//   else{
//     keep[g[n2][n1]]=true;
//     return n2;
//   }
  
// }
ll ma=0;
void dfs(ll x){
  vis[x]=1;
  // cout << x << " ";
  for(auto &it:g[x]){
    if(vis[it])
      continue;
    dfs(it);
    if(__gcd(a[x],gc[it])!=1){
      if(dist[x]<1+dist[it]){
        dist[x]=1+dist[it];
        gc[x]=__gcd(a[x],gc[it]);
      }
    }
  }
  // if(a[x]!=1)
    ma=max(ma,dist[x]);
  // return ma;
}
int main(){
 ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  ll i,l=s.length(),j=0,ok=0,f=0;
  string c="keyence";
  for(i=0;i<7;i++){
    if(s[i]==c[j])
        j++;
    
  }
  for(i=l-(7-j);i<l;i++){
    if(s[i]==c[j])
      j++;
  }
  if(j==c.length())
    cout << "YES";
  else
    cout << "NO";
    return 0;
}

Measured memory_bytes: 11264
import java.util.*;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int v[] = new int[n];
		for (int i = 0; i < n; ++i)
			v[i] = sc.nextInt();
		for (int i = 0; i < n; ++i) {
			int c = sc.nextInt();
			v[i] -= c;
		}
		sc.close();
		Arrays.sort(v);
		int ans = 0;
		for (int i = n - 1; i >= 0; --i) {
			if (v[i] > 0)
				ans += v[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int nmax = 40;
const int abmax = 10;
const int INF = 1<<29;

int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main(){
    int N, Ma, Mb; cin >> N >> Ma >> Mb;
    vector<int> a(N+1), b(N+1), c(N+1);
    for(int i=1; i<=N; i++) cin >> a[i] >> b[i] >> c[i];


    for(int i=0; i<nmax+1; i++) for(int j=0; j<nmax*abmax+1; j++) for(int k=0; k<nmax*abmax+1; k++) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    
    for(int i=0; i<=N-1; i++){
        for(int j=0; j<=nmax*abmax; j++){
            for(int k=0; k<=nmax*abmax; k++){
                if(dp[i][j][k] == INF) continue;
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                dp[i+1][j+a[i+1]][k+b[i+1]] = min(dp[i+1][j+a[i+1]][k+b[i+1]], dp[i][j][k]+c[i+1]);
            }
        }
    }

    int ans = INF;
    for(int j=1; j<=nmax*abmax; j++){
        for(int k=1; k<=nmax*abmax; k++){
            if(Ma*k == Mb*j) ans = min(ans, dp[N][j][k]);
        }
    }

    cout << ((ans == INF)? -1:ans) << endl;
}



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

using namespace std;

int x[10];

int main(void) {

	for (int i = 1; i <= 5; i++) {
		cin >> x[i];
	}

	for (int i = 1; i <= 5; i++) {
		if (x[i] == 0) { cout << i << endl; return 0; }
	}
	return 0;
}

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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
int main()
{
   int x;
   cin>>x;
   cout<<(int)(x/500)*1000+(int)((x%500)/5)*5;
}


Measured memory_bytes: 256
using System;

class A{
	public static void Main(){


		while (true) {
			string[] input = Console.ReadLine ().Split (' ');
			int H = int.Parse (input [0]);
			int W = int.Parse (input [1]);

			if (H == W && H == 0) {
				break;
			}
		
			for (int x =0; x<H; x++) {
				for (int i =0; i<W; i++) {
					if(x%2 != 0){
						if(i%2 != 0){
							Console.Write("#");
						}else{
							Console.Write(".");
						}
					}else{
						if(i%2 != 0){
							Console.Write(".");
						}else{
							Console.Write("#");
						}
					}
				}
				Console.WriteLine ();
			}
			Console.WriteLine ();

		}	
	}

}

Measured memory_bytes: 8888
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;
#define MAX 100

int main(){
  int n,dammy;
  cin>>n;
  int p[MAX+1];
  cin>>p[0];
  for(int i=0;i<n-1;i++){
    cin>>p[i+1];
    cin>>dammy;
  }
  cin>>p[n];
  int C[MAX+1][MAX+1];
  for(int i=1;i<=n;i++) C[i][i]=0;
  for(int h=2;h<=n;h++){
    for(int s=1;s<=n-h+1;s++){
      int e=s+h-1;
      C[s][e]=C[s][s]+C[s+1][e]+p[s-1]*p[s]*p[e];
      for(int j=s+1;j<e;j++){
        C[s][e]=min(C[s][e],C[s][j]+C[j+1][e]+p[s-1]*p[j]*p[e]);
      }
    }
  }
  cout<<C[1][n]<<endl;
}



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

int main(){
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}


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

int main(void){
    int N,X; cin >> N >> X;
    int ans=N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        X-=A[i];
    }

    sort(A.begin(), A.end());
    ans+=X/A[0];
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int[] count = new int[26];
        for (char c : scanner.next().toCharArray()) {
            count[c - 'a']++;
        }
        for (int i = 0; i < 26; i++) {
            if (count[i] % 2 == 1) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    rep(i,n){
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int k = sc.nextInt();
        for (int i = 0; i < s.length ; i++) {
            int v = s[i];
            if (v > 97 && v + k > 122) {
                s[i] = 97;
                k -= 123 - v;
            }
        }
        s[s.length - 1] += k % 26;
        StringBuilder builder = new StringBuilder();
        for (char v: s
             ) {
            builder.append(v);
        }
        System.out.println(builder);
    }
}

Measured memory_bytes: 26108
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool cmp(int a,int b) {return a>b;}
int fast_pow(int b,int p,int m=1){
     if(p==0) return 1;
     if(p==1) return b;
    int res=fast_pow(b,p/2,m);  res=(res*res)%m;
    if(p%2==0) return res; else return  (b*res)%m;
}
int mmi(int a,int m){ return fast_pow(a,m-2,m);}

int a[200001],b[200001];

int32_t main()
{
    FIO
    int s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe\n";
    else cout<<"safe\n";
    return 0;
}

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

const ll INF=numeric_limits<ll>::max();
const int N=1e5+5;
int n,m;
ll a[N],poly[N],cnt[N],sum,res;

void upd(int l,int r,int s){
	poly[l]-=l-s;
	poly[r+1]+=l-s;
	cnt[l]++;
	cnt[r+1]--;
}

ll get(int x){
	return poly[x]+x*cnt[x];
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;i<=n-1;++i){
		int l=a[i],r=a[i+1];
		if(l<=r){
			if(l+2<=r) upd(l+2,r,1);
			sum+=r-l;
		}
		else{
			int rf=m;
			int lf=1;
			sum+=m-l+r;
			if(l+2<=rf){
				upd(l+2,rf,1);
				upd(1,r,rf-l);
			}
			else{
				if(l==rf) l=2;
				else l=1;
				if(l<=r) upd(l,r,1);
			}
		}
	}
	for(int i=1;i<N;++i){
		poly[i]+=poly[i-1];
		cnt[i]+=cnt[i-1];
	}
	res=INF;
	for(int i=1;i<=m;++i) //?? wtf did i put n here
		res=min(res,sum-get(i));
	cout<<res<<'\n';
}




Measured memory_bytes: 5932
#include<stdio.h>
#include <string.h>


int main(void){
    char a[200002], b[200002];
    scanf("%s", a);
    scanf("%s", b);
    int ans = 0;
    int n = strlen(a);
    for(int i = 0; i < n; i++){
        if(a[i] != b[i]){
            ans++;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2088
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ld = long double;

const int N = 200002;
int d[2][2][N], ss[2][2][N], dp[N][4];
char s[2][N];

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0);
	int h, w, n, x, y;
	cin >> h >> w >> n >> x >> y >> s[0] >> s[1];	
	dp[n][1] = h - 1;
	dp[n][3] = w - 1;
	for (int i = n - 1; i >= 0; i--) {
		rep(j, 4)
			dp[i][j] = dp[i + 1][j];
		if (s[1][i] == 'U')
			dp[i][1] = min(h - 1, dp[i][1] + 1);
		else if (s[1][i] == 'D')
			dp[i][0] = max(0, dp[i][0] - 1);
		else if (s[1][i] == 'L')
			dp[i][3] = min(w - 1, dp[i][3] + 1);
		else
			dp[i][2] = max(0, dp[i][2] - 1);
		if (s[0][i] == 'U')
			dp[i][0]++;
		else if (s[0][i] == 'D')
			dp[i][1]--;
		else if (s[0][i] == 'L')
			dp[i][2]++;
		else
			dp[i][3]--;
		if (dp[i][0] > dp[i][1] || dp[i][2] > dp[i][3]) {
			cout << "NO";
			return 0;
		}
	}
	x--; y--;
	if (dp[0][0] <= x && x <= dp[0][1] && dp[0][2] <= y && y <= dp[0][3])
		cout << "YES";
	else
		cout << "NO";
}


Measured memory_bytes: 4352
#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from random import randint
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
from math import ceil
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
import sys
import os
import re
sys.setrecursionlimit(9999)
inf = float('inf')
mod = int(1e9) + 7
mod_ = 998244353
N = 5001
 
'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''


def main():
	n = int(input())
	s = input()
	total = 0
	for i in range(1, n):
		if s[i] != s[i-1]:
			total += 1
	print(total+1)

BUFSIZE = 8192
class FastI(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = StringIO()
		self.newlines = 0
 
	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()
 
	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count("\n") + (not b)
			ptr = self._buffer.tell()
			self._buffer.seek(0, 2), self._buffer.write(
				b), self._buffer.seek(ptr)
		self.newlines -= 1
		return self._buffer.readline()
class FastO(IOBase):
	def __init__(self, file):
		self._fd = file.fileno()
		self._buffer = __pypy__.builders.StringBuilder()
		self.write = lambda s: self._buffer.append(s)
 
	def flush(self):
		os.write(self._fd, self._buffer.build())
		self._buffer = __pypy__.builders.StringBuilder()
def print(*args, **kwargs):
	sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop("end", "\n"))
	if kwargs.pop("flush", False):
		file.flush()
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x
sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
	def bootstrap(cont):
		call, arg = cont.switch()
		while True:
			call, arg = cont.switch(to=continulet(
				lambda _, f, args: f(*args), call, arg))
	cont = continulet(bootstrap)
	cont.switch()
	main()

Measured memory_bytes: 32748
import Data.List

main = do
  s <- reverse <$> getLine
  putStrLn $ f s

f :: String -> String
f [] = "YES"
f xs
  | "maerd" `isPrefixOf` xs = f $ drop 5 xs
  | "esare" `isPrefixOf` xs = f $ drop 5 xs
  | "remaerd" `isPrefixOf` xs = f $ drop 7 xs
  | "resare" `isPrefixOf` xs = f $ drop 6 xs
  | otherwise = "NO"

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}


int main(){
	ll N; cin>>N;
	vector<ll>E;
	vector<ll>O;
	vector<P>e;
	vector<P>o;
	rep(i,N){
		ll A; cin>>A;
		if(i%2==0) E.pb(A);
		else O.pb(A);
	}
	sort(E.bg,E.ed);
	sort(O.bg,O.ed);
	ll mem=E[0],cnt=0;
	rep(i,E.sz){
		if(mem==E[i]) cnt++;
		else{
			if(i>=1) e.pb(mp(cnt,E[i-1]));
			cnt=1;
			mem=E[i];
		}
	}
	e.pb(mp(cnt,E[E.sz-1]));

	mem=O[0],cnt=0;
	rep(i,O.sz){
		if(mem==O[i]) cnt++;
		else{
			if(i>=1) o.pb(mp(cnt,O[i-1]));
			cnt=1;
			mem=O[i];
		}
	}
	o.pb(mp(cnt,O[O.sz-1]));

	sort(e.bg,e.ed,greater<P>());
	sort(o.bg,o.ed,greater<P>());
	if(e[0].b!=o[0].b) cout<<N-e[0].a-o[0].a;
	else if(e.sz==1 || o.sz==1){
		if(o.sz!=1) cout<<N/2-o[1].a;
		else if(e.sz!=1) cout<<N/2-e[1].a;
		else cout<<N/2;
	}
	else{
		ll t1,t2;
		t1=N/2-e[0].a;
		t2=N/2-o[1].a;
		ll ans=t1+t2;
		ans=min(ans,N-e[1].a-o[0].a);
		cout<<ans;
	}
}

Measured memory_bytes: 3312
#include<stdio.h>
  
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;
 
       
     
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

vector< vs32 > g;
vector< bool > reached;

void dfs(int u)
{
    reached[u] = true;
    for (int v : g[u])
    {
        if (!reached[v])
        {
            dfs(v);
        }
    }
}

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

    int n, m;
    cin >> n >> m;

    g.resize(n);
    reached.resize(n);
    rep (i, m)
    {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    rep (i, n)
    {
        if (!reached[i])
        {
            dfs(i);
            ++ans;
        }
    }

    cout << ans - 1 << "\n";
    return 0;
}



Measured memory_bytes: 9272
s = gets.chomp
odds = []
evens = []
s.length.times do |n|
  if n.odd?
    odds.push(s[n])
  elsif n.even?
    evens.push(s[n])
  end
end

def count(list)
  res = [0, 0] #0, 1
  list.each do |n|
    if n == "0"
      res[0] += 1
    else
      res[1] += 1
    end
  end
  res
end

even_res = count(evens)
odd_res = count(odds)

puts [even_res[0] + odd_res[1], even_res[1] + odd_res[0]].min

Measured memory_bytes: 9468
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

using namespace std;
const long long int MOD = 1000000007;

int N, M;
int num;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> M;
		if (M % 2) {
			num++;
		}
	}
	if (num % 2)cout << "NO\n";
	else cout << "YES\n";
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl
#define VIEW(x) do{cout << "--" << #x << "--" << endl; view(x);}while(0)
template<typename T> void view(T e){COUT(e);}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define _GLIBCXX_DEBUG

int main(){
  
  string a, b;
  cin >> a >> b;
  if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  ll a,b;
  cin>>a>>b;

  ll ans=1;
  if(abs(a-b)>1) {
    cout << 0 << endl;
    return 0;
  }
  if(a==b) {
    ans*=2;
    repo(i,a+1){
      ans*=i;
      ans%=mod;
      ans*=i;
      ans%=mod;
    }
  }
  else {
    repo(i,a+1){
      ans*=i;
      ans%=mod;
    }
    repo(i,b+1){
      ans*=i;
      ans%=mod;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

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

	int n; cin >> n;
	int cnt = 0;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		cnt += (a == b);
		if (a != b) cnt = 0;
		if (cnt >= 3) { cout << "Yes" << endl; return 0;}
		
	}
	cout << "No" << endl;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){FIN;
	int n; cin>>n;
	vector<int> a(n+2),l(n+2),r(n+2);
	fore(i,1,n+1) cin>>a[i];
	fore(i,1,n+1) l[i]=l[i-1]+abs(a[i]-a[i-1]);
	for(int i=n;i;i--) r[i]=r[i+1]+abs(a[i]-a[i+1]);
	
	fore(i,1,n+1) cout<<l[i-1]+abs(a[i-1]-a[i+1])+r[i+1]<<"\n";
	
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9+7;
const long double PI=acos(-1);

char a[10][10];

void solve(int T){
    int n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int msk1=0;msk1<(1<<n);msk1++){
        for(int msk2=0;msk2<(1<<m);msk2++){
            int tmp=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if((msk1>>i)&1>0 && (msk2>>j)&1>0 && a[i][j]=='#'){
                        tmp++;
                    }
                }
            }
            //cout<<tmp<<"\n";
            if(tmp==k)ans++;
        }
    }
    cout<<ans<<"\n";
}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3536
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <limits>
#include <iomanip>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class ARightTriangle {
public:
	void solve(std::istream& in, std::ostream& out) {
        int ab,bc,ca;in>>ab>>bc>>ca;
        out<<ab*bc/2<<endl;
	}
};


int main() {
	ARightTriangle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3152
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#include<sstream>
#include<boost/algorithm/string/trim.hpp>


using namespace std;

typedef long long int ll;


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

int main()
{
	ll a, b; cin >> a >> b;
	ll g = gcd(a, b);
	int ans = 1;
	for (ll i = 2; i * i <= g; i++) {
		if (g % i == 0) {
			while (g % i == 0) g /= i;
			ans++;
		}
	}
	if (g > 1) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256