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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll INF = (1ll << 60);

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

    ll N;
    cin >> N;
    vector<pll> t(N);
    REP(i, N){
    	cin >> t[i].first >> t[i].second;
    	if(t[i].first > t[i].second) swap(t[i].first, t[i].second);
    }
    ll res = INF;

    ll rmi = INF, bmi = INF, rma = -1, bma = -1;
    ll mind, mand;
    REP(i, N){
    	if(rmi > t[i].first){
    		rmi = t[i].first;
    		mind = i;
    	}
    	rma = max(rma, t[i].first);
    	bmi = min(bmi, t[i].second);
    	if(bma < t[i].second){
    		bma = t[i].second;
    		mand = i;
    	}
    }
    res = min(res, (bma - bmi)*(rma - rmi));

    if(mind == mand){
    	cout << res << endl;
    }else{
    	ll mihaba = INF;
    	multiset<ll> st;
    	st.insert(t[mind].second);
    	st.insert(t[mand].first);
    	vector<pll> x;
    	REP(i, N){
    		if(i != mind && i != mand){
    			x.push_back(t[i]);
    			st.insert(t[i].first);
    		}
    	}
    	sort(x.begin(), x.end());

    	ll ue = *(--st.end());
    	ll shita = *(st.begin());
    	mihaba = min(mihaba, ue - shita);
    	REP(i, x.size()){
    		st.erase(st.find(x[i].first));
    		st.insert(x[i].second);
    		/*
    		for(auto xx :st) cout << xx << " ";
    		cout << endl;
    		*/
    		ue = *(--st.end());
    		shita = *(st.begin());
    		mihaba = min(mihaba, ue - shita);
    	}
    	res = min(res, (bma - rmi)*mihaba);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 16748
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <random>
using namespace std;

const int N_MAX = 1e+5;
int N;
int a[N_MAX];
int b[N_MAX];
int c[N_MAX];
int dp[3][N_MAX];

int elapseA(int i);
int elapseB(int i);
int elapseC(int i);

int elapseA(int i)
{
	if (i == N) return 0;
	if (dp[0][i] != -1) return dp[0][i];

	int max_happiness = a[i] + max(elapseB(i+1), elapseC(i+1));
	return dp[0][i] = max_happiness;
}
int elapseB(int i)
{
	if (i == N) return 0;
	if (dp[1][i] != -1) return dp[1][i];

	int max_happiness = b[i] + max(elapseA(i+1), elapseC(i+1));
	return dp[1][i] = max_happiness;
}
int elapseC(int i)
{
	if (i == N) return 0;
	if (dp[2][i] != -1) return dp[2][i];

	int max_happiness = c[i] + max(elapseA(i+1), elapseB(i+1));
	return dp[2][i] = max_happiness;
}

int main ()
{
	cin >> N;
	for (int i=0; i<N; ++i)
	{
		cin >> a[i] >> b[i] >> c[i];
		dp[0][i] = -1;
		dp[1][i] = -1;
		dp[2][i] = -1;
	}
	
	cout << max({elapseA(0), elapseB(0), elapseC(0)}) << endl;
	return 0;
}

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

int main(){
  int X, Y;
  cin >> X >> Y;
  long long ans = 0, a[] = {-1, 300000, 200000, 100000};
  for(int i = 1; i <= 3; ++i){
    if(X == i) ans += a[i];
    if(Y == i) ans += a[i];
  }
  if(X == 1 and Y == 1){
    ans += 400000;
  }
  cout << ans << endl;
}


Measured memory_bytes: 768
#include <stdio.h>
int main(void){
    char a[1200]={};
    int i=0;
     
    while(1){
        scanf("%c", &a[i]);
        if (a[i]==0){
            break;
        }
        else if (a[i]>='a' && a[i]<='z'){
            a[i]=a[i]-32;
        }
        else if(a[i]>='A' && a[i]<='Z'){
            a[i]=a[i]+32;
        }
        printf("%c", a[i]);
        i++;
    }
    return 0;
}


Measured memory_bytes: 2032
import math
A,B=map(int,input().split())
a=set(range(math.ceil(A/0.08),int((A+1)/0.08)))
b=set(range(math.ceil(B/0.1),int((B+1)/0.1)))
s=a&b
print(min(a&b) if len(s)>0 else -1)

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define sz(a) (int)(a).size()
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int cas=1;
int fa[maxn];
int Find(int x) {
    return fa[x] == x ? x : fa[x] = Find(fa[x]);
}
priority_queue<int,vector<int>,greater<int> >q[maxn], pp;
int a[maxn];
int vis[maxn];
void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0 ; i < n ; i ++) fa[i] = i;
    for (int i = 0 ; i < n ; i ++) scanf("%d", a+i);
    for (int i = 1 ; i <= m ; i ++) {
        int u, v;
        scanf("%d%d", &u, &v);
        u = Find(u);
        v = Find(v);
        fa[u] = v;
    }
    int k = 0;
    for (int i = 0 ; i < n ; i ++) {
        int tmp = Find(i);
        if (!vis[tmp]) {
            vis[tmp] = ++k;
            q[k].push(a[i]);
        }
        else q[vis[tmp]].push(a[i]);
    }
    if (k == 1) {
        printf("0\n");
        return ;
    }
    ll ans = 0;
    for (int i = 1 ; i <= k ; i ++) {
        if (q[i].empty()) continue;
        ans += q[i].top();
        q[i].pop();
        while(!q[i].empty()) {
            pp.push(q[i].top());
            q[i].pop();
        }
    }
    int sum = k - 2;
    int flag = 1;
    while(sum--) {
        if (pp.empty()) {
            flag = 0;
            break;
        }
        ans += pp.top();
        pp.pop();
    }
    if (!flag) printf("Impossible\n");
    else printf("%lld\n", ans);
}
int main()
{
    // freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n, m;
    cin >> n >> m;
    {
        int a = 1, b = m + 1;
        for (int i = m; i >= 1; i -= 2) {
            assert(b <= n);
            cout << a << " " << b << endl;
            a++;
            b--;
        }
    }
    {
        int a = m + 2, b = 2 * m + 1;
        for (int i = m - 1; i >= 1; i -= 2) {
            assert(b <= n);
            cout << a << " " << b << endl;
            a++;
            b--;
        }
    }
}


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

ll n,m,k,ans=0,w;
ll a[200004],b[200004];
int main() {
  cin >>n>>m>>k;
  rep(i,n){
    cin>>a[i];
    if(i!=0) a[i]+=a[i-1];
  }
  rep(i,m){
    cin>>b[i];
    if(i!=0)b[i]+=b[i-1];
  }
  for(ll i=0;i<=n;i++){
    if(k>=a[i]){
      w=upper_bound(b+1,b+1+m,k-a[i])-b-1;
      ans=max(ans,w+i);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6792
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<iostream>
#define rep(i,x,y) for(int i=x;i<y;i++)
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int>X(N),Y(N);
  rep(i,0,N)cin>>X[i];
  rep(i,0,N){
    Y[i]=X[i];
  }
  sort(Y.begin(),Y.end());
  rep(i,0,N){
    int z=Y[N/2];
    if(X[i]<z){
      cout<<Y[N/2]<<endl;
    }
    else{
      cout<<Y[N/2-1]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 1e5 + 10;

struct UnionFind{
	vector<int> par;

	UnionFind(int n){
		par = vector<int>(n);
		rep(i, n) par[i] = i;
	}

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

	void unite(int x, int y){
		par[find(x)] = find(y);
	}
};

int p[N], qv[N];
char qc[N];

int main(){
	int n, q;
	while (cin >> n >> q, n){
		FOR(i, 1, n) cin >> p[i], --p[i];
		set<int> ok;
		rep(i, q){
			cin >> qc[i] >> qv[i], --qv[i];
			if (qc[i] == 'M'){
				if (ok.count(qv[i])) qv[i] = -1;
				else ok.insert(qv[i]);
			}
		}

		UnionFind uf(n);

		rep(i, n) if (!ok.count(i)) uf.unite(i, p[i]);

		ll ans = 0;
		for (int i = q - 1; i >= 0; --i){
			if (qv[i] < 0) continue;
			if (qc[i] == 'M'){
				uf.unite(qv[i], p[qv[i]]);
			}
			else{
				ans += uf.find(qv[i]) + 1;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 4164
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

typedef long long ll;

const int kMod = 1e9 + 7, kMaxN = 2e5 + 5;
int h, w, a, b;
ll fact[kMaxN], rfact[kMaxN];

ll QuickPow(ll x, ll y, ll p = kMod) {
  ll ret = 1;
  for (; y; y >>= 1, x = x * x % p)
    if (y & 1) ret = ret * x % p;
  return ret;
}

inline ll Combin(ll n, ll m) {
  return fact[n] * rfact[n - m] % kMod * rfact[m] % kMod;
}

int main() {
  ios::sync_with_stdio(false);
  cin >> h >> w >> a >> b;
  fact[0] = rfact[0] = 1;
  for (int i = 1; i < kMaxN; ++i)
    fact[i] = 1LL * fact[i - 1] * i % kMod;
  rfact[kMaxN - 1] = QuickPow(fact[kMaxN - 1], kMod - 2);
  for (int i = kMaxN - 2; i >= 0; --i)
    rfact[i] = 1LL * rfact[i + 1] * (i + 1) % kMod;
  ll sum = 0;
  for (int i = 0; i < w - b; ++i) {
    ll former = Combin(b + h - a - 1 + i, b + i), latter = Combin(a + w - b - 2 - i, w - b - 1 - i);
    sum += former * latter % kMod;
    sum %= kMod;
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
  int n; cin >> n;
  long long y; cin >> y;
  int ans = 0;
  long long temp = 0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      temp = y - (10000*i + 5000*j);
      if(temp < 0){
        break;
      }
      int k = temp / 1000;
      if(k == n-i-j){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        exec();
    }

    private static void exec() {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        // 借金額
        float debt = 100000;

        // n週間後の借金残高計算
        for (int i = 0; i < n; i++) {

            // 利子5%を追加
            debt = debt + (debt / 20);

            // 借金の1000円未満切り上げ
            BigDecimal bd1 = new BigDecimal(debt / 1000);
            BigDecimal bd2 = bd1.setScale(0, BigDecimal.ROUND_UP);
            debt = bd2.intValue() * 1000;
        }

        System.out.println((int) debt);
    }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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

// 参考: https://drken1215.hatenablog.com/entry/2020/03/10/160500

ll n;
vll a;

ll solve(){
  vvll dp(n+1, vll(n+1, -n));
  for(ll i=0; i<=n; i++){
    dp[i][i]=0;
    if(i<n) dp[i][i+1]=0;
  }
  
  for(ll len=2; len<=n; len++){
    for(ll i=0; i+len<=n; i++){
      ll j=i+len; // 右端
      
      // dpの遷移は以下の2パターンが考えられる
      
      // 1) [i,j-1]の両端以外が消せて、両端が残るパターン
      // この場合は残った両端で消せるなら全消し、無理なら2個残る状態となる
      if(dp[i+1][j-1]==j-i-2){
        if(abs(a[i]-a[j-1])<=1) dp[i][j]=j-i;
        else chmax(dp[i][j],dp[i+1][j-1]);
      }
      
      // 2) あるkが存在して、[i,k), [k,j)を独立に操作して回数の最大値を求める場合
      // 2つの区間に分けてそれぞれが全消しできるパターンも当然存在する
      for(ll k=i+1; k<j-1; k++){
        chmax(dp[i][j], dp[i][k]+dp[k][j]);
      }
    }
  }
  
  return dp[0][n];
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  while(cin>>n, n){
    a.resize(n);
    rep(i,n) cin>>a[i];
    cout<<solve()<<endl;
  }
  
}


Measured memory_bytes: 3668
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  std::uint32_t N;
  std::cin >> N;

  std::uint32_t t = INF;

  std::vector<std::int32_t> xs(N);
  std::vector<std::int32_t> ys(N);
  std::vector<std::int64_t> hs(N);
  for (auto i = 0ul; i < N; ++i) {
    std::cin >> xs[i] >> ys[i] >> hs[i];
    if (t == INF && hs[i] >= 1) t = i;
  }

  for (auto cy = 0; cy <= 100; ++cy) {
    for (auto cx = 0; cx <= 100; ++cx) {
      // h_t = H − |x_t − c_x| − | y_t − c_y|
      // h   = h_t + |x_t − c_x| + | y_t − c_y|
      const auto h = hs[t] + std::abs(xs[t] - cx) + std::abs(ys[t] - cy);
      if (h < 1) continue;

      bool f = true;
      for (auto i = 0ul; i < N; ++i) {
        f = f && (std::max(h - std::abs(xs[i] - cx) - std::abs(ys[i] - cy), 0l) == hs[i]);
      }
      if (f) {
        std::cout << cx << ' ' << cy << ' ' << h << std::endl;
        return 0;
      }
    }
  }

  return -1;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
	int N,M;
	for(;cin>>N>>M,N;){
		string file;
		set<string>files;
		set<string>directories;
		for(;N--;){
			cin>>file;
			files.insert(file);
			for(int i=file.size()-1;i>=0;i--){
				if(file[i]=='/'){
					file.resize(i);
					directories.insert(file);
				}
			}
		}
		for(;M--;){
			bool fail=false;
			vector<string>v(2);
			for(int _=0;_<2;_++){
				int prev=1;
				cin>>file;
				if(directories.find(file)!=directories.end())file+="/";
				for(int i=1;i<file.size();i++){
					if(file[i]=='/'){
						if(file.substr(prev,i-prev)=="."){
						}else if(file.substr(prev,i-prev)==".."){
							int j=v[_].size()-1;
							for(;j>=0;j--){
								if(v[_][j]=='/'){
									v[_].resize(j);
									break;
								}
							}
							if(j<0){
								fail=true;
								break;
							}
						}else{
							v[_]+="/";
							v[_]+=file.substr(prev,i-prev);
							if(directories.find(v[_])==directories.end()){
								fail=true;
								break;
							}
						}
						prev=i+1;
					}
				}
				if(file.size()>prev){
						int i=file.size();
						if(file.substr(prev,i-prev)=="."){
						}else if(file.substr(prev,i-prev)==".."){
							int j=v[_].size()-1;
							for(;j>=0;j--){
								if(v[_][j]=='/'){
									v[_].resize(j);
									break;
								}
							}
							if(j<0){
								fail=true;
								//break;
							}
						}else{
							v[_]+="/";
							v[_]+=file.substr(prev,i-prev);
							//if(directories.find(v[_])==directories.end()){
							//	fail=true;
							//	break;
							//}
						}
				}
				if(directories.find(v[_])!=directories.end())v[_]+="/index.html";
				if(files.find(v[_])==files.end())fail=true;
			}
			if(fail)cout<<"not found"<<endl;
			else if(v[0]==v[1])cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}
	}
}

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

void call(int);

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

}

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <utility>

using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;

constexpr int nil = -1;

class Graph
{
public:

    Graph(int n)
        : e(n)
    {}

    void connect(int from, int to, bool isTwoWay = true)
    {
        e[from].push_back(to);
        if (isTwoWay)
            e[to].push_back(from);
    }

    vi getComponentGroup() const
    {
        vi group {vi(e.size(), nil)};
        int id = 0;

        for (int i = 0; i < e.size(); ++i)
        {
            if (group[i] != nil)
                continue;

             grouping(group, i, id++);
        }

        return group;
    }

private:
    vvi e;

    void grouping(vi& group, int vertex, int groupId) const
    {
        if (group[vertex] != nil)
            return;

        group[vertex] = groupId;

        for (auto v : e[vertex])
            grouping(group, v, groupId);
    }
};

void solve()
{
    using namespace std;

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

    Graph g {n};

    for (int i = 0, v1, v2; i < m; ++i)
    {
        cin >> v1 >> v2;
        g.connect(v1, v2);
    }

    auto group = g.getComponentGroup();

    int q;
    cin >> q;

    for (int i = 0, v1, v2; i < q; ++i)
    {
        cin >> v1 >> v2;
        cout << (group[v1] == group[v2] ? "yes" : "no") << endl;
    }
}

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


Measured memory_bytes: 10664
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.length() == 2)
      System.out.println(s);
    else{
      StringBuffer sb = new StringBuffer(s);
      s = sb.reverse().toString();
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 23124
// not completed
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main() {
    int n;
    map<string, int> abc;
    cin >> n >> abc["A"]>> abc["B"] >> abc["C"];
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    vector<string> ans;
    string t1, t2;
    for (int i = 0; i < n; i++) {
        t1 = s[i].substr(0, 1);
        t2 = s[i].substr(1, 2);
        if (abc[t1] == 0 && abc[t2] == 0) {
            cout << "No" << endl;
            break;
        } else if (abc[t1] < abc[t2]) {
            abc[t1]++;
            abc[t2]--;
            ans.push_back(t1);
        } else if (abc[t1] > abc[t2]) {
            abc[t1]--;
            abc[t2]++;
            ans.push_back(t2);
        } else if (abc[t1] == abc[t2]) {
            if (i != n - 1) {
                string t1_next = s[i + 1].substr(0, 1);
                string t2_next = s[i + 1].substr(1, 2);
                if (t1 == t1_next || t1 == t2_next) {
                    abc[t1]++;
                    abc[t2]--;
                    ans.push_back(t1);
                } else {
                    abc[t1]--;
                    abc[t2]++;
                    ans.push_back(t2);
                }
            } else {
                abc[t1]++;
                abc[t2]--;
                ans.push_back(t1);
            }

        }
    }

    if (ans.size() == n) {
        cout << "Yes" << endl;
        for (int i = 0; i < n; i++) {
            cout << ans[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 10556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<string>> mps(n+1);
    for(int i=0; i<m; i++)
    {
        int num;
        string s;
        cin >> num >> s;
        mps.at(num).push_back(s);
    }
    int pena = 0;
    int acs = 0;
    for(auto &vs : mps)
    {
        int p = 0;
        for(auto &s : vs)
        {
            if(s == "WA") p++;
            else if(s == "AC")
            {
                acs++;
                pena += p;
                break;
            }
        }
    }
    cout << acs << " " << pena << endl;
    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#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(){
    double P1_x, P1_y, P2_x, P2_y, d;
    cin >> P1_x >> P1_y >> P2_x >> P2_y;
    d = sqrt(pow((P2_x-P1_x),2)+pow((P2_y-P1_y),2));
    printf("%f", d);
    return 0;
}


Measured memory_bytes: 3184
/**
ABC079
2019/03/25/ 自力AC
**/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    string s;
    cin >> s;

    if(s[1] == s[2]){
        if(s[0] == s[1] || s[1] == s[3]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef unordered_map<ll, ll> ump;

const ll mod = 1e9+7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	cout << n/3 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,high=0,middle=0,low=0,i;
	for(i=0;i<10;i++){
		scanf("%d",&a);
		if(a > high){
			low = middle;
			middle = high;
			high = a;
		}
		else if(a > middle){
			low = middle;
			middle = a;
		}
		else if(a > low){
			low =a;
		}
	}
	printf("%d\n%d\n%d\n",high,middle,low);
	return 0;
}

Measured memory_bytes: 0
//b.c B-Digital Gifts
#include<stdio.h>
#include<string.h>

typedef struct{
    double x;
    char u[3];
}gift;

int main(void){
    int n;
    scanf("%d",&n);
    gift buf[n];
    for(int i=0;i<n;++i){
        scanf("%lf %s",&buf[i].x,buf[i].u);
    }

    double ans = 0;
    for(int i=0;i<n;++i){
        if(strcmp(buf[i].u,"JPY")==0){
            ans += buf[i].x;
        }else{
            ans += 380000.0 * buf[i].x;
        }
    }

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

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

constexpr ll MAX = 10000000000000;

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

    int N;
    cin >> N;
    vll A(N);
    for(int i=0;i<N;i++) cin >> A[i];

    vll sums(N+1, 0);
    for(int i=0;i<N;i++) sums[i+1] = sums[i] + A[i]; 

    vll dprow(N+1, 0);
    vvll dp(N+1, dprow);

    for(int w=2;w<=N;w++) {
        for(int i=0;i<=N-w;i++) {
            dp[i][i+w] = MAX;
            for(int x=1; x<w; x++) {
                dp[i][i+w] = min(dp[i][i+w], 
                                 dp[i][i+x] + dp[i+x][i+w] + sums[i+w] - sums[i]);
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> v;
  int sum = 0;
  rep(i,N){
    int a;
    cin >> a;
    sum += a;
    v.push_back(a);
  }

  int cnt = 0;
  rep(i,N){
    int a = v[i];
    if(4*M*a<sum);
    else cnt++;
  }

  if(cnt >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
  int n, k;
  double ans = 0.0;

  scanf("%d %d", &n, &k);

  for (int i=1; i<=n; ++i) {
    ans += pow(0.5, ceil(fmax(0.0, log2(k/(double)i))));
  }
  ans /= n;
  printf("%.12lf\n", ans);
  return 0;
}

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

int main(){
    string s;
  	cin >> s;
    int ri=s.size()-1,lf=0,count=0;
    while(ri-lf>=1){
        if(s.at(ri)!=s.at(lf)) count++;
      	ri--;lf++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib> 
 
using namespace std;
int main(){
	int N = 0;
  	long long ans = 0;
	cin >> N;
	long long  minA = 10000000000;
  	long long  a = 0;
	int nNegative = 0;
  	for(int i=0; i < N; ++i){
		cin >> a;
      	long long absA = std::abs(a);
      	if(a < 0) ++nNegative;
      	if(absA < minA) minA = absA;
		ans += absA;
    }
  
	if(nNegative%2) ans -= 2 * minA;
      
    cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007

template <class T>
T digitSum(T num) {
    T sum = 0;
    while (num != 0) {
        sum += num%10;
        num /= 10;
    }
    return sum;
}


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

    // input
    int N, cake, donuts;
    cin >> N;
    cake = N/4;
    donuts = N/7;
    
    // calculation
    int price;
    REP(i, cake+1) {
        REP(j, donuts+1) {
            price = i*4 + j*7;
            if (price == N) {
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }
    cout << "No" << "\n";
    
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n , k;
    cin >> n >> k;

    vector<int> a(n);
    for (int &x : a)
        cin >> x;


    auto sum = [&] (int n) {
        return n * (n + 1) / 2;
    };

    double exp = 0;
    for (int i = 0 ;i < k ;i++)
        exp += sum(a[i]) / double(a[i]);

    double mx = exp;
    for (int i = k ;i < n ;i++) {
        exp += sum(a[i]) / double(a[i]);
        exp -= sum(a[i - k]) / double(a[i - k]);
        mx = max(mx , exp);
    }

    cout << fixed << setprecision(12) << mx;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    vector<P> vec;
    int a[n];
    REP(i,n){
        cin >> a[i];
        vec.emplace_back(a[i], i);
    }
    sort(ALL(vec));
    cout << n * 2 - 1 << endl;
    if(vec[n - 1].first >= abs(vec[0].first)){
        for(int i = 1; i <= n; i++){
            cout << vec[n - 1].second + 1 << " " << i << endl;
        }
        for(int i = 1; i < n; i++){
            cout << i << " " << i + 1 << endl;
        }
    }else{
        for(int i = 1; i <= n; i++){
            cout << vec[0].second + 1 << " " << i << endl;
        }
        for(int i = n; i > 1; i--){
            cout << i << " " << i - 1 << endl;
        }
    }
    return 0;
}

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

int F(long long a){
  int count = 0;
  while(a > 0){
    count++;
    a /= 10;
  }
  return count;
}

int main() {
  long long N;
  cin >> N;
  long long ans = 10000000000000000;
  for(int i = 1; i <= sqrt(N); i++){
    long long k = N / i;
    if(k * i == N){
      if(ans > F(k)){
      ans = F(k);
      }
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    long long int x, y;
    long long int ans = 0;

    cin >> x >> y;

    if (labs(x) > labs(y)) {
        ans += labs(x) - labs(y);
    }
    else {
        ans += labs(y) - labs(x);
    }

    if (x >= 0 && y >= 0) {
        if (y == 0) {
            ans++;
        }
        else if (x > y) {
            ans += 2;
        }
    }
    else if (x >= 0 && y < 0) {
        ans++;
    }
    else if (x < 0 && y > 0) {
        ans++;
    }
    else if (x < 0 && y < 0) {
        if (x > y) {
            ans += 2;
        }
    }

    cout << ans << endl;
}


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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 100;
const int oo = 1e18;
const int mod  = 1e9 + 7;

int cnt = 0, k;
int a[200];

void btr(int pos, int len) {
    if(pos == len + 1) {
        cnt ++;
        if(cnt == k) {
            string res = "";
            FOR(i, 1, len) res += char('0' + a[i]);
            cout << res; exit(0);
        }
        return;
    }
    if(pos == 1) {
        FOR(i, 1, 9) {
            a[1] = i;
            btr(pos + 1, len);
        }
    } else {
        if(a[pos - 1] > 0) a[pos] = a[pos - 1] - 1, btr(pos + 1, len);
        a[pos] = a[pos - 1]; btr(pos + 1, len);
        if(a[pos - 1] < 9) a[pos] = a[pos - 1] + 1, btr(pos + 1, len);
    }
}

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);
    cin >> k;
    FOR(i, 1, 100) btr(1, i);
}


Measured memory_bytes: 256
S = input()


if len(S)%2 == 0:
    ans = "Yes"
    for i in range(len(S)//2):
        #print(S[2*i:2*i+2])
        if S[2*i:2*i+2] != "hi":
            ans = "No"
            break
    print(ans)
else:
    print("No")

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	a := nextLine()
	arr := strings.Split(a, " ")
	x, _ := strconv.Atoi(arr[0])
	y, _ := strconv.Atoi(arr[1])
	fmt.Println(x * y)
}


Measured memory_bytes: 1772
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, X;
    cin >> N >> X;

    ll minM = 1001;
    ll m;
    rep(i, N){
        cin >> m;
        X -= m;
        minM = min(minM, m);
    }

    cout << N + X / minM << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){

        int N,K;
        scanf("%d%d",&N,&K);//すぬけn人　お菓子k種類
        int d[K];
        int A[102][102];

        int count[102] = {0};

for(int i=0;i<K;i++){
        scanf("%d",&d[i]);
        for(int j=0;j<d[i];j++){
                scanf("%d",&A[i][j]);
//      printf("%d",A[i][j]);
                count[A[i][j]]++;
        }   
}

int ans = 0;
for(int i=1;i<=N;i++){
        if(count[i]==0){
                ans++;
        }   
}
printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1), B(N);
  for (int i = 0; i < N + 1; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  int64_t ans = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) + A.at(i + 1) <= B.at(i)) {
      ans += (A.at(i) + A.at(i + 1));
      A.at(i + 1) = 0;
    }
    else if (A.at(i) <= B.at(i)) {
      ans += B.at(i);
      A.at(i + 1) = A.at(i) + A.at(i + 1) - B.at(i);
    }
    else {
      ans += B.at(i);
    }
  }
  cout << ans << endl;
}
              

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

    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n){
        cin >> l[i];
    }

    int d = 0;
    int cnt = 1;
    for(int i=1; i<=n; ++i){
        d += l[i-1];
        if(d <= x){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n, k; cin >> n >> k;
    vector<int> d(11, 0);
    rep(i, k) {
        int x; cin >> x;
        d[x] = 1;
    }
    for(int i = n; i <= 100000; ++i) {
        string s = to_string(i);
        bool flag = true;
        rep(j, (int)s.size()) {
            if(d[s[j] - '0']) flag = false;
        }
        if(flag) {
            cout << i << endl;
            return;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int total_member =0 ;
  
  for(int i=0; i<N ;i++){
    int l;
    int r;
    cin >> l >> r;
    
    int member = r-l+1;
    
    total_member += member;
  }
  cout << total_member << endl;
  
}






Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        long ans = 0;
        
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            for(int j=i+1; j<N; j++){
                ans = ans+a[i]*a[j];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35724
n,q = map(int,input().split())
S = input()
b = [0]*(n+10)
for i in range(1,n):
	if S[i-1] == 'A' and S[i] == 'C':
		b[i] = 1
for i in range(1,n):
	b[i] += b[i-1]
for i in range(q):
	l,r = map(int,input().split())
	print(b[r-1]-b[l-1]) 

Measured memory_bytes: 7668
"""#################################################################
【ABC088】
C_Takahashi's Information
#################################################################"""

#インポート
import sys
from collections import Counter

#入力用
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))  #リスト(int型)
def MI(): return map(int, sys.stdin.readline().rstrip().split())        #多変数(int型)
def II(): return int(sys.stdin.readline().rstrip())                     # 1変数(int型)
def S(): return sys.stdin.readline().rstrip()                           #文字列(str型)

c = []
x = []
y = []
for _ in range(3):
    c.append(LI())
x.append(0) # x[0]=0と仮定
#y[0:2]の算出
for j in range(3):
    y.append(c[0][j] - x[0])
#x[1:2]の算出
for i in range(1, 3):
    x.append(c[i][0]-y[0])
#チェック
OK = True
for i in range(3):
    for j in range(3):
        if c[i][j] != x[i]+y[j]:
            OK = False
if OK == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include <stdio.h>

int main(void){
	int a[10];
	int a_i = 0;
	int x;
	int i;

	while(scanf("%d", &x) != EOF){
		a_i = 0;
		for(i=1; i <= 512; i = i << 1){
			if((x & i) == i){
				a[a_i] = i;
				a_i++;
			}
		}
		for(i=0; i < a_i-1; i++){
			printf("%d ", a[i]);
		}
		printf("%d\n", a[a_i-1]);
	}
	return 0;
}

Measured memory_bytes: 0
i = list(map(int, input().split()))
N = i[0]
M = i[1]
C = i[2]
B = list(map(int, input().split()))

A = [list(map(int, input().split())) for l in range(N)]
sum = 0
tom = 0
count = 0

for i in range(N):
  for j in range(M):
    sum = sum + (A[i][j] * B[j])
    if j == (M - 1):
      tom = sum + C
      if tom > 0:
        count = count + 1
        sum = 0
      else:
        sum = 0

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//ruogu_alter
int n, k;
vector<pii > v;
//
bool cmp(pii x, pii y) {
	return x.first + x.second < y.first + y.second;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n = getint(); k = getint();
	if (2 * k - 2 > n - 1) return !printf("%d\n", -1);
	int l = k + n, r = k + 2 * n - 1, mid = (l + r + 1) >> 1;
	for(int i = 0, p = mid; i < n; i++) {
		v.push_back(mp(k + i, p));
		if (p == r) p = l; else ++p;
	}
	sort(v.begin(), v.end(), cmp);
	rep(i, v.size()) printf("%d %d %d\n",v[i].first, v[i].second, k + 2 * n + i);
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void){
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[200010];
int main(){
	int n,ans=0,num=0;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		if(a[i]=='W')num++;
	}
	for(int i=n;i>=n-num+1;i--){
		if(a[i]=='R')ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3720
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    int N, i;
    scanf("%d", &N);
    for(i=0;i<3;i=i+1)
    {
        if(N%10==7)
        {
            printf("Yes\n");
            break;
        }
        else
        {
            N=N/10;
        }
    }
    if(i==3)
    {
        printf("No\n");
    }
}

Measured memory_bytes: 1660
s = list(input())
flg = "WA"
if s[0]=="A":
  if "C" in s[2:len(s)-1]:
    s.remove("A")
    s.remove("C")
    s = ''.join(s)
    if s.islower()==True:
      flg = "AC"
print(flg)

Measured memory_bytes: 9052
#include <iostream>

using namespace std;

int main()
{
int a,b;
cin>>a>>b;
if(a==b){
    for(int i=0;i<a;i++){
        cout<<b;
    }
}
else if(a>b){
    for(int i=0;i<a;i++){
        cout<<b;
    }
}
else if(a<b){
    for(int i=0;i<b;i++){
        cout<<a;
    }
}
return 0;
}


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

int main(){
    string a, b, c;
    cin >> a >> b >> c;

    int len_a = a.length();
    int len_b = b.length();
    int len_c = c.length();

    char k = 'a';

    while(1){
        if(k == 'a'){
            if(len_a == 0){
                break;
            }

            k = a[0];
            a.erase(0, 1);
            len_a--;
        }else if(k == 'b'){
            if(len_b == 0){
                break;
            }

            k = b[0];
            b.erase(0, 1);
            len_b--;
        }else{
            if(len_c == 0){
                break;
            }

            k = c[0];
            c.erase(0, 1);
            len_c--;
        }
    }

    if(k == 'a'){
        cout << "A" << endl;
    }else if(k == 'b'){
        cout << "B" << endl;
    }else{
        cout << "C" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
typedef long long ll;

int calc(vector<int> &cnt, int bits, int rest, int pos) {
	//cout << bits << "," << rest << endl;
	int ret = 0;
	for(int i = 3; i < rest; i++) {
		if(rest%i==0) {
			for(int j = pos; j < cnt.size(); j++) {
				if(cnt[j]>=(i-1)&&((bits&(1<<j))==0)) {
					ret += calc(cnt,bits|(1<<j),rest/i,j+1);
				}
			}
		}
	}
	for(int i = pos; i < cnt.size(); i++) {
		if(cnt[i]>=(rest-1)&&(((bits&(1<<i))==0))) {
			ret++;
		}
	}
	//cout << bits << "," << rest << " = " << ret << endl;
	return ret;
}

int main() {
	int n;
	cin >> n;
	unordered_map<int,int> mp;
	for(int i = 2; i <= n; i++) {
		int temp = i;
		while(temp>1) {
			for(int j = 2; j <= i; j++) {
				if(temp%j==0) {
					temp/=j;
					mp[j]++;
					break;
				}
			}
		}
	}
	vector<int> cnt;
	for(pair<int,int> p : mp) {
		//cout << "  " << (p.first) << "," << (p.second) << endl;
		cnt.push_back(p.second);
	}
	sort(cnt.begin(),cnt.end());
	cout << calc(cnt,0,75,0) << endl;
	return 0;
}


Measured memory_bytes: 256
//  Created by conan1024hao on 2019/11/19.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c;
    string s;
    cin>>s;
    a=1000*(s[0]-'0')+100*(s[1]-'0')+10*(s[2]-'0')+s[3]-'0';
    b=10*(s[5]-'0')+s[6]-'0';
    c=10*(s[7]-'0')+s[9]-'0';
    if(a<2019)
        cout<<"Heisei"<<endl;
    else if(a>2019)
        cout<<"TBD"<<endl;
    else if(b<=4)
        cout<<"Heisei"<<endl;
    else
        cout<<"TBD"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256