akhauriyash/Code-Regression huggingface dataset:
#define F freopen("/home/ffacs/Codes/Ccodes/testin.txt","r",stdin);// freopen("/home/ffacs/Codes/Ccodes/testout.txt","w",stdout);
#pragma GCC optimiz(2)
#include <bits/stdc++.h>
#define rg register
using namespace std;
typedef long long ll;
template<typename T>
inline bool read(T &n) {
    T ans = 0, flag = 1;
    char ch;
    while ((ch = getchar()) < '0' || ch > '9') if (ch == '-') flag = -1; else if (ch == EOF) return false;
    ans = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9') ans = ans * 10 + ch - '0';
    n = ans * flag;
    return true;
}
inline ll read() {
    ll ans = 0, flag = 1;
    char ch;
    while ((ch = getchar()) < '0' || ch > '9') if (ch == '-') flag = -1;
    ans = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9') ans = ans * 10 + ch - '0';
    return ans * flag;
};
char buff[500005];
int tree[500005][30],len;
inline void add(int x,int p,int k){
    for(;x<=len;x+=(x&-x)) tree[x][p]+=k;
}
inline int ask(int x,int p){
    int ans=0;
    for(;x;x-=(x&-x)) ans+=tree[x][p];return ans;
}
int main(){
    cin>>len;
    scanf("%s",buff+1);
    for(rg int i=1;i<=len;i++){
        add(i,buff[i]-'a',1);
    }
    int Q=read(),o,l,r;
    char tihuan[3];
    while (Q--){
        o=read();
        if(o==1){
            l=read();scanf("%s",tihuan);
            add(l,buff[l]-'a',-1);
            add(l,*tihuan-'a',1);
            buff[l]=*tihuan;

        }
        else{
            l=read(),r=read();
            int ans=0;
            for(rg int i=0;i<26;i++)
                if(ask(r,i)-ask(l-1,i)>0) ans++;
            printf("%d\n",ans);
        }
    }
    return 0;
}

Measured memory_bytes: 59392
n = int(input())
a = input().split()
b = a[:]
flag = 1
while flag:
    flag = 0
    for i in range(n-1):
        if a[i][1] > a[i+1][1]:
            a[i], a[i+1] = a[i+1], a[i]
            flag = 1
print(*a)
print("Stable")

for i in range(n-1):
    min_j = i
    for j in range(i,n):
        if b[j][1] < b[min_j][1]:
            min_j = j
    b[i], b[min_j] = b[min_j], b[i]
print(*b)
if a == b:
    print("Stable")
else:
    print("Not stable")

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

int n;

void solve()
{
	long double x[4],y[4],px[2],py[2];


	for(int i = 0; i < 4; i++){
		cin >> x[i] >> y[i];
	}

	px[0] = x[1] - x[0];
	px[1] = x[3] - x[2];
	py[0] = y[1] - y[0];
	py[1] = y[3] - y[2];



	if(px[0]*py[1] == px[1]*py[0])
		cout << "YES";
	else
		cout << "NO";
	cout << endl;

}

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++)
		solve();


	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
struct Union{
  vector<int> par;
   Union(int a){
   par=vector<int>(a,-1);
   }
   int find(int a){
     if(par[a]<0)
       return a;
     else
       return par[a]=find(par[a]);
   }
   bool same(int a,int b){
    return find(a)==find(b);
   }
   int Size(int a){
     return -par[find(a)];
   }
   void unite(int a,int b){
     a=find(a);
     b=find(b);
     if(a==b)
       return;
   if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
     par[b]=a;
   }
 
  int much(int a){
  vector<int> e(a);
   rep(i,a){
   e[i]=find(i);
    }
   sort(all(e)); 
   e.erase(unique(all(e)),e.end());
   return e.size();
   }
 };
signed main(){
int a,b;
  cin>>a>>b;
  vector<int> c(b),d(b);
  rep(i,b)
    cin>>c[i]>>d[i];
  int f=0;
  rep(j,b){
  Union e(a);
  rep(i,b){
    if(i==j)
      continue;
    else
    e.unite(c[i]-1,d[i]-1);
 }
    if(e.much(a)>1)
      f++;
  }
  cout<<f;
}

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

vector<vector<int>> g;
int n;

void bfs(int node,vector<vector<int>> &diff){
  queue<pair<int,int>> que;
  que.emplace(node,0);
  vector<int> seen(n);
  seen[node]=1;

  while(!que.empty()){
    int now = que.front().first;
    int cost = que.front().second;
    que.pop();

    for(int next:g[now]){
      if(seen[next]) continue;
      diff[node][next] = cost+1;
      que.emplace(next,cost+1);
      seen[next]=1;
    }
  } 
}

int main(){
  int x,y;
  cin >> n >> x >> y;
  g.assign(n,vector<int>());
  x--;
  y--;

  for (int i = 0; i < n-1; i++)
  {
    g[i].push_back(i+1);
    g[i+1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);

  const int INF = 1e9;
  vector<vector<int>> diff(n,vector<int>(n,INF));
  for (int i = 0; i < n; i++)
  {
    bfs(i,diff);
  }

  vector<int> anss(n);
  for (int i = 0; i < n; i++)
  {
    for (int j = i+1; j < n; j++)
    {
      if(diff[i][j]<n) anss[diff[i][j]]++;
    }
  }

  for (int i = 1; i < n; i++)
  {
    cout << anss[i] << endl;
  }  
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int D_AB, D_BC, D_AC;
    if (a-b>0)
        D_AB = a-b;
    else if (a-b<=0)
        D_AB = b-a;
    
    if (b-c>0)
        D_BC = b-c;
    else if(b-c<=0)
        D_BC = c-b;
    
    if (a-c>0)
        D_AC = a-c;
    else if (a-c<=0)
        D_AC = c-a;

    
    if(D_AC<=d || (D_AB<=d && D_BC<=d))
        cout << "Yes" << endl;

    else
        cout << "No" << endl;
    
}

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

int main()
{
	long n, m;
	long b[40];
	memset(b, 0, sizeof(b));

	cin >> n >> m;

	int j = 0;

	while (m % 2 == 0) {
		b[j]++;
		m /= 2;
	}
	if (b[j] > 0)
		j++;

	for (long i = 3; i <= m; i = i + 2) {
		while (m % i == 0) {
			b[j]++;
			m /= i;
		}
		if (b[j] > 0)
			j++;
	}

	long long s = 1;

	for (int i = 0; b[i] > 0; i++) {
		for (long j = 0; j < b[i]; j++)
			s = (s * (n + b[i] - 1 - j)) % 1000000007;
		
		for (long j = 0; j < b[i]; j++) {
			long long a[40];
			a[0] = 1;
			a[1] = b[i] - j;
			for (int i = 2; i < 40; i++)
				a[i] = (a[i - 1] * a[i - 1]) % 1000000007;

			int d = 1;
			long long p = 1000000005;

			while (p) {
				if (p & 1)
					s = (s * a[d]) % 1000000007;
				d++;
				p = p >> 1;
			}
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
//gcc -std=gnu11 -O2 -o a.out main.c -lm

#include <stdio.h>

int main(void)
{
    int res;

    int w, h;
    char line[100][100+1];
    int i;

    // input
    res = scanf("%d%d", &h, &w);
    for (i = 0; i < h; i++) {
        res = scanf("%s", &line[i][0]);
    }
    // output
    for (i = 0; i < h; i++) {
        printf("%s\n", &line[i][0]);
        printf("%s\n", &line[i][0]);
    }

	return 0;
}



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

int64_t walk(int64_t zahyo, int64_t D) {
  if (zahyo>=0) return zahyo-D;
  else return zahyo+D;
}

int main() {
  int64_t X, K, D;
  cin >> X >> K >> D;
  
  int64_t i = abs(X)/D;
  if(i>=K) X = walk(X, K*D);
  else {
	if (i!=0) X = walk(X, i*D);
    K = (K-i) % 2;
    if (K!=0) X = walk(X, D);
  }
   
  cout << abs(X) << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll pow10(ll x) {
	ll ret = 1;
	if (x == 0) return ret;
	else {
		repi(i, 0, x) ret *= 10;
		return ret;
	}
}

int main() {
	ll Q;
	rd(Q);
	repi(i, 0, Q) {
		ll N, ans = 0;
		rd(N);
		while (N / 10 != 0) {
			ll tc = 1;
			ll tv = N / 10;
			ll tr = N % pow10(tc);
			ll maxt = 0;
			while (1) {
				maxt = max(maxt, tv*tr);
				if (tv / 10 == 0) break;
				tv /= 10;
				tc++;
				tr = N % pow10(tc);
			}
			N = maxt;
			ans++;
		}
		wrln(ans);
	}
	return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <utility>
#define eps 1e-9
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint p, q, a, n;

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

llint dfs(llint l, P sum, llint mul, llint x)
{
	llint ret = 0, bunbo, bunsi; P nsum;
	for(llint i = l; i <= a; i++){
		if(mul*i > a) break;
		bunbo = sum.second * i;
		bunsi = sum.first * i + sum.second;
		if(q*bunsi > p*bunbo) continue;
		
		//llint d = gcd(bunsi, bunbo);
		//bunsi /= d, bunbo /= d;
		//nsum = make_pair(bunsi/d, bunbo/d);
		
		if(q*bunsi == p*bunbo) ret++;
		if(x+1 < n){
			nsum = make_pair(bunsi, bunbo);
			ret += dfs(i, nsum, mul*i, x+1);
		}
	}
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	while(1){
		cin >> p >> q >> a >> n;
		if(p == 0 && q == 0 && a == 0 && n == 0) break;
		cout << dfs(1, make_pair(0, 1), 1, 0) << "\n";
	}
	flush(cout);
	
	return 0;
}


Measured memory_bytes: 3088
from fractions import gcd
a,b,c,d = map(int,input().split())
cd = c * d // gcd(c,d)
n_c = 0
n_d = 0
n_cd = 0
s = a // c 
e = b // c
n_c = e - s
if a%c==0:
    n_c+=1
s = a // d
e = b // d
n_d = e - s
if a%d==0:
    n_d+=1
s = a // cd 
e = b // cd
n_cd = e - s
if a%cd==0:
    n_cd+=1
print(b-a+1-(n_c+n_d-n_cd))

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

decltype(0) main () {
  int n; cin >> n;
  if (n%2 == 0) {
    cout << 0.5 << endl;
  } else {
    cout << ((double)(n/2 +1))/((double)n) << endl;
  }
}


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

int binpow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) res = 1LL * res * a % MOD;
        a = 1LL * a * a % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    cout << (0LL + binpow(10, n) - 2 * binpow(9, n) + binpow(8, n) + 2 * MOD) % MOD << "\n";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  string s;
  while(cin >> s){
    bool ans = true;

    if(s[0] == s[1] or s[1] == s[2] or s[2] == s[3]) ans = false;

    cout << (ans ? "Good" : "Bad") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,l;
    cin>>n>>l;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int lp=0,res1=0,res2=0;
    for(int i=0;i<n-1;i++){
        if(a[i]+a[i+1]>lp){
            lp=a[i]+a[i+1];
            res1=i;
            res2=i+1;
        }
    }
    if(lp<l)cout<<"Impossible"<<endl;
    else{
        //cout<<res1<<' '<<res2<<endl;
        cout<<"Possible"<<endl;
        for(int i=1;i<=res1;i++){
            cout<<i<<endl;
        }
        for(int i=n-1;i>=res2;i--){
            cout<<i<<endl;
        }
    }
}

Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        List<Integer> ans = new ArrayList<>();
        if(N==3){
            ans.add(2);ans.add(5);ans.add(63);
        }else{
            ans.add(3);ans.add(29997);
            ans.add(2);ans.add(4);
            N-=4;
            int even = 10;
            int oddup = 6;
            int odddown=29994;
            while(N>0){
                if(N==1){
                    ans.add(30000);
                    break;
                }
                if(even<30000){
                    ans.add(even);ans.add(even-2);
                    even+=6;
                }else{
                    if(oddup == odddown){
                        ans.add(oddup);
                        ans.add(30000);
                    }else{
                        ans.add(oddup);ans.add(odddown);
                        oddup+=3;odddown-=3;
                    }
                }
                N-=2;
            }
        }
        for(int i : ans)System.out.print(i+" ");
        System.out.println();
    }
}

Measured memory_bytes: 29576
let id x = x
let str = Scanf.scanf "%s\n" id

let n = String.length str
  
let array = Array.init n (fun n -> str.[n])
let list = Array.to_list array

let check l =
  let hd = List.hd l in
  List.for_all (fun x -> x = hd) l 
  
let rec make_alphalist n l =
  if n = 123 then l else make_alphalist (n+1) (char_of_int n :: l)

let rec subst c l =
  match l with
  | [a] -> []
  | a :: b :: rest ->
     if a=c || b=c then c :: subst c (b::rest) else a :: subst c (b::rest)
    
let rec count c n l =
  if check l then n else count c (n+1) (subst c l)

let rec make_cntlist alist cntlist =
  match alist with
  | [] -> cntlist
  | hd :: rest -> make_cntlist rest ((count hd 0 list) :: cntlist)

let alphalist = make_alphalist 97 []
let cntlist = List.sort compare (make_cntlist alphalist [])

let ans = List.hd cntlist

let () =
  Printf.printf "%d\n" ans

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 307;

int n, m;
int a[MAXN][MAXN];
int cc[MAXN];
int il[MAXN];
bool in[MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d%d", &n, &m );
	lpi ( i, 1, n ) lpi ( j, 1, m ) scanf ( "%d", &a[i][j] );
}

void work ()
{
	// main work

	lpi ( i, 0, m ) in[i] = true;   // in[0] = true as a flag of ending
	lpi ( i, 1, n ) il[i] = 1;

	int maxi, mp;
	int ans = INF;
	lpi ( _t, 1, m ) {
		INIT ( cc, 0 );
		lpi ( i, 1, n ) ++cc[a[i][il[i]]];
		maxi = mp = -1;
		lpi ( i, 1, m ) if ( cc[i] > maxi ) maxi = cc[i], mp = i;
		ans = qmin ( ans, maxi );
		in[mp] = false;
		lpi ( i, 1, n ) while ( !in[a[i][il[i]]] ) ++il[i];
	}

	cout << ans << endl;
}

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

int main() {
	long long int n, m;
	cin >> n >> m;

	long long int ans;
	if (n > 2 && m > 2) {
		ans = (n * m) - (n * 2) - (m * 2) + 4;
	}
	else {
		if ((n == 2 || m == 2) && n + m > 2) {
			ans = 0;
		}
		else if (n + m > 2) {
			ans = n * m - 2;
		}
		else {
			ans = 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int S = sc.nextInt();

		int a = S / 1000;
		int b = S % 1000 / 100;
		int c = S % 1000 % 100 / 10;
		int d = S % 1000 % 100 % 10;

		if (a == b || b == c || c == d) {
			System.out.print("Bad");
		} else {
			System.out.print("Good");
		}

	}
}

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

using namespace std;

tuple<int, int, int, int> p[111111];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		scanf("%d%d", &get<0>(p[i]), &get<1>(p[i])), get<2>(p[i]) = i;
	sort(p, p + m);
	int x, q = -1;
	for (int i = 0; i < m; i++) {
		if (get<0>(p[i]) != q)
			q = get<0>(p[i]), x = 1;
		get<3>(p[i]) = x++;
		swap(get<0>(p[i]), get<2>(p[i]));
	}
	sort(p, p + m);
	for (int i = 0; i < m; i++)
		printf("%06d%06d\n", get<2>(p[i]), get<3>(p[i]));
	return 0;
}


Measured memory_bytes: 3072
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
set<string> st;
deque <char> q ;
int vis [1000];
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   if(a+b+c==17) pr(1);
   else pr(0);
}






Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    // dp[i]=トキの体力
    vector<int> dp(h + 10010, INF);
    dp[0] = 0;
    int ans = INF;
    for (int j = 0; j <= h + 10000; j++)
    {
        for (int i = 0; i < n; i++)
        {
            if (j - a[i] >= 0)
            {
                chmin(dp[j], dp[j - a[i]] + b[i]);
            }
            if (j >= h)
            {
                chmin(ans, dp[j]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int n,a[1005],i,j;

int main(){
	scanf("%d", &n);
	
	for(i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	sort(a, a + n);
	
	printf("%d\n", a[n - 1] - a[0]);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    static final int INF = (int)1e9;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] value = new int[m];
        int[] keybit = new int[m];
        for(int i=0; i<m; i++){
            value[i] = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            for(int j=0; j<b; j++){
                int shift = Integer.parseInt(sc.next())-1;
                keybit[i] |= 1<<shift;
            }
        }
        
        int k = 1;
        for(int i=0; i<n; i++){
            k*=2;
        }
        
        int[] dp = new int[k];
        Arrays.fill(dp, INF);
        dp[0] = 0;
        for(int i=0; i<m; i++){
            for(int j=0; j<k; j++){
                if(dp[j]+value[i] < dp[j|keybit[i]]){
                    dp[j|keybit[i]] = dp[j]+value[i];
                }
            }
        }
        
        if(dp[k-1] != INF){
            System.out.println(dp[k-1]);
        }else{
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 28836
import sys

sys.setrecursionlimit(2000000000)


class Node:
    def __init__(self, index):
        self.index = index
        self.connected_indices = set()


def build_graph(nodes, curr_index, connected_indices, reached_indices):
    # already reached
    if curr_index in connected_indices or curr_index in reached_indices:
        return

    connected_indices |= {curr_index}
    reached_indices |= {curr_index}

    unreached_indices = nodes[curr_index].connected_indices - connected_indices

    for i in unreached_indices:
        build_graph(nodes, i, connected_indices, reached_indices)

    return connected_indices


if __name__ == '__main__':
    N, M = map(int, input().split())
    p = [int(v) - 1 for v in input().split()]

    nodes = [Node(i) for i in range(N)]
    for _ in range(M):
        xy_str = input().split()
        x, y = int(xy_str[0]) - 1, int(xy_str[1]) - 1

        # link neighbors
        nodes[x].connected_indices |= {y}
        nodes[y].connected_indices |= {x}

    reached_indices = set()
    all_connected_indices = [None] * N
    for i in range(N):
        connected_indices = build_graph(nodes, i, set(), reached_indices)
        if connected_indices is None:
            continue

        for c in connected_indices:
            all_connected_indices[c] = connected_indices

    answer = sum([p[i] in all_connected_indices[i] for i in range(N)])
    print(answer)


Measured memory_bytes: 135252
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
	int face[6];
	int q, upper, front;
	bool is_asc;

	cin >> face[0] >> face[1] >> face[2] >> face[3] >> face[4] >> face[5];

	int dice[][4] = {
		{face[1], face[2], face[4], face[3]},
		{face[2], face[0], face[3], face[5]},
		{face[0], face[1], face[5], face[4]}
	};

	cin >> q;

	for(int i = 0; i < q; i++){
		cin >> upper >> front;

		is_asc = false;
		if ((upper == face[0] || upper == face[5] || front == face[0] || front == face[5]) && (upper == face[1] || upper == face[4] || front == face[1] || front == face[4])){
			for(int j = 0; j < 4; j++){
				if (dice[2][j] == upper && dice[2][(j + 1) % 4] == front){
					is_asc = true;
					break;
				}
			}
			cout << (is_asc ? face[2] : face[3]) << endl;
		}
		else if ((upper == face[0] || upper == face[5] || front == face[0] || front == face[5]) && (upper == face[2] || upper == face[3] || front == face[2] || front == face[3])) {
			for(int j = 0; j < 4; j++){
				if (dice[1][j] == upper && dice[1][(j + 1) % 4] == front){
					is_asc = true;
					break;
				}
			}
			cout << (is_asc ? face[1] : face[4]) << endl;
		}
		else if ((upper == face[1] || upper == face[4] || front == face[1] || front == face[4]) && (upper == face[2] || upper == face[3] || front == face[2] || front == face[3])) {
			for(int j = 0; j < 4; j++){
				if (dice[0][j] == upper && dice[0][(j + 1) % 4] == front){
					is_asc = true;
					break;
				}
			}
			cout << (is_asc ? face[0] : face[5]) << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)


using namespace std;
using ll = long long;

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



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s;
    int ans;
    cin >> s;
    string a[7]={"SUN","SAT","FRI","THU","WED","TUE","MON"};
    rep(i,7){
        if(a[i] == s) ans = i;
    }
    if(ans == 0) ans = 7;
    cout << ans << endl;
   

    return 0;
}


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

s1 = [0]
for i in range(n):
    s1.append(s1[-1]+a[i])

s2 = [0]
for i in range(m):
    s2.append(s2[-1]+b[i])
ans = 0
j = m
for i in range(n+1):
    
    if k-s1[i]<0:
        break
    while k-s1[i]-s2[j]<0 and j>0:
            j -= 1 
    ans = max(i+j,ans)
print(ans)




Measured memory_bytes: 47452
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
bool jud(int m) {
	return m > 1 && n / m == n % m;
}
signed main() {
	cin >> n;
	int ans = 0;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans += jud(i - 1) * (i - 1);
			ans += jud(n / i - 1) * (n / i - 1);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc132_b

n = int(input())
p = list(map(int, input().strip().split()))

res = 0
for i in range(n-2):
    if p[i] > p[i+1] and p[i+1] >= p[i+2]:
        res += 1
        continue
    if p[i] <= p[i+1] and p[i+1] < p[i+2]:
        res += 1
        continue

print(res)



Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  string S; cin >> S;
  string E = "AKIHABARA";

  for (int i = 0; i < E.size(); ++i) {
    if ((i < S.size() and S[i] != E[i]) or (i == S.size())) {
      if (E[i] == 'A') S.insert(i, "A");
    } else if (i < S.size() and S[i] == E[i]) {
      continue;
    } else {
      break;
    }
  }

  if (S != E) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        int I = i;
        double tmp = 1;
        while(I < k){
            I *= 2;
            tmp *= 0.5;
        }
        ans += tmp;
    }
    printf("%.9f\n", ans / n);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vrep(i,a,b) for(__typeof(b) i=a-(a>b);i!=b-(a>b);i+=1-2*(a>b))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=n-1;i>=a;i--)
#define SZ(x) ((int)(x).size())
#define all(a) begin(a), end(a)

#define eb emplace_back
#define mt make_tuple
#define pb push_back
#define f first
#define s second

typedef  pair<int, int>   pii;
typedef   vector<int>     vi;
typedef    long long      ll;
//for debug
#define debug(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define rangei(a,L,R) {vrep(i,L,R) cout << a[i] <<' '; cout<<endl;}
#define range(a) rangei(a,0,a.size())
#define rangei_2d(a,L,R){vrep(j,L,R) cout<<a[i][j]<<' '; cout<<endl;}
#define range_2d(a) { rep(i,0,SZ(a)){rangei_2d(a,0,SZ(a[0]));} }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,w;
	cin>>n>>w;

	vi weight(n),value(n);
	rep(i,0,n)cin>>weight[i]>>value[i];

	vector<ll> dp(w+1);
	rep(i,1,w+1){
		if(i>=weight[0])
			dp[i]=value[0];
	}

	rep(i,1,n){
		rrep(j,1,w+1){
			if(j>=weight[i])
				dp[j]=max(dp[j],dp[j-weight[i]]+value[i]);	
		}
	}
	cout<<dp[w]<<endl;
	return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int year, month, day;
    std::string s;

    std::cin >> s;

    year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
    month = (s[5] - '0') * 10 + (s[6] - '0');
    day = (s[8] - '0') * 10 + (s[9] - '0');

    if(year < 2019){
        std::cout << "Heise";
        return 0;
    } 
    else if(year == 2019 && month <= 4){
        std::cout << "Heisei";

        return 0;
    }

    std::cout <<"TBD";
    return 0;
}

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

using namespace std;
int  main()
{
	int N;
	cin >> N;
	list<long double> V;
	//vector<int> V(N);
	for (int i = 0; i < N; ++i) {
		int v;
		cin >> v;
		V.push_back((long double)v);
	}
	V.sort();
	
	while (V.size() >= 2) 
	{
		long double v0 = V.front();
		V.pop_front();
		long double v1 = V.front();
		V.pop_front();
		V.push_front((v0 + v1) / 2.0);
	}
	cout << fixed << setprecision(20) << V.front();


	return 0;
}


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

int W, H, cost[102][102], N, hx[5], hy[5], sx, sy, gx, gy;
string grid[102];

const int dx[4] = {0,1,0,-1}, Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int dy[4] = {1,0,-1,0}, Dy[8] = {1,1,0,-1,-1,-1,0,1};
bool in_range(int x, int y) { return 0 <= x && x < W && 0 <= y && y < H; }

void pre() {
	memset(cost, -1, sizeof(cost));
	
	N = 0;
	for (int y=0; y<H; ++y) for (int x=0; x<W; ++x) {
		if (grid[y][x] == '#') cost[y][x] = 100;
		if (grid[y][x] == 'M') {
			hx[N] = x;
			hy[N] = y;
			++N;
		}
		if (grid[y][x] == 'S') sx = x, sy = y;
		if (grid[y][x] == 'G') gx = x, gy = y;
	}
	
	for (int y=0; y<H; ++y) for (int x=0; x<W; ++x) {
		if (cost[y][x] < 0) {
			bool hole_flag = false;
			for (int d=0; d<8; ++d) {
				int nx = x + Dx[d], ny = y + Dy[d];
				if (!in_range(nx, ny)) continue;
				hole_flag |= (grid[ny][nx] == '#');
			}
			if (hole_flag) cost[y][x] = 3;
		}
	}
	
	for (int y=0; y<H; ++y) for (int x=0; x<W; ++x) {
		if (cost[y][x] < 0) {
			int max_c = -1;
			for (int d=0; d<8; ++d) {
				int nx = x + Dx[d], ny = y + Dy[d];
				if (!in_range(nx, ny)) continue;
				max_c = max(max_c, cost[ny][nx]);
			}
			cost[y][x] = max_c - 1;
		}
	}
	
	for (int y=0; y<H; ++y) for (int x=0; x<W; ++x) if (cost[y][x] <= 0) cost[y][x] = 1;
}

	
struct State {
	int x, y, c;
	bool operator > (const State& s) const { return c > s.c; }
};

int dst[102][102];

int dijkstra(int ax, int ay, int bx, int by) {
	memset(dst, -1, sizeof(dst));
	
	priority_queue< State, vector< State >, greater< State > > que;
	que.push(State{ax, ay, 0});
	dst[ay][ax] = 0;
	
	while (!que.empty()) {
		State s = que.top(); que.pop();
		if (dst[s.y][s.x] < s.c) continue;
		for (int d=0; d<4; ++d) {
			int nx = s.x + dx[d], ny = s.y + dy[d], nc = s.c + cost[s.y][s.x];
			if (!in_range(nx, ny)) continue;
			if (grid[ny][nx] == '#') continue;
			if (dst[ny][nx] == -1 || dst[ny][nx] > nc) {
				dst[ny][nx] = nc;
				que.push(State{nx, ny, nc});
			}
		}
	}
	
	return dst[by][bx];
}

int main() {
	cin >> W >> H;
	for (int y=0; y<H; ++y) cin >> grid[y];
	
	pre();
	
	vector< int > order;
	for (int i=0; i<N; ++i) order.push_back(i);
	
	int ans = 1L << 30;
	do {
		int sum = dijkstra(sx, sy, hx[order[0]], hy[order[0]]);
		for (int i=0; i<N-1; ++i) {
			int a = order[i], b = order[i+1];
			sum += dijkstra(hx[a], hy[a], hx[b], hy[b]);
		}
		sum += dijkstra(hx[order[N-1]], hy[order[N-1]], gx, gy);
		ans = min(ans, sum);
	} while (next_permutation(order.begin(), order.end()));
	cout << ans << endl;
}


Measured memory_bytes: 3316
/* ex2_3
   seira3 */

#include <stdio.h>

int main(void){
    int N, A; //変数宣言
    scanf("%d",&N); //Nに入力
    scanf("%d",&A); //Aに入力
    printf("%d\n",(N*N-A)); //黒色のマスの個数(N*N-A)を出力
    return 0;
}

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double ld;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

const int MOD = 1e9+7;

int s[100009];

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N, M;
    scanf("%d%d",&N,&M);

    times(M, i) {
        int A, B;
        scanf("%d%d",&A,&B);
        s[A-1]++;
        s[B-1]--;
    }

    times(N, i) {
        if(s[i] % 2) {
            cout << "NO\n";
            return false;
        }
        s[i+1] += s[i];
    }
    cout << "YES\n";

    return 0;
}


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

 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    long double v[n],sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v,v+n);
    sum=((v[0]+v[1])/2);
    for(ll i=2;i<n;i++)
    sum=((v[i]+sum)/2);
    cout<<fixed<<setprecision(7)<<sum;

	return 0;
}


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

const int N = (int)1e5;
int res[N + 5];

vector< pair<int,int> > adjList[N+5];

int dfs(int u, int par, int used_color) {
    int ret = 0;
    int color = 0;

    for (pair<int,int> v: adjList[u]) if (v.first != par) {
        while (++color == used_color);
        res[v.second] = color;

        ret = max(ret, dfs(v.first, u, color));
    }
    return max(ret, color);
}

int main() {
    for (int i=0; i<N+3; i++) {
        adjList[i].clear();
        res[i] = -1;
    }

    int n; scanf("%d", &n);
    for (int i=1; i<=n-1; i++) {
        int u,v; scanf("%d %d", &u, &v);
        adjList[u].push_back(make_pair(v,i));
        adjList[v].push_back(make_pair(u,i));
    }

    int ret = dfs(1, -1, -1);

    printf("%d\n", ret);
    for (int i=1; i<=n-1; i++) printf("%d\n", res[i]);
    return 0;
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
#define CoutV(vec)     \
    for (auto v : vec) \
        Cout(v);
#define CoutVV(vecvec)      \
    for (auto vec : vecvec) \
        CoutV(vec);

using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;
//int t[10010];

int main()
{

    int n, m, x, y;
    cin >> n >> m >> x >> y;

    vector<int> X(n), Y(m);
    REP(i, n)
    cin >> X[i];
    REP(i, m)
    cin >> Y[i];

    int xmax = x;
    int ymin = y;
    REP(i, n)
    xmax = max(xmax, X[i]);
    REP(i, m)
    ymin = min(ymin, Y[i]);
    if (xmax < ymin)
    {
        cout << "No War" << endl;
    }
    else
    {
        cout << "War" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    tmp=0
    for j in range(m):
        tmp+=a[j]*b[j]
    if tmp+c>0:
        ans+=1

print(ans)


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

#define D 10

int d, g;
int p[D];
int c[D];

int main()
{
	int ans = INT32_MAX;

	cin >> d >> g;
	for( int i = 0; i < d; i++ ) {
		cin >> p[i] >> c[i];
	}

	for( int mask = 0; mask < (1 << d); mask++ ) {
		int num = 0, s = 0, rest_i = -1;
		for( int i = 0; i < d; i++ ) {
			if( mask & (1 << i) ) {
				s += 100 * (i + 1) * p[i] + c[i];
				num += p[i];
			}
			else {
				rest_i = i;
			}
		}
		if( s < g ) {
			if( rest_i < 0 ) {
				continue;
			}
			int s1 = 100 * (rest_i + 1);
			int n = (g - s + s1 - 1) / s1;
			if( n > p[rest_i] ) {
				continue;
			}
			num += n;
		}
		ans = min( ans, num );
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#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() {
    string t;
    cin >> t;
    int length = t.size();
    rep(i, length){
        if(t[i] == '?'){
            t[i] = 'D';
        }

    }

    cout << t << endl;

    return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  cout << pow(2, k) * (1900 * k + 100 * (n - k)) << endl;
}


Measured memory_bytes: 256
####### 二項係数 C(n,k) mod pの計算 #######

MOD=10**9+7
FACT=[]
INV=[]

## a**b mod p by 繰り返し二乗法 ##
def pow(a,b)
  return 1 if b==0
  return a*pow(a,b-1)%MOD if b%2==1
  return pow(a**2%MOD,b/2)
end

## n! mod p ##
def fact(n)
  ret=1
  n.times do |i|
    ret=ret*(i+1)%MOD
  end
  ret
end

## a**(-1) mod p ##
def inv(n)
  pow(n,MOD-2)%MOD
end

## FACT[n],INV[n] mod p ##
def calc_fact(n)
  FACT[0]=1
  INV[0]=pow(FACT[0],MOD-2)
  for i in 1..n
    FACT[i]=FACT[i-1]*i%MOD
    INV[i]=pow(FACT[i],MOD-2)
  end
end

## C(n,k) mod p ##
def com(n,k)
  (fact(n)*inv(fact(k)))%MOD*inv(fact(n-k))%MOD
end

## C(n,k) mod p (10**5>>k version) ##
def frac(n,k)
  a=1
  b=1
  k.times do |i|
    b*=i+1
    b%=MOD
  end
  k.times do |i|
    j=i+1
    a*=n-i
    a%=MOD
  end
  a*inv(b)%MOD
end

## C(n,k) mod p (n,k>10**5 version) ##
def conv(n,k)
  (FACT[n]*INV[n-k]%MOD)*INV[k]%MOD
end

##########################################


N,A,B=gets.split.map(&:to_i)
ans=pow(2,N)-1
ans+=MOD-frac(N,A)
ans+=MOD-frac(N,B)
puts ans%MOD

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);


int N,K;cin>>N>>K;
  int ans=1;
  int counter=0;
while(N>=ans){ans*=K;
             counter++;
            }
  cout<<counter<<endl;
  
}


Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

// ll frac_a_b(ll a, ll b)
// {
//     auto ans{1ll};

//     if (a < b)
//         std::swap(a, b);

//     for (auto i = a + b, j = 1ll; i > a; --i, ++j)
//     {
//         ans *= i;
//         if (j <= b)
//             ans /= j;
//     }

//     return ans;
// }

int main()
{
    using namespace std;

    int n, h, w;
    cin >> n >> h >> w;

    auto ans = (n - w + 1) * (n - h + 1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll x,a,b; cin >> x >> a >> b;
    if(b<=a) puts("delicious");
    else if(b<=a+x) puts("safe");
    else puts("dangerous");
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			String s=in.nextLine();
			boolean judge=false;
			if(s.equals("1 1 0")||s.equals("0 0 1"))
				judge=true;
			
			System.out.println(judge ? "Open" : "Close");
		}
	}
}

Measured memory_bytes: 17140
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(void){
    
    long int n,ans=0,sum=1;
    int a[222];
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    while(1){
        sum*=2;
        for(int i=0;i<n;i++){
            if(a[i]%sum!=0)goto nokillingfrog;
        }
        ans++;
    }
    nokillingfrog:
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = int(input())
c = "SHCD"

card = [[0] * 13 for i in range(4)]
for i in range(n):
    a,b = input().split()
    card[c.find(a)][int(b)-1] = 1
for i in range(4):
    for j in range(13):
        if card[i][j] == 0:
            print(c[i], j+1)


Measured memory_bytes: 5608