akhauriyash/Code-Regression huggingface dataset:
from collections import deque
n, m = map(int, input().split())
K = []
S = []
for i in range(m):
    ks = deque(list(map(int, input().split())))
    K.append(ks.popleft())
    S.append(ks)
P = list(map(int, input().split()))
ans = 0

for i in range(2 ** n):
    flg = False
    for j in range(m):
        count = 0  # j番目の電球に繋がるONスイッチの個数
        
        for k in range(K[j]):
            l = (n - S[j][k])  # 後ろから何番目か
            if ((i >> l) & 1):  # k番目のスイッチフラグがONかどうか(1かどうか)
                count += 1
        if count % 2 != P[j]:
            flg = True
            break  # Offの電球が１個でもある時点でループ抜ける
    if flg:
        continue
    ans += 1

print(ans)


Measured memory_bytes: 3436
#include<iostream>
#include<cstring>
#include<string>
#include <bitset>
#include <type_traits>
#include <string>
#include <climits>



using namespace std;

int main(){
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	int d, t, s;

	cin >> d >> t >> s;

	if(d > (t * s)){
		cout << "No" << endl;
		return 0;
	}
	else{
		cout << "Yes" << endl;
		return 0;	
	}
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	string a;
 	cin >> a;
 	if(a.size()==2){
 		cout << a << endl;
 	}else{
 		char b,c,d;
 		b=a[0];
 		c=a[1];
 		d=a[2];
 		cout << d<<c<<b << endl;
 	}
 }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = inv[1] = 1;
    fact[0] = invfact[0] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i * fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n;
    cin >> n;

    init();
    
    out(fact[n]);
    re0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;

int main(){
    int N;cin>>N;
    ll D,A;cin>>D>>A;
    vector<P> X;
    for(int i=0;i<N;i++){
        ll x,h;cin>>x>>h;
        X.push_back((P){x,1+(h-1)/A});
    }
    sort(X.begin(),X.end());
    vec imos(N+2,0),S(N+2);imos[0]=S[0]=0;
    int l=0,r=0;
    ll ans=0;
    while(true){
        while(X[r].first<=X[l].first+2*D && r<N) r++;
        imos[l+1]-=X[l].second;
        imos[r+1]+=X[l].second;
        ans+=X[l].second;
        while(l<N){
            S[l+1]=S[l]+imos[l+1];
            if(X[l].second+S[l+1]>0)break;
            l++;
        }
        if(l==N)break;
        X[l].second+=S[l+1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7148
#include <cstring>
#include <cstdio>
using namespace std;
#define ms(a) memset(a, 0, sizeof a)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
const int N = 2e3 + 10;
const int inf = 0x3f3f3f3f;
struct E {int v, nt;} e[N<<1];
int n, K, ans = inf, tot, Maxdep, h[N], cnt[N], dep[N];

inline void add(int u, int v) {
	e[++tot] = (E){v, h[u]}, h[u] = tot;
	e[++tot] = (E){u, h[v]}, h[v] = tot;
}

template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline void dfs(int x, int f) {
	++ cnt[dep[x]];
	Maxdep = max(Maxdep, dep[x]);
	for (int v, i = h[x]; i; i = e[i].nt)
		if ((v = e[i].v) != f) dep[v] = dep[x] + 1, dfs(v, x);
}

int main() {
	int u, v, ret; in(n), in(K);
	for (int i = 1; i < n; ++i) in(u), in(v), add(u, v);
	for (int i = 1; i <= n; ++i) {
		Maxdep = ret = 0, ms(cnt), ms(dep);
		dfs(i, 0);
		for (int j = (K >> 1) + 1; j <= Maxdep; ++j) ret += cnt[j];
		if (!(K & 1)) ans = min(ans, ret);
		else {
			for (int v, j = h[i]; j; j = e[j].nt) {
				ms(cnt), ms(dep), Maxdep = ret = 0;
				dfs(i, v = e[j].v);
				for (int k = (K >> 1) + 1; k <= Maxdep; ++k) ret += cnt[k];
				ms(cnt), ms(dep), Maxdep = 0;
				dfs(v, i);
				for (int k = (K >> 1) + 1; k <= Maxdep; ++k) ret += cnt[k];
				ans = min(ans, ret);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    // z:122, a:97
    char res = 1;
    for(char c='a';c<='z';c++){
        if(s.find(c)==-1){
            res = c;
            break;
        }
    }
    if(res!=1){
        cout << res << endl;
    }else{
        cout << "None" << endl;
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


ll dp[102][2][5];

int main() {
	string s; cin >> s;
	int n = s.size();
	int k; cin >> k;
	
	dp[0][1][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= k; j++) {
			dp[i + 1][0][j] += dp[i][0][j];
			dp[i + 1][0][j + 1] += dp[i][0][j] * 9;
			if (s[i] >= '1') {
				dp[i + 1][0][j] += dp[i][1][j];
				dp[i + 1][0][j + 1] += dp[i][1][j] * (s[i] - '1');
			}
			dp[i + 1][1][j + (s[i] != '0')] += dp[i][1][j];
		}
	}
	cout << dp[n][0][k] + dp[n][1][k] << endl;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    char a, b;
    cin >> a >> b;
    bool B = false;
    if (a == 'H')
    {

        if (b == 'H')
        {
            cout << 'H' << endl;
        }
        if (b == 'D')
        {
            cout << 'D' << endl;
        }
    }
    else if (a = 'D')
    {
        if (b == 'H')
        {
            cout << 'D' << endl;
        }
        if (b == 'D')
        {
            cout << 'H' << endl;
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i=0; i<n; i++) {
        string s;
        cin >> s;
        if(s=="AC") ac++;
        else if(s=="TLE") tle++;
        else if(s=="WA") wa++;
        else re++;
    }
    
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
ll ans[100005] = {};
int main() {
	int n;
	cin >> n;
	ll count = 0;
	ll count2 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == i + 1) {
			count++;
			
		}
	}
	
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == i&&a[i]==i+1) {
			swap(a[i], a[i - 1]);
			count--;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
int main()
{
    int n;
    std::cin>>n;
    while(n>9){
        n=n%10;
    }
    if(n==3){
        std::cout<<"bon";
    }else if(n==0 || n==1|| n==6 || n==8){
        std::cout<<"pon";
    }else{
        std::cout<<"hon";
    }
    std::cout<<std::endl;
    return 0;
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
// 変数はti[D]。これをいじるのみで良い結果を探す
int D;
int p_contest[27];
vector<int> last_contest[27];
int schedule[500][27];
int ti[500];
ll score=0;
ll calc_score(int d){
    ll ans = 0;
    ans += schedule[d][ti[d]];
    last_contest[ti[d]].push_back(d);
    rep(j,1,27){ //penalty
        ans -= p_contest[j] * (d - last_contest[j][last_contest[j].size()-1] );
    }
    return ans;
}

ll move_and_eval(int d,int q){
    try{
    ll sa=0;
    auto result = lower_bound(all(last_contest[ti[d]]),d);
    auto next = result+1;
    auto prev = result-1;
    if(next != last_contest[ti[d]].end()){
        sa -= (*next - *result) * (*result - *prev) * p_contest[ti[d]];
    }else{
        sa -= (D - *result) * (*result - *prev) * p_contest[ti[d]];
    }
    sa -= schedule[d][ti[d]];
    //cout << sa << endl;
    last_contest[ti[d]].erase(result);

    ti[d] = q;
    sa += schedule[d][ti[d]];
    result = upper_bound(all(last_contest[ti[d]]),d);
    prev = result-1;
    sa += (*result - d) * (d - *prev) * p_contest[ti[d]];
    last_contest[ti[d]].insert(result,d);
    //cout << sa << endl;
    return sa;
    }catch(char *str){ 
        return -1;
    }
}

int main(){
    mt19937 mt{ std::random_device{}() };

    clock_t start = clock(); //time calc
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> D;
    uniform_int_distribution<int> dist1(1, D);
    uniform_int_distribution<int> dist(1, 26);
    rep(i,1,27){
        cin >> p_contest[i];
        last_contest[i].push_back(0);
    }
    rep(i,1,D+1){
        rep(j,1,27){
            cin >> schedule[i][j];
        }
    }
    //greedy
    rep(i,1,D+1){
        ti[i] = 1;
        ll sum = 0;
        rep(j,1,26){ 
            if(sum < schedule[i][j]){
                sum = schedule[i][j];
                ti[i] = j;
            }
        }
        score += calc_score(i);
    }
    //cout << score << endl;
    int cnt = 0;
    while( cnt < 100){
        //int d,q; cin >> d >> q;
        int d = dist1(mt);
        int q = dist(mt);
        int tq = ti[d];
        //if(move_and_eval(d,q) < 0) ti[d] = tq; 
        //cout << "a" << endl;
        cnt++;
    }
    rep(i,1,D+1){
        cout << ti[i] << endl;
    }
}

Measured memory_bytes: 3744
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

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

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod  998244353
#define pii pair<int, int>
#define PI 2*acos(0.0)
#define forn(i, n) for(int i = 0; i < n; i++)

ll bigmod()
{
    ll x = 2, p = mod - 2, res = 1;
    while(p)
    {
        if(p&1)
            res = (res * x)%mod;
        x = (x*x)%mod;
        p>>=1;
    }
    return res;
}

int main()
{
    io;
    ll n, s;
    cin>>n>>s;
    vll inp(n);
    for(auto& x: inp)
        cin>>x;
    ll dp[n+1][s+1];
    memset(dp, 0LL, sizeof(dp));
    ll minv = bigmod();
    ll tw = 1, p = n;
    while(p--)
        tw = (tw*2)%mod;
    dp[0][0] = tw;
    for(int i = 0; i<n; i++)
    {
        for(int j = 0; j<=s; j++)
        {
            dp[i+1][j] = (dp[i+1][j] + dp[i][j])%mod;
            if(inp[i] + j <=s)
                dp[i+1][inp[i] +j] =(dp[i+1][inp[i]+j] + dp[i][j] * minv %mod) %mod;
        }
    }
    cout<<dp[n][s];
    return 0;
}

Measured memory_bytes: 73964
#include <iostream>
#include "string.h"
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string N;
	cin >> N;
	if(N[0] == N[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	//vector<int>v(N);
	
	return 0;
}

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

int main() {
  int N;

  cin >> N;

  vector<string> blue(N);

  for (int i = 0; i < N; i++) {
    cin >> blue.at(i);
  }

  int M;

  cin >> M;

  vector<string> red(M);

  for (int i = 0; i < M; i++) {
    cin >> red.at(i);
  }

  int max = 0;
  for (int i = 0; i < N; i++) {
    string s;
    int sum = 0;
    s = blue.at(i);

    for (int j = 0; j < N; j++) {
      if (blue.at(j) == s) sum++;
    }

    for (int j = 0; j < M; j++) {
      if (red.at(j) == s) sum--;
    }

    if (sum > max) max = sum;
  }

  cout << max << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	while(1){
		scanf("%d%d",&a,&b);
		if(a==0&&b==0) break;
		if(a<=b) printf("%d %d\n",a,b);
		if(a>b) printf("%d %d\n",b,a);
	}
	return 0;
}

Measured memory_bytes: 600
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        a, b, c = line.split(" ", 3)
        if a[-1] == b[0] and b[-1] == c[0]:
            print("YES")
        else:
            print("NO")

if __name__ == "__main__":
    main(sys.argv)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "yes" << endl;}
void no(){ cout << "no" << endl;}

//-----------------------------------------
int ts(char c){
  if(c == 'S') return 0;
  if(c == 'H') return 1;
  if(c == 'C') return 2;
  return 3;
}
char ts2(int i){
  if(i == 0) return 'S';
  if(i == 1) return 'H';
  if(i == 2) return 'C';
  return 'D';
}
//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  vector<vector<bool>> f(4,vector<bool>(13,1));
  int n;
  cin >> n;
  REP(i,n){
    char c;
    int a;
    cin >> c >> a;
    a--;
    f[ts(c)][a] = 0;
  }
  REP(i,4){
    REP(j,13){
      if(f[i][j]) cout << ts2(i) <<" " << j+1 <<endl;
    }
  }

  return 0;
}






Measured memory_bytes: 3232
#include<stdio.h>
#define INF (1<<24)
int G[100][100];
int d[100];
int v[100];
int u,ans=0;
int n;
int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
      if(G[i][j]==-1)G[i][j]=INF;
    }
    d[i]=INF;
    v[i]=0;
  }
  d[0]=0;
  while(1){
    u=-1;
    for(i=0;i<n;i++){
      if(v[i]==1)continue;
      if(u==-1||d[u]>d[i])u=i;
    }
    if(u==-1)break;
    v[u]=1;
    for(i=0;i<n;i++)
      if(G[u][i]<d[i]&&v[i]==0)
	d[i]=G[u][i];
  }
  for(i=0;i<n;i++)ans+=d[i];
  printf("%d\n",ans);
  return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

int main()
{
  int64_t n;
  cin >> n;
  cout << n * (n - 1) / 2 << endl;
}

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

int main() {
  string s;
  cin >> s;
  bool good = true;
  for (int i = 0; i < s.length(); i++) {
    // check for equal chars
    for (int j = i + 1; j < s.length(); j++) {
      if (s[j] == s[i]) {
        good = false;
      }
    }
  }
  if (good)
    cout << "yes";
  else
    cout << "no";  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<str, ll> msl;
typedef std::map<char, ll> mcl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100000;

#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))

int main(void){
    ll a,b,c,k;
    in4(a,b,c,k);
    ll answer = max({a,b,c});
    rep(i,k) answer *= 2;
    prl(a+b+c-max({a,b,c})+answer);

    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 COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string s; cin >> s;
  bool ok = true;

  if (s[0] != 'A') ok = false;
  int cnt=0;
  for (int i = 2; i < s.size()-1; i++) if (s[i] == 'C') cnt++;
  if (cnt != 1) ok = false;
  for (char c: s) {
    if (c=='A' || c == 'C') continue;
    if (isupper(c)) ok = false;
  }
  COUT(ok?"AC":"WA");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> ai(n);
    for (int i=0; i<n ; i++){
        cin >> ai.at(i);
    }
    for (int j=0; j<n; j++){
        if (j != n-1) cout << ai.at(n-j-1) << " ";
        else cout << ai.at(n-j-1) << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, m, c;
  cin >> n >> m >> c;
  vi32 b(m);
  rep(i, m) cin >> b[i];
  vvi32 a(n, vi32(m));
  rep(i, n) rep(j, m) cin >> a[i][j];
  int ans = 0;
  rep(i, n) {
    int r = c;
    rep(j, m) r += a[i][j] * b[j];
    if (r > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define ll long long
    #define endl '\n'
    #define pi 3.14159265
    ll n,W;
  	vector<ll> w(200),v(200);
  	ll dp[200][200000];
  	ll f(ll i,ll left)
  	{
  		if(i==n)
  		{
  			if(left==0)
  				return 0;
  			return 1e17;
  		}
  		if(dp[i][left]!=-1)
  			return dp[i][left];
  		dp[i][left]=min(w[i]+f(i+1,left-v[i]),f(i+1,left));
  		return dp[i][left];
  	}
    int main()
    {
        IOS;
        cin>>n>>W;
        for(ll i=0;i<n;i++)
        	cin>>w[i]>>v[i];
        memset(dp,-1,sizeof(dp));
        for(ll i=1;i<=100000;i++)
            f(0,i);
        ll ans=0;
        for(ll i=100000;i>=1;i--)
        {
    		if(dp[0][i]<=W&&dp[0][i]>0)
    			ans=max(ans,i);
        }
        cout<<ans;
    }      

Measured memory_bytes: 312832
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

vector<int> G[100'010];
vector<vector<bool>> used(100'010, vector<bool>(11,false));
vector<int> color(100'010, 0);

void dfs(int v, int d, int c){
  if(used[v][d])return;
  used[v][d] = true;
  if(color[v]==0){
    color[v] = c;
  }
  if(d<=0)return;
  dfs(v, d-1, c);
  for(int next_:G[v]){
    dfs(next_, d-1, c);
  }
  return;
}

int main(){
  
  int n,m;
  cin>>n>>m;
  int a,b;
  REP(i,m){
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int q;
  cin>>q;
  int v[q],d[q],c[q];
  REP(i,q){
    cin>>v[i]>>d[i]>>c[i];
    v[i]--;
  }
  
  for(int i=q-1;i>=0;i--){
    dfs(v[i], d[i], c[i]);
  }
  
  REP(i,n){
    cout<<color[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 15096
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  map<string, int> s;
  rep(i, n){
    string t;
    cin >> t;
    s[t]++;
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 19228
#include<stdio.h>

int main(){

int i;
int H,W;
int x,y;

for(i=0;i<100;i++){
	scanf("%d %d",&H,&W);
	
	if(H==0 && W==0){
		return 0;
	}
	
	for(y=0;y<H;y++){
		for(x=0;x<W;x++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}
	
return 0;
}


Measured memory_bytes: 2088
#include <stdio.h>
   
   int main(void) {
   	int a,b,x;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&x);
	if(a<=x && x<=a+b){
		printf("YES");	
	}else{
		printf("NO");
	}
	
	
	return 0;
   }

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int l, r, d; cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; ++i) {
        if(i % d == 0) {
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3580
package main

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

var n int
var size []int
var g [][]int
var ans []int64
var m ModUtil

func main() {
  io := IO{bufio.NewReaderSize(os.Stdin,100),bufio.NewWriterSize(os.Stdout,100)}
  n = io.NextInt()
  size = make([]int,n)
  g = make([][]int,n)
  ans = make([]int64,n)
  m = ModUtil{mod:1000000007}.Init(n)
  for i:=0;i<n-1;i++ {
    a,b := io.NextInts()
    g[a-1] = append(g[a-1],b-1)
    g[b-1] = append(g[b-1],a-1)
  }
  dfs1(0,-1)
  ans[0] = 1
  for i:=0;i<n;i++ { ans[0] = (ans[0]*int64(size[i]))%m.mod }
  dfs2(0,-1)
  for i:=0;i<n;i++ { ans[i] = (m.f[n]*m.Inv(ans[i]))%m.mod }
  for i:=0;i<n;i++ { io.Println((ans[i]+m.mod)%m.mod) }
  io.Flush()
}

func dfs1(v,p int) {
  size[v] = 1
  for _,u := range g[v] {
    if u == p { continue }
    dfs1(u,v)
    size[v] += size[u]
  }
}
func dfs2(v,p int) {
  if p != -1 { ans[v] = ((ans[p]*int64(n-size[v])%m.mod)*m.Inv(int64(size[v])))%m.mod }
  for _,u := range g[v] {
    if u == p { continue }
    dfs2(u,v)
  }
}

type ModUtil struct {
  mod int64
  f,invf []int64
}
func(m ModUtil) Init(n int) ModUtil {
  m.f = make([]int64,n+1)
  m.invf = make([]int64,n+1)
  m.f[0] = 1
  for i:=1;i<n+1;i++ { m.f[i] = (int64(i)*m.f[i-1])%m.mod }
  m.invf[n] = m.Inv(m.f[n])
  for i:=n;i>0;i-- { m.invf[i-1] = (int64(i)*m.invf[i])%m.mod }
  return m
}
func(m ModUtil) Inv(n int64) int64 {
  var a,b,c,x int64 = n%m.mod,m.mod,0,1
  for b != 0 { a,b,c,x = b,a%b,x-(a/b)*c,c }
  return (x%m.mod+m.mod)%m.mod
}
func(m ModUtil) Perm(n,k int) int64 {
  if n < 0 || k < 0 || n-k < 0 { return 0 }
  return (m.f[n]*m.invf[n-k])%m.mod
}
func(m ModUtil) Comb(n,k int) int64 {
  if n < 0 || k < 0 || n-k < 0 { return 0 }
  return (m.Perm(n,k)*m.invf[k])%m.mod
}
func(m ModUtil) Homo(n,k int) int64 {
  if n == 0 && k == 0 { return 1 }
  return m.Comb(n+k-1,k)
}

type IO struct {
  reader *bufio.Reader
  writer *bufio.Writer
}
func(io *IO) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := io.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(io *IO) Println(a ...interface{}) (int,error) {
  return fmt.Fprintln(io.writer,a...)
}
func(io *IO) Flush() error {
  return io.writer.Flush()
}
func(io *IO) NextInt() int {
  n,_ := strconv.Atoi(io.NextLine())
  return n
}
func(io *IO) NextInts() (int,int) {
  s := strings.Fields(io.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

Measured memory_bytes: 28032
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define MAX 5000000000;

int main() {
  int A, B, M; cin >> A >> B >> M;
  vector<int> a(A), b(B);
  int tmp = MAX;
  for (int i = 0; i < A; i++) {
    cin >> a[i];
    tmp = min(tmp, a[i]);
  }
  int ans = tmp;
  tmp = MAX;
  for (int i = 0; i < B; i++) {
    cin >> b[i];
    tmp = min(tmp, b[i]);
  }
  ans += tmp;
  int x, y, c;
  for (int i = 0; i < M; i++) {
    cin >> x >> y >> c;
    x--; y--;
    ans = min(a[x] + b[y] - c, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,K;
	cin>>N>>K;
	vector<int> input(N);
	rep(i,N)cin>>input[i];
	int g = 0;
	rep(i,N)g = __gcd(g,input[i]);
	string ans = "IMPOSSIBLE";
	rep(i,N){
		int dis = input[i]-K;
		if(dis<0)continue;
		if(dis%g == 0)ans = "POSSIBLE";
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
mod = 1000000007

class combination():
    def __init__(self, n):
        self.fact = [1] * (n+1)
        self.ifact = [1] * (n+1)
        for i in range(1, n+1):
            self.fact[i] = self.fact[i-1]*i % mod
        self.ifact[n] = pow(self.fact[n], mod-2, mod)
        for i in range(n, 0, -1):
            self.ifact[i-1] = self.ifact[i]*i % mod
    def comb(self, n, k):
        if k < 0 or k > n: return 0
        comb = self.fact[n]*self.ifact[k]*self.ifact[n-k] %mod
        return comb

n, k = map(int, input().split())

comb = combination(n)
for i in range(1, k+1):
    print(comb.comb(n-k+1, i) * comb.comb(k-1, i-1) % mod)

Measured memory_bytes: 3444
#include <cstdio>
#include <iostream>

#define N_MAX 10000
#define Q_MAX 100000
//#define NIL -1
#define UNITE 0
#define SAME 1
using namespace std;

int N,Q;
int num_array[N_MAX+1];//0オリジン．



int main(){
	scanf("%d %d",&N,&Q);
	for(int i = 0;i < N_MAX;i++)
		num_array[i] = i;//iはグループ番号

	//クエリごとの処理
	int query;
	int x,y;
	int p1,p2;
	int cnt1,cnt2;
	for(int q = 0;q < Q;q++){
		scanf("%d %d %d",&query,&x,&y);

		p1 = x;
		p2 = y;
		cnt1 = 0;
		cnt2 = 0;
		while(num_array[p1] != p1){
			p1 = num_array[p1];
			cnt1++;
		}
		while(num_array[p2] != p2){
			p2 = num_array[p2];
			cnt2++;
		}

		if(query == UNITE){
			if(cnt1 > cnt2){
				num_array[p1] = p2;
			}else{
				num_array[p2] = p1;
			}

		}else if(query == SAME){
			if(p1 == p2) printf("1\n");
			else printf("0\n");
		}else{
			cout <<"error" <<endl;
			return 0;
		}
	}

	return 0;
}

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

using namespace std ;

int main()
{
    string s ;
    cin >> s ;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
    cout << "Yes" ;
    else cout << "No" ;
    return 0 ;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    proconio::input! {
        n: usize,
        mut xy: [(i32, i32); n]
    }
    xy.sort();
    let mut ans = 0;
    let mut prev = xy[0].0;
    let mut ymin = xy[0].1;
    let mut ymax = xy[0].1;
    for p in xy {
        if prev != p.0 {
            ymin -= p.0 - prev;
            ymax += p.0 - prev;
            prev = p.0;
        }
        ans = cmp::max(ans, cmp::max(ymax - p.1, p.1 - ymin));
        ymin = cmp::min(ymin, p.1);
        ymax = cmp::max(ymax, p.1);
    }

    println!("{}", ans);
}


Measured memory_bytes: 8144
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;
typedef long long LL;

int main(void) {

	int num = 0;
	int carry = 0;

	cin >> num;

	carry = num / 1000;

	if (carry == 1)
		cout << "ABD" << endl;
	else
		cout << "ABC" << endl;
	

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template <class T> void out(const T &val) { cout << val << endl; }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

ll ksm(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int x, y;
    sf(x, y);
    if ((x + y) % 3 || 2 * x < y || 2 * y < x) puts("0");
    else {
        if (x < y) swap(x, y);
        ll sum = (x + y) / 3, a = x - sum;
        ll ans = 1, t = 1;
        for (int i = 2; i <= sum; ++i) {
            ans = ans * i % mod;
        }
        for (int i = 2; i <= a; ++i) {
            t = t * i % mod;
        }
        ans = ans * ksm(t, mod - 2) % mod;
        t = 1;
        for (int i = 2; i <= sum - a; ++i) {
            t = t * i % mod;
        }
        ans = ans * ksm(t, mod - 2) % mod;
        cout << ans << '\n';
    }
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int a, b, c; cin >> a >> b >> c;

    set<int> se;
    se.insert(a);
    se.insert(b);
    se.insert(c);


    if (se.size() == 2) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 256
n,a,b,c=gets.split.map &:to_i
s=[]
n.times do |i|
  s[i]=gets.to_i
end
ans=a+b+c
[1,2,3,4].repeated_permutation(n).to_a.each{|j|
  x=a
  y=b
  z=c
  a1=0
  b1=0
  c1=0
  kai=0
  n.times do |u|
    if j[u]==1
      if a1==1
        kai+=10
      end
      (x-=s[u])
      a1=1
    elsif j[u]==2
      if b1==1
        kai+=10
      end
      (y-=s[u])
      b1=1
    elsif j[u]==3
      if c1==1
        kai+=10
      end
      (z-=s[u])
      c1=1
    end
  end
  x=x.abs; y=y.abs; z=z.abs
  kai+=(x+y+z)
  next if a1+b1+c1 !=3
  ans=[ans,kai].min
}
puts ans


Measured memory_bytes: 21916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N;
string S, T;

int main() {
	cin >> N >> S >> T;
	for (int i = 0; i < N; i++) {
		cout << S[i] << T[i];
	}
	cout << endl;
    return 0;
}



Measured memory_bytes: 764
N, K = map(int, input().split())
S = '1' + input() + '1'
s = 0
t = 0
k = 0
l = 0
while s < N:
  while s < N:
    s += 1
    if S[s] == '0' and S[s + 1] == '1':
      k += 1
    if k == K and S[s] == '1' and S[s + 1] == '0':
      break
  l = max(s - t, l)
  while t < s:
    t += 1
    if S[t] == '0' and S[t + 1] == '1':
      k -= 1
      break
print(l)

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9) cout << -1 << endl;
    else cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
	int n = N;
	int count = 0;
	for(int i=0;i<Integer.toString(N).length();i++){
	    count += n%10;
	    n /= 10;
	}
        if(N%count==0) System.out.print("Yes");
	else System.out.print("No");
    }
}


Measured memory_bytes: 22868
#!/usr/bin/env python3
s = input()
n = len(s)

a = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(n):
    if s[i] == '<':
        a[i + 1] = a[i] + 1
for i in range(n)[::-1]:
    if s[i] == '>':
        b[i] = b[i + 1] + 1
ans = [0] * (n + 1)
for i in range(n + 1):
    ans[i] = max(a[i], b[i])
print(sum(ans))


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;

    LL small=INF_LL;
    VL a(n);
    REP(i,n){
        cin>>a[i];
        small=min(small,a[i]);
    }

    while(true){
        LL small2=INF_LL;
        REP(i,n){
            if(a[i]%small==0){
                continue;
            }
            a[i]%=small;
            small2 = min(small2,a[i]);
        }

        if(small2==INF_LL || small2==small){
            break;
        }
        small=small2;
    }

    cout<<small<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,a;
  cin>>s;
  int N=s.size();
  
  for(int i=0;i<N;i++){
    if(s.at(i)=='0')
      a.push_back('0');
    else if(s.at(i)=='1')
      a.push_back('1');
    else if(s.at(i)=='B'){
      if(a.size()>0)
        a.pop_back();
    }
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int r;
    cin>>r;
    cout<<(double)2*3.14159*(double)r<<endl;
}

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

int main(){
   int A, B, C, K;
   cin >> A >> B >> C >> K;
   if (K <= A){
      cout << K << endl;
   } else if (K <= A+B){
      cout << A << endl;
   } else{
      cout << A-(K-A-B) << endl;
   }
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s.size() < 4) {
        puts("No");
    } else {
        if (s[0]=='Y' && s[1] =='A'&&s[2]=='K'&&s[3]=='I') {
            puts("Yes");
        } else {
        puts("No");
        }
    }
    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  int N,K;
  cin>>N>>K;
  double ans(0);
  for(int i(1);i<=N;i++){
    int cnt(0);
    int tmp(i);
    while(tmp<K){
      cnt++;
      tmp*=2;
    }
    //cout << cnt << endl;
    ans += 1/((double)(1<<cnt));
  }
  cout << setprecision(10) << ans/(double)N << endl;
  return 0;
}

Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int a,b; cin >> a >> b;
        string s; cin >> s;
        if(s[a]!='-'){
            cout<<"No"<<endl;
            return 0;
        }
        for(int i = 0; i<sz(s); i++){
            if(i==a)continue;
            if(s[i]>='0' and s[i]<='9')continue;
            else{
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;

return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int n, k;

bool check(double arr[], double mid) {
	int cut = 0;
	for (int i = 0; i < n; i++) {
		cut += ceil(arr[i] / mid) - 1;
		if (cut > k)
			return false;
	}
	return true;
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	cin >> n >> k;
	double arr[n];
	double left = 0, right = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		right = max(right, arr[i]);
	}
	for (int i = 0; i < 200; i++) {
		double mid = (left + right) * 0.5;
		if (check(arr, mid))
			right = mid;
		else
			left = mid;
	}
	int ans = ceil(right);
	cout << ans;
	return 0;
}


Measured memory_bytes: 5424
MOD = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))

res = 0

for k in range(60):
    cnt = [0, 0]
    for i in range(N):
        cnt[(A[i] >> k) & 1] += 1
    res = (res + cnt[0] * cnt[1] * pow(2, k)) % MOD

print(res)


Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,d,a,c=0;
  cin>>n>>k;
  vector<bool> v(n,false);
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>a;
      v[a-1]=true;
    }
  }
  for(int i=0;i<n;i++){
    if(v[i]==false) c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    
    if (n % k == 0) {
      System.out.println(0);
    } else {
      System.out.println(1);
    }
  }
}

Measured memory_bytes: 22612