akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;
const int MAXM = 1e5 + 10;
int n, m;

int x[MAXM], y[MAXM], z[MAXM];

class UnionFind {
  vector<int> size_;
  vector<int> parent_;

public:
  UnionFind(int n) {
    size_.reserve(n);
    parent_.reserve(n);
    for (int i = 0; i < n; i++) {
      size_.push_back(1);
      parent_.push_back(i);
    }
  }

  int getSize(int x) { return size_[x]; }

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

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

  void _union(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return;
    }
    if (size_[x] < size_[y]) {
      parent_[x] = y;
      size_[y] += size_[x];
    } else if (size_[x] >= size_[y]) {
      parent_[y] = x;
      size_[x] += size_[y];
    }
  }
};

void solve() {
  UnionFind uf(n);
  for (int i = 0; i < m; i++) {
    uf._union(x[i], y[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (uf.find(i) == i) {
      ans++;
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i] >> z[i];
    x[i]--;
    y[i]--;
  }
  solve();
}


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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b,c,d;


main() {
    cin >> a >> b  >> c >> d;
    if (a+b > c+d) ct("Left")
    else if (a+b < c+d) ct("Right")
    else ct("Balanced")
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int d(int x1, int y1, int x2, int y2) {
    return abs(x1-x2) + abs(y1-y2);
}
int main () {
    int t = 0, x = 0, y = 0;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int nt, nx, ny;
        cin >> nt >> nx >> ny;
        int a = d(x, y, nx, ny);
        if (!(a <= nt-t && (nt-t-a) % 2 == 0)) {
            puts("No");
            return 0;
        }
        t = nt, x = nx, y = ny;
    }
    puts("Yes");
}

Measured memory_bytes: 384
from decimal import Decimal, getcontext
getcontext().prec = 10000


def f(x):
    return Decimal(x).sqrt()


a, b, c = map(int, input().split())
eps = Decimal(10) ** (-1000)
if f(a) + f(b) + eps < f(c):
    ans = "Yes"
else:
    ans = "No"

print(ans)


Measured memory_bytes: 5588
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N = cin.nextInt();
            var D = cin.nextInt();

            var range = D * 2 + 1;
            if (N%range != 0)
            {
                Console.WriteLine((N / range) + 1);
            }
            else
            {
                Console.WriteLine((N / range) );
            }            
        }
    }

    

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = 0;
		
		for(int i=0; i < n; i++){
			if(PNcheck(sc.nextInt())) c++;
		}
		System.out.println(c);
	}
	
	static boolean PNcheck(int n){
		if(n == 2) return true;
		if((n % 2) == 0) return false;
		
		for(int i=3; i*i <= n; i = i+2){
			if((n % i) == 0) return false;
		}
		return true;
	}
}

Measured memory_bytes: 31224
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int n, m, k;
	cin >> n >> m >> k;
	char mat[n][m];
	F0R(i, n) F0R(j, m)
		cin >> mat[i][j];
	int ans = 0;
	F0R(i, 1 << n) F0R(j, 1 << m) {
		int blk = 0;
		F0R(x, n) F0R(y, m)
			if (mat[x][y] == '#' && ((i & 1 << x) == 0 && (j & 1 << y) == 0))
				++blk;
		if (blk == k)
			++ans;
	}
	cout << ans << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3660
from collections import Counter
from itertools import permutations

N = int(input())
x, y = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)

# (p, q) = (x_i - x_j, y_i - y_j) を満たす組(i, j)の個数が最大となるように
# p, qを定めればよい
ans = (
    1 if N == 1 else
    N - max(
        Counter(
            (x[i] - x[j], y[i] - y[j])
            for i, j in permutations(range(N), 2)
        ).values()
    )
)

print(ans)


Measured memory_bytes: 3828
// #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using V = vector<int>;
using VV = vector<V>;

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;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
//~ if (!bit) break;
//~ }
int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a) {
    if (a == 2) return true;
    if (a <= 1 || a % 2 == 0) return false;

    for (int i = 3; i * i <= a; i += 2) {
        if (a % i == 0) return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> aaa;
// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (aaa[index] >= key)
        return true;
    else
        return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1;  //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok =
        (int)aaa
            .size();  // 「index =
                      // a.size()-1」が条件を満たさないこともあるので、初期値は
                      // a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

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;
}

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

void memo() {
    int n = 100;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }

    vector<int> ans(n);
    iota(ans.begin(), ans.end(), 0);
    sort(ans.begin(), ans.end(), [&](int i, int j) { return a[i] < a[j]; });

    double t1 = 0.1;
    cout << fixed << setprecision(6) << t1 << endl;
}

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

    int now = 0;
    vector<int> a;
    a.push_back(s);
    set<int> sa;
    rep(i, (int)1e10) {
        auto itr = sa.lower_bound(a[i]);
        if (itr != sa.end() && (*itr) == a[i]) {
            cout << i + 1 << endl;
            return 0;
        }
        sa.insert(a[i]);

        int next;
        if (a[i] % 2 == 0)
            next = a[i] / 2;
        else
            next = 3 * a[i] + 1;

        a.push_back(next);
    }

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INT_INF 1000000000
#define DOUBLE_INF 1e18
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 19

using namespace std;

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

int main()
{
  int N;
  string S;
  cin >> N >> S;

  char l[MAX_N], r[MAX_N];
  for (int i = 0; i < N; i++) {
    l[i] = S[i];
    r[i] = S[2*N-1-i];
  }


  map<pair<string, string>, ll> m[2];

  for (int i = 0; i < (1<<N); i++) {
    string s[2];
    for (int j = 0; j < N; j++) {
      if (i >> j & 1) {
        s[0] += l[j];
      } else {
        s[1] += l[j];
      }
    }
    m[0][make_pair(s[0], s[1])]++;
  }
  for (int i = 0; i < (1<<N); i++) {
    string s[2];
    for (int j = 0; j < N; j++) {
      if (i >> j & 1) {
        s[0] += r[j];
      } else {
        s[1] += r[j];
      }
    }
    m[1][make_pair(s[0], s[1])]++;
  }

  ll ans = 0;
  for (auto itr = m[0].begin(); itr != m[0].end(); itr++) {
    ans += itr->second * m[1][itr->first];
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 108288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
vi sosuu(ll n){ //n以下の素数列挙
    vector<bool> b(n-1,true);
    for(ll i=2;i<=sqrt(n);i++){
        if(!b[i-2])continue;
        for(ll j=2;i*j<=n;j++)b[i*j-2]=false;
    }
    vi v;
    rep(i,n-1)if(b[i])v.pb(i+2);
    return v;
}
vi res;
void bunkai(ll n){
    vi x=sosuu(sqrt(n)+1);
    for(ll i:x){
        if(n%i!=0)continue;
        ll k=0;
        while(n%i==0){
            k++;
            n/=i;
        }
        chmax(res[i],k);
    }
    if(n!=1)chmax(res[n],(ll)(1));
}
ll modpow(ll a,ll b){
  ll ans=1;
  while(b>0){
    a%=mod;
    if((b&1)==1){
      ans=ans*a%mod;
    }
    b>>=1;
    a*=a;
  }
  return ans;
}
int main(){
    res=vi(1000000);
    ll n,lc=1;cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    rep(i,n)bunkai(v[i]);
    REP(i,1,1000000){
        lc*=modpow(i,res[i]);
        lc%=mod;
    }
    ll ans=0;
    rep(i,n)ans=(ans+lc*modpow(v[i],mod-2)%mod)%mod;
    out(ans);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N; cin >> N;
	vector<long long> A(N);
	rep(i, N)cin >> A[i];
	map<int, int> mp;

	rep(i, N) {
		int num = 1;
		if (mp[A[i]] != 0) {
			mp[A[i]] = 2;
		}
		else {
			for (int j = A[i]; j <= 1000000; j += A[i])++mp[j];
		}
	}
	int ans = 0;
	rep(i, N) {
		if (mp[A[i]] <= 1)++ans;
	}
	cout << ans;
}


Measured memory_bytes: 51732
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

void dump(ll *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

bool judge(){

}

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

	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);

	if(n%2==0){
		ll ans=0;
		ans+=a[n/2]-a[n/2-1];
		
		for(int i=0;i<(n-2)/2;i++){
			ans+=2*(a[n-1-i]-a[i]);
		}
		cout << ans << "\n";
	}else{
		ll ans1=0,ans2=0;
		ans1+=(a[n/2]+a[n/2+1]);
		ans2-=(a[n/2-1]+a[n/2]);

		int i=0;
		for(;i<(n-2)/2;i++){
			ans1+=2*a[n-1-i];
			ans1-=2*a[i];
			ans2-=2*a[i];
			ans2+=2*a[n-1-i];
		}
		ans1-=2*a[i];
		ans2+=2*a[n-1-i];
		cout << max(ans1,ans2) << "\n";
	}
	return 0;
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


long long  dp[3005][3005];

void solve() {
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    for (int i = 0; i <= N; i++) dp[i][i] = 0;

    for (int len = 1; len <= N; len++) {
        for (int l = 0; l + len <= N ; l++) {
            int r = l + len;

            if ((N - len) % 2 == 0) {
                dp[l][r] = max(dp[l+1][r] + a[l], dp[l][r-1] + a[r-1]);
            }
            else {
                dp[l][r] = min(dp[l+1][r] - a[l], dp[l][r-1] - a[r-1]);
            }
        }
    }

    cout << dp[0][N] << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 49752
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define pi 3.1415926536
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define precise cout.precision(7);
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
using namespace std;
int main()
{
    godspeed
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll  n,m,tc,i,j,k,l,x,y;
    string s="ACL";
    cin>>tc;
    while(tc--)
    {
       cout<<s;
    }
cout<<endl;
    return 0;
}







Measured memory_bytes: 3612
#include <iostream>
using namespace std;
const int limit = 50;
int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
	visited[v] = true;
	for (int v2 = 0; v2 < n; v2++) {
		if (graph[v][v2] == false)continue;
		if (visited[v2] == true)continue;
		dfs(v2);
	}
}

int main(){
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	int ans = 0;
	for (int i = 0; i < m;i++) {
        graph[a[i]][b[i]] = false;
        graph[b[i]][a[i]] = false;
		bool bridge = false;
		dfs(0);
		for (int i=0; i < n; i++) if (visited[i] == false)bridge = true;
		if (bridge)ans++;
		for(int i=0;i<n;i++)visited[i]=false;
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
	}
	cout << ans << endl;
	return 0;
}


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

#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VC vector<char>
#define VVI vector<vector<ll>>
#define VVC vector<vector<char>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define l_b(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define u_b(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define p_b push_back
#define p_f push_front
#define m_p make_pair
#define fir first
#define sec second
#define sz size()
ll n,m,k;
VVI tr;
ll dp[100005][2];
ll fun(ll v,ll par,ll cl)
    {   if(dp[v][cl]!=-1)
            return dp[v][cl];
        ll mul=1;
        if(cl==0)
        {   lfl(i,tr[v])
            {   if(par!=tr[v][i])
                {   ll sum=(fun(tr[v][i],v,0)+fun(tr[v][i],v,1))%mod;
                    mul=(mul*sum)%mod;
                }
            }
        }
        else
        {   lfl(i,tr[v])
            {   if(par!=tr[v][i])
                {   ll sum=(fun(tr[v][i],v,0))%mod;
                    mul=(mul*sum)%mod;
                }
            }
        }
        return dp[v][cl]=mul;
    }
int main() 
{   cin>>n;
    tr=VVI(n+1);
    lf(i,1,n-1)
    {   ll u,v;cin>>u>>v;
        tr[u].p_b(v);
        tr[v].p_b(u);
    }
    memset(dp,-1,sizeof(dp));
    cout<<(fun(1,-1,0)+fun(1,-1,1))%mod<<endl;
}

Measured memory_bytes: 14208
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, r, d; vector<string> v;
bool ok(vector<string> w) {
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < n - 2; j++) {
			if (w[i][j] == '1' && w[i][j + 1] == '1') return false;
		}
	}
	int pos = m;
	for (int i = 0; i < d; i++) {
		if (pos > 0 && w[i][pos - 1] == '1') pos--;
		else if (pos < n - 1 && w[i][pos] == '1') pos++;
	}
	return (pos == r);
}
int main() {
	while (cin >> n, n) {
		cin >> m >> r >> d; m--; r--; v.resize(d);
		for (int i = 0; i < d; i++) cin >> v[i];
		if (ok(v)) {
			cout << 0 << endl;
			continue;
		}
		bool flag = false;
		for (int i = 0; i < d; i++) {
			if (flag) break;
			for (int j = 0; j < n - 1; j++) {
				if (v[i][j] == '0') {
					v[i][j] = '1';
					if (ok(v)) {
						cout << i + 1 << ' ' << j + 1 << endl;
						flag = true; break;
					}
					v[i][j] = '0';
				}
			}
		}
		if(!flag) cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

void solve(){
  string s; cin >> s;
  int i;
  for(i = 0; i < s.length(); i++){
    if(i % 2 == 1 && s[i] == 'R') break;
    else if(i % 2 == 0 && s[i] == 'L') break;
  }
  if(i == s.length()) cout << "Yes\n";
  else cout << "No\n";
  return;
}

int main(){
  solve();
  return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int l = ri();
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	int max = a[0] + l - a[n - 1];
	for (int i = 0; i + 1 < n; i++) max = std::max(max, a[i + 1] - a[i]);
	std::cout << l - max << std::endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abcxy = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var a = abcxy[0];
            var b = abcxy[1];
            var c = abcxy[2];
            var x = abcxy[3];
            var y = abcxy[4];

            var min = Math.Min(x, y);
            var max = Math.Max(x, y);
            var answer = 0L;
            answer = a * x + b * y;
            answer = Math.Min(answer, 2 * c * max);
            answer = Math.Min(answer, 2 * c * min + Math.Min(a, 2 * c) * (x - min) + Math.Min(b, 2 * c) * (y - min));

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

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(a>b){
		a=b;
		return true;
	}
	return false;
}


int main(){
	LL l,r;cin>>l>>r;
	const LL MOD=2019;
	LL ans=LLONG_MAX;
	for(LL i=l;i<r;i++){
		for(LL j=i+1;j<=r;j++){
			chmin(ans,(i*j)%2019);
			if(!ans)break;
		}
		if(!ans)break;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

bool is_pal(string s) {
	int n = s.length();
	int i = -1, j = n;

	while (i < j and s[++i] == s[--j]);
	return i >= j;
}


int main() {

	string s; cin >> s;
	int n = s.length();
	string ff = s.substr(0, (n - 1) / 2);
	string ss = s.substr(((n + 3) / 2) - 1, n - ((n + 3) / 2) + 1);

	if (is_pal(s) and is_pal(ff) and is_pal(ss)) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const ll mod = 1e9+7;
const int N = 2e5+5;
int f(int x){
    if(x==0)return 0;
    int ret = 0;
    for(int i=1;i<=10;i++){
        if(x>=i){
            x-=i;
            ret++;
        }
        else{
            break;
        }
    }
    return ret;
}
void solve(){
    ll x;
    cin>>x;
    ll xx = x;
    int ans = 0;
    for(ll i = 2;i*i<=xx;i++){
        int cnt = 0;
        while(x%i==0){
            x/=i;
            cnt++;
        }
        ans += f(cnt);
    }
    if(x!=1)ans++;
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    scanf("%d",&t);
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define X ios_base::sync_with_stdio(false); cin.tie(NULL);
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<bool> VB;
typedef vector<string> VS;
typedef pair<ll, ll> pl;
typedef unordered_map<ll, ll> UMP;
#define FOR(i,b) for(i=0;i<b;i++)
#define pb push_back
#define mp make_pair
 
vector<pair<ll,ll>> dirx{mp(1,0),mp(0,1),mp(-1,0),mp(0,-1)};
vector<char> dir{'R', 'D','L','U'};

int main(){
    ll n,i,j;
    cin>>n;
    ll mx = n+7;
    VL spf(mx);
    FOR(i,mx){
        spf[i] = i;
    }
    for(i=2;i<mx;i++){
        if(i==spf[i]){
            for(j=i*i;j<mx;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
    // debug(spf);
    ll ans=0;
    for(i=1;i<=n;i++){
        j = i;
        // debug(i);
        ll k = i;
        while(j>1){
            ll tmp = 0;
            ll x = spf[j];
            while(j%x==0){
                j = j/x;
                tmp+=1;
            }
            // debug(tmp,j);
            k = k*(tmp+1);
        }
        ans+=k;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 81352
n = int(input())
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = cum[i] + a[i]
l = 0
r = 0
count = 0
while(r < n or l < n):
    if r < n and (cum[r] - cum[l]) & a[r] == 0:
        r += 1
    else:
        count += r - l
        l += 1
print(count)


Measured memory_bytes: 23560
N=int(input())
X=list(map(int,input().split()))
X.sort()
ans=1000000000
for i in range(X[0],X[N-1]+1):
    tmp=0
    for j in range(N):
        tmp+=(i-X[j])**2
    if tmp<ans:
        ans=tmp
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct node{
	int key;
	node *next,*prev;
};

node *nil;

node* ls(int key){
	node *cur=nil->next;
	while(cur!=nil&&cur->key!=key){
		cur=cur->next;
	}
	return cur;
}

void init(){
	nil=(node*)malloc(sizeof(node));
	nil->next=nil;
	nil->prev=nil;
}

void pri(){
	node *cur=nil->next;
	int isf=0;
	while(1){
		if(cur==nil)break;
		if(isf++>0)printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}

void deln(node *t){
	if(t==nil)return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void delf(){
	deln(nil->next);
}

void dell(){
	deln(nil->prev);
}

void delk(int key){
	deln(ls(key));
}

void insert(int key){
	node *x=(node *)malloc(sizeof(node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}

int main(){
	int key,n,i;
	int size=0;
	char com[20];
	int np=0,nd=0;
	scanf("%d",&n);
	init();
	for(i=0;i<n;i++){
		scanf("%s%d",com,&key);
		if(com[0]=='i'){insert(key);np++;size++;}
		else if(com[0]=='d'){
			if(strlen(com)>6){
				if(com[6]=='F')delf();
				else if(com[6]=='L')dell();
			}else{
				delk(key);nd++;
			}
			size--;
		}
	}
	
	pri();
	return 0;
}


Measured memory_bytes: 34008
use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;
use std::str;


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let s: String = sc.read();
    let s = s.as_bytes();
    let n = s.len();
    // println!("{:?}", s);
    let k: usize = sc.read();
    let mut slices = Vec::new();
    for len in 1..cmp::min(k,n)+1 {
        for i in 0..n-len+1 {
            let j = i + len;
            slices.push(s[i..j].to_vec())
        }
    }
    slices.sort();
    // println!("{:?}", slices);
    let mut i = 1;
    let mut j = 0;
    while i < k {
        j += 1;
        if j == 0 || slices[j] != slices[j-1] {
            i += 1;
        }
    }
    let ans = str::from_utf8(&*slices[j]).unwrap();
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 6396
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll heights[100005];
ll dp[100005];

ll rec(ll x) {
	if(x > N - 1) {
		return 1e9;
	}
	if(x == N - 1) {
		return 0;
	}
	// if(x + 1 >= N) 
	ll &ans = dp[x];
	if(ans != -1) {
		return ans;
	}
	ans = min(abs(heights[x + 1] - heights[x]) + rec(x + 1), abs(heights[x + 2] - heights[x]) + rec(x + 2));
	// ans = min(ans, min(rec(x + 2), );
	return ans;
}


int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &heights[i]);
	}
	// memset(dp, -1, sizeof(dp));
	for(int i = 0; i < N; i++) {
		dp[i] = -1;
	}
	cout << rec(0ll) << " ";

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>

int f[20][20];

int main()
{
	int h,w;
	scanf("%d%d",&h,&w);
	for (int i = 0; i<=9; i++)
		for (int j = 0; j<=9; j++)
			scanf("%d",&f[i][j]);

	for (int k = 0; k<=9; k++)
		for (int i = 0; i<=9; i++)
			for (int j = 0; j<=9; j++)
				f[i][j] = std::min(f[i][j],f[i][k] + f[k][j]);

	int ans = 0;
	for (int i = 1; i<=h; i++)
		for (int j = 1; j<=w; j++)
		{
			int x;
			scanf("%d",&x);
			if (x>=0)
				ans += f[x][1];
		}

	printf("%d",ans);

	return 0;
}

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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int count=0;
  for (int i=0;i<N-1;i++){
    if(!(S.at(i)==S.at(i+1))){
      count++;
    }
  }
  cout <<count+1<<endl;
  return 0;
}

    
      
  
  

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> X;
  int x;
  int min = 0;
  int max = 0;
  int P = 0;
  int SP = 0;
  for(int i = 0;i < N;++i){
    cin >> x;
    P += x;
    X.push_back(x);

  }


  P /= N;
  int hp = 1;
  int hp2 = 1;
  int ans = 0;
  int ans2 = 0;
  for(int i = 0;i < N;++i){
    hp = (X[i] - P) *(X[i] - P);
    hp2 = (X[i] - (P+1)) *(X[i] - (P+1));
    ans += hp;
    ans2 += hp2;
    
  }
  if(ans <= ans2){
  cout << ans << endl;
  
  }
  if(ans > ans2){
    cout << ans2 << endl;
    
  }


  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace dotnet_test
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var hw =
                Console.ReadLine()
                .Split(' ')
                .Select(Int64.Parse)
                .ToArray();
            Int64 H = hw[0], W = hw[1];

            Int64 ret;
            if (H == 1 || W == 1)
            {
                ret = 1;
            }
            else if (W * H % 2 == 0)
            {
                ret = W * H / 2;
            }
            else
            {
                ret = (W * H + 1) / 2;
            }
            /*else
            {
                ret =
                ((W + 1) / 2) * ((H + 1) / 2)
                + (W / 2) * (H / 2);
            }
            */
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;


class DP{
public:
	int cost, x, rest;
	
	DP(){}
	DP(int xx, int rr, int cc){
		cost = cc;x=xx;rest=rr;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};

struct Edge{
	int to, dist, risk;
};
unsigned int visit[200][200];
int N, M, L;
main(){
	int i,j;
	while(cin >> N >> M >> L, N){
		memset(visit, -1, sizeof(visit));
		vector<Edge> E[200];
		for(i=0;i<M;i++){
			int a;
			Edge e;
			cin >> a >> e.to >> e.dist >> e.risk;
			E[a].push_back(e);
			swap(a, e.to);
			E[a].push_back(e);
		}
		priority_queue<DP> dp;
		DP S;
		dp.push(DP(1, L, 0));
		while(!dp.empty()){
			S = dp.top();
			dp.pop();
			if(S.x == N) break;
			for(i=0;i<E[S.x].size();i++){
				DP T=S;
				T.x = E[S.x][i].to;
				T.cost += E[S.x][i].risk;
				
				if(visit[T.x][T.rest] > T.cost){
					visit[T.x][T.rest] = T.cost;
					dp.push(T);
				}
				
				T.cost = S.cost;
				T.rest -= E[S.x][i].dist;
				if(T.rest >= 0 && visit[T.x][T.rest] > T.cost){
					visit[T.x][T.rest] = T.cost;
					dp.push(T);
				}
			}
		}
		cout << S.cost << endl;
	}
	return 0;
}

Measured memory_bytes: 1612
import numpy as np 
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            a[i][j] = 1
        else:
            a[i][j] = 0

a = np.array(a)

while True:
    flag = True
    for i in range(len(a)-1, -1, -1):
        if sum(a[i]) == 0:
            a = np.delete(a, i, 0)
            flag = False

    a = a.T
    for i in range(len(a)-1, -1, -1):
        if sum(a[i]) == 0:
            a = np.delete(a, i, 0)
            flag = False
    a = a.T

    if flag:
        break

ans = [['#']*len(a[0]) for _ in range(len(a))]
for i in range(len(a)):
    for j in range(len(a[i])):
        if a[i][j] == 0:
            ans[i][j] = '.'

for i in range(len(a)):
    for j in range(len(a[i])):
        print(ans[i][j], end="")
    print()


Measured memory_bytes: 13916
#include <iostream>
using namespace std;
int main(){
  int D,N;
  cin>>D>>N;
  if(N==100){
    N=101;
  }
if(D==0){
  cout<<N<<endl;
}else if(D==1){
  cout<<100*N<<endl;
}else{
  cout<<100*100*N<<endl;
}
  return 0;
}


Measured memory_bytes: 256
n, a, b = list(map(int, input().split()))

ans = 0
for i in range(n+1):
    one = i%10
    ten = i//10%10
    hund = i//100%10
    thou = i//1000%10
    man = i//10000%10
    summ = man+thou+hund+ten+one
    if a <= summ <= b:
        ans += i
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();

        do {
            if (n < 0) {
                sb.append(-n % 2);
                n = (n + n % 2) / -2;
            } else {
                sb.append(n % 2);
                n = n / -2;
            }
        } while (n != 0);
        System.out.println(sb.reverse().toString());
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n, 0);
    int wa = 0, ac = 0;
    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if (cnt[p] == -1) continue;
        if (s == "WA") {
            cnt[p]++;
        } else {
            wa += cnt[p];
            cnt[p] = -1;
            ac++;
        }
    }
    for (int i = 0; i < n; ++i) {
        
    }
    cout << ac << " " << wa << "\n";
    return 0;
}

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

int main(void){
	char bl[256];
	int num;
	int A,B,O,AB;
	
	memset(bl,'\0',sizeof(bl));
	A = B = O = AB = 0;
	
	
	while(scanf("%d,%s",&num,bl)!=EOF){
		if(!strcmp(bl,"A")){
			A++;
		}else if(!strcmp(bl,"B")){
			B++;
		}else if(!strcmp(bl,"O")){
			O++;
		}else if(!strcmp(bl,"AB")){
			AB++;
		}
	}
	
	printf("%d\n%d\n%d\n%d\n",A,B,AB,O);
	
	return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MAXN 100005
#define mod 1000000007
#define inf LLONG_MAX/3
using namespace std;

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

ll power(ll x,ll y,ll m=mod)
{
  ll ans = 1;
  while(y>0)
  {
    if(y&1)
    {
      ans = (ans*x)%m;
    }
    x = (x*x)%m;  
    y /= 2;
  }
  return ans%m;
}

ll modInverse(ll a, ll m=mod) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        ll q = a / m; 
        ll t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 

ll get(string s)
{
  ll res = 0;
  for(int i=0;i<s.length();i++)
  {
    res += s[i]-'0';
    res *= 10;
  }
  return res/10;
}


int main()
{
  // #ifndef ONLINE_JUDGE 
  // freopen("input.txt", "r", stdin); 
  // #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll t=1;
  // cin>>t;
  while(t--)
  {
    ll n,m,i,j,ans=0;
    ll a[3][3],mark[3][3];
    map<ll,pll> mp;
    for(i=0;i<3;i++)
    {
      for(j=0;j<3;j++)
      {
        cin>>a[i][j];
        mark[i][j] = 0;
        mp[a[i][j]] = {i,j};
      }
    }
    cin>>n;
    while(n--)
    {
      cin>>m;
      if(mp.find(m)!=mp.end())
      {
        auto it = mp.find(m);
        mark[it->second.first][it->second.second] = 1;
      }
    }
    for(i=0;i<3;i++)
    {
      for(j=0;j<3;j++)
      {
        a[i][j] = mark[i][j];
        // cout<<mark[i][j]<<" ";
      }
      // cout<<"\n";
    }
    if(a[0][0]+a[0][1]+a[0][2]==3 || a[1][0]+a[1][1]+a[1][2]==3 || a[2][0]+a[2][1]+a[2][2]==3 ||
      a[0][0]+a[1][0]+a[2][0]==3 || a[0][1]+a[1][1]+a[2][1]==3 || a[0][2]+a[1][2]+a[2][2]==3 ||
      a[0][0]+a[1][1]+a[2][2]==3 || a[0][2]+a[1][1]+a[2][0]==3)
    {
      cout<<"Yes";
    }
    else
    {
      cout<<"No\n";
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int i,h, w;
	char a[100][101];

	scanf("%d%d", &h, &w);
	
	for (i = 0; i < h; i++)
		scanf("%s", a[i]);

	for (i = 0; i < w+2; i++)
		printf("#");
	printf("\n");

	for (i = 0; i < h; i++)
	{
		printf("#%s#", a[i]);
		printf("\n");
	}

	for (i = 0; i < w+2; i++)
		printf("#");
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <string>
#include <queue>
using namespace std;

int main(){
	int N, Q;
	while(cin >> N >> Q, N|Q){
		int p_max = 0;
		vector<int> date(110);
 		for(int i=0; i<N; i++){
 			int M; cin >> M;
 			for(int j=0; j<M; j++){
 				int d; cin >> d;
 				date[d]++;
 				p_max = max(p_max, date[d]);
 			}
		}
		if(p_max < Q){
			cout << 0 << endl;
		}else{
			for(int i=0; i<110; i++){
				if(date[i]==p_max){
					cout << i << endl;
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 3084
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

from copy import deepcopy

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

cnt=0
for i in range(m):
  uf=UnionFind(n)
  ll=deepcopy(l)
  del ll[i]
  for a,b in ll:
    a-=1
    b-=1
    uf.union(a,b)
  if uf.group_count()>=2:
    cnt+=1
print(cnt)

Measured memory_bytes: 3444
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,b=get_f
puts ((a+b)/2.0).ceil

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), k(m);
  for (int i = 0; i < m; i++) {
    int b;
    cin >> a[i] >> b;
    for (; b > 0; b--) {
      int c;
      cin >> c;
      k[i] |= 1 << c - 1;
    }
  }
  vector<vector<int>> dp(m + 1, vector<int>(1 << n, 1e9));
  dp[0][0] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < (1 << n); j++) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      dp[i + 1][j | k[i]] = min(dp[i + 1][j | k[i]], dp[i][j] + a[i]);
    }
  }
  cout << (dp[m][(1 << n) - 1] != int(1e9) ? dp[m][(1 << n) - 1] : -1) << endl;
}


Measured memory_bytes: 16384
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    r, D, x = i2nn()
    for i in range(10):
        x = r * x - D
        print(x)

main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,m,n;
while(cin>>n){
   i=0;
   while(n>0){
    if(n%10==7) i++;
        n/=10;
   }
   if(i>0)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
} return 0;
}


Measured memory_bytes: 3624
def main():
    N,W = map(int, input().split())
    w,v = [0]*N,[0]*N
    for i in range(N):
        w[i],v[i] = map(int, input().split())
    # dp[i][w] := 容量をwとして荷物0~iの中から荷物を選んだ時の価値の最大値
    # ではなく...
    # dp[i][v] := 荷物0~iの中から荷物を選んで価値vを超える時の重さ合計の最小値
    # 初期値dp[0][v] = 0の重さ(もし0の価値がvを超えないならINF)
    V = N*max(v)
    INF = float('inf')
    dp = [[INF]*(V+1) for i in range(N)]
    for x in range(V+1):
        dp[0][x] = INF if x>v[0] else w[0]
    dp[0][0] = 0
    for i in range(N-1):
        for j in range(V+1):
            if j>=v[i+1]:
                # i+1番目を選ぶ
                dp[i+1][j] = min(dp[i+1][j], (dp[i][j-v[i+1]])+w[i+1])
            # i+1番目を選ばない
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])

    # dp[N-1]のうちW以下であるものの価値の最大値
    for val in range(V,-1,-1):
        if dp[-1][val]<=W:
            print(val)
            break
main()


Measured memory_bytes: 304528