akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>
#include<queue>
#include<cmath>

using namespace std;

typedef long long int64;

int main(void){
    int64 x,y;
    cin>>x>>y;
    for (int64 i = 0; i <= x; i++)
    {
        if(i*2+(x-i)*4==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int a,b,c;
cin>>a;
cin>>b>>c;
for(int i=b;i<=c;i++)

	if(i%a==0)
	{
		cout<<"OK";
		return 0;
	}



		cout<<"NG";





return 0;

}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

ll n,_10[17],_99[17];

char AI(string s) {
  string t = s.substr(2);
  ll v = atoll(t.c_str());
  if( s[0] == '?' ) {
    if( v <= n && t <= to_string(n) ) return 'Y';
    if( v >  n && t >  to_string(n) ) return 'Y';
    return 'N';
  } else {
    if( n == v ) return 'Y';
    else return 'N';
  }
}

/*
  123 < 124
  999 < 9999

  10^x と 9{x} で桁数は決まる ( 4 * 2 )
 */
void compute() {
  ll keta = 0;
  _10[0] = 1, _99[0] = 9;
  REP(i,1,17) {
    _10[i] = _10[i-1] * 10LL;
    _99[i] = _99[i-1] * 10LL + 9LL;
  }
  
  {
    ll L = 0, R = 10;
    while( R - L ){
      ll M = ( L + R ) / 2LL;
      cout << "? "+to_string(_10[M]) << endl;
      //char c = AI("? "+to_string(_10[M]));
      char c;
      cin >> c;
      if( c == 'Y' ) L = M + 1LL;
      else           R = M;  
    }
    if( L-1LL == 9LL ) {
      keta = -1;
    } else {
      keta = L;
    }
  }

  if( keta == -1 ) {
    ll L = 0, R = 10;
    while( R - L ){
      ll M = ( L + R ) / 2LL;
      cout << "? "+to_string(_99[M]) << endl;
      //char c = AI("? "+to_string(_99[M]));
      char c;
      cin >> c;
      if( c == 'N' ) L = M + 1LL;
      else           R = M;  
    }
    if( L-1LL == 9LL ) {
      keta = -1;
    } else {
      keta = L+1;
    }
  }

  if( keta == 1 ) {
    cout << "? 10" << endl;
    //char c = AI("? 10");
    char c;
    cin >> c;
    if( c == 'Y' ) {
      cout <<"! 1" << endl;
      return;
    }
  }

  string s = "";
  rep(i,keta) {
    ll L = 0, R = 10;
    while( R - L ){
      ll M = ( L + R ) / 2LL;
      cout << "? "+s+to_string(M) << endl;
      //char c = AI("? "+s+to_string(M));
      char c;
      cin >> c;
      if( c == 'Y' ) L = M + 1LL;
      else           R = M;  
    }
    s += to_string(L-1LL);
  }
  //cout << "! " << s << endl;
  s = s.substr(0,(int)s.size()-1);

  {  
    ll L = 0, R = 10;
    while( R - L ){
      ll M = ( L + R ) / 2LL;
      cout << "? "+s+to_string(M)+"1" << endl;
      //char c = AI("? "+s+to_string(M)+"1");
      char c;
      cin >> c;
      if( c == 'N' ) L = M + 1LL;
      else           R = M;  
    }
    cout << "! " << s + to_string(L) << endl;
  }
  
}

void test() {
  cin >> n;
  /*
  cin.ignore();
  rep(i,64) {
    string s;
    getline(cin,s);
    cout << AI(s) << endl;
    if( s[0] == '!' ) {
      return;
    }
  }
  */
  compute();
}

int main() {
  //test();
  compute();
  return 0;
}


Measured memory_bytes: 596
#include<iostream>
using namespace std;
int main() {
    int n;
    cin >> n; //10^5
    int v[n];
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int Max = 100000;
    int weight1[Max + 1];
    int weight2[Max + 1];
    for (int i = 1; i <= Max; ++i) {
        weight1[i] = 0;
        weight2[i] = 0;
    }
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            weight1[v[i]]++;
        } else {
            weight2[v[i]]++;
        }
    }
    int w1 = 0, w2 = 0;
    int id1 = -1, id2 = -1;
    for (int i = 1; i <= Max; ++i) {
        if (w1 < weight1[i]) {
            w1 = weight1[i];
            id1 = i;
        }
        if (w2 < weight2[i]) {
            w2 = weight2[i];
            id2 = i;
        }
    }
    if (id1 != id2) {
        cout << (n + 1) / 2 - w1 + n / 2 - w2 << endl;
        return 0;
    } else {
        if (w1 > w2) {
            w2 = 0;
            for (int i = 1; i <= Max; ++i) {
                if (w2 < weight2[i] && i != id2) {
                    w2 = weight2[i];
                }
            }
        } else if (w1 < w2){
            w1 = 0;
            for (int i = 1; i <= Max; ++i) {
                if (w1 < weight1[i] && i != id1) {
                    w1 = weight1[i];
                }
            }
        } else if (w1 == w2) {
            int w11 = 0, w22 = 0;
            for (int i = 1; i <= Max; ++i) {
                if (w11 < weight1[i] && i != id1) {
                    w11 = weight1[i];
                }
                if (w22 < weight2[i] && i != id2) {
                    w22 = weight2[i];
                }
            }
            if (w11 > w22) {
                w1 = w11;
            } else if (w11 < w22) {
                w2 = w22;
            } else if (w11 == w22) {
                w1 = w11; //どっちでもいいか
            }
        }
    }
    cout << (n + 1) / 2 - w1 + n / 2 - w2 << endl;
    return 0;
}




Measured memory_bytes: 1408
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5+1;
vector<int> children[L];
int f(int i)
{
	vector<int> ds;
	for(int c:children[i]){
		ds.push_back(f(c));
	}
	sort(ds.rbegin(),ds.rend());
	int ret=0;
	int v=1;
	for(int d:ds){
		ret=max(ret,d+v);
		v++;
	}
	return ret;
}
int main() {
	int N;
	cin >> N;
	for(int i=2;i<=N;i++){
		int v;
		cin >> v; 
		children[v].push_back(i);
	}
	cout << f(1) << endl;


	return 0;
}



Measured memory_bytes: 16640
def main():
    x,y,a,b,c=map(int,input().split())
    P=list(map(int,input().split()))
    P.sort(reverse=True)
    Q=list(map(int,input().split()))
    Q.sort(reverse=True)
    R=list(map(int,input().split()))
    R.sort(reverse=True)
    PQ=P[:x]+Q[:y]
    ans=sum(PQ)
    PQ.sort()
    r=0
    for pq in PQ:
        if r>=c:
            break
        else:
            if pq<R[r]:
                ans-=pq
                ans+=R[r]
                r+=1
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 105444
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0, i##_len=(N); i<i##_len; i++)
#define RREP(i, N) for(int i=1, i##_len=(N); i<i##_len; i++)
#define REPP(i, N) for(int i=0, i##_len=(N); i<=i##_len; i++)
#define RREPP(i, N) for(int i=1, i##_len=(N); i<=i##_len; i++)
#define P(x) cout << (x)
#define pb push_back
using ll = long long;
using namespace std;

int A, B, K, cnt;

int main() {
    cin >> A >> B >> K;
    int i = min({A, B});
    while (cnt < K) {
        if (A%i+B%i == 0)
            cnt++;
        i--;
    }
    cout << ++i;
    return 0;
}


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

template <typename T> void chmin(T&x,const T &y)
{
	if(x>y)x=y;
}
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef int64_t s64;
typedef uint64_t u64;
typedef uint32_t u32;
typedef pair<int,int> pii;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)
#define gc (c=getchar())
int read()
{
	char c;
	while(gc<'-');
	if(c=='-')
	{
		int x=gc-'0';
		while(gc>='0')x=x*10+c-'0';
		return -x;
	}
	int x=c-'0';
	while(gc>='0')x=x*10+c-'0';
	return x;
}
#undef gc

const int N=2e5+5;
char s[N];

void out()
{
	puts("No");
	exit(0);
}
void check(int l,int r)
{
	rep(i,l,r-1)
	if(s[i]=='#'&&s[i+1]=='#')out();
}

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);//freopen("1.out","w",stdout);
#endif
	int n,A,B,C,D;
	cin>>n>>A>>B>>C>>D;
	scanf("%s",s+1);
	check(A,C);
	check(B,D);
	if(C>D)
	{
		bool ok=0;
		rep(i,B,D)
		if(s[i]=='.'&&s[i-1]=='.'&&s[i+1]=='.')ok=1;
		if(!ok)out();
	}
	puts("Yes");
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <queue>
#include <string>
using namespace std;
struct task {
	string name;
	int time;
};
queue<task> q;
int main(void)
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	task t;
	while (n--)
	{
		cin >> t.name >> t.time;
		q.push(t);
	}
	int ans = 0;
	while (!q.empty())
	{
		t = q.front();
		q.pop();
		if (t.time > m)
		{
			ans += m;
			t.time -= m;
			q.push(t);
		}
		else
		{
			ans += t.time;
			printf("%s %d\n", t.name.c_str(), ans);
		}
	}
	return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(){
    int N, L;
    cin >> N >> L;
    int ans, sum;
    sum = (L + L + N - 1) * N / 2;
    if(L > 0) ans = sum - L;
    else if(abs(L) < N) ans = sum;
    else ans = sum - (L + N - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,a[5],x,s=0;
	for(i=0;i<5;i++)
	{
		cin>>a[i];		
	}
	
	for(i=1;i<5;i++)
	{
		x=a[i]%10;
		if(x==0)
		{
			x=10;
		}
		
		if(x>a[i-1]%10)
		{
			int s;
			s=a[i];
			a[i]=a[i-1];
			a[i-1]=s;
			
		}
		
		
	}
	for(i=0;i<5;i++)
	{
		
		if(a[i]%10!=0 && i!=4)
		{
			a[i]=a[i]+(10-a[i]%10);
		}
		s=s+a[i];
	}
	cout<<s<<endl;
	
	
	
}

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

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin >> x;
    cout << !x << '\n';

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    if(a == b) cout << c << endl;
    if(a == c) cout << b << endl;
    if(b == c) cout << a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

vector<int> E[100001], IE[100001];
int num = 1;
int topo[100001], visit[100001];
void dfs(int v) {
	if (visit[v]) return;
	for (int to : E[v]) {
		dfs(to);
	}
	visit[v] = 1;
	topo[v] = num++;
}

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


	int N, M;
	cin >> N >> M;
	bool kodomo[100001] = {};
	rep(i, N + M - 1) {
		int a, b;
		cin >> a >> b;
		E[a].pb(b);
		IE[b].pb(a);
		kodomo[b] = 1;
	}

	int rt = 0;
	rep1(i, N) if (!kodomo[i]) {
		rt = i;
		break;
	}

	dfs(rt);
	rep1(i, N) {
		int kotae = 0;
		int saishou = 1e9;
		if (rt == i) kotae = 0;
		else {
			for (int u : IE[i]) {
				if (saishou > topo[u]) {
					saishou = topo[u];
					kotae = u;
				}
			}
		}
		co(kotae);
	}

	Would you please return 0;
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define sz(x)          (int) x.size()
#define MOD 1000000007
#define EPS 1e-7
#define lp(i, o, m)     for(int i = o; i<=m ; i++)
#define lol(x)        if(n==x){ cal(); continue;}

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;

struct qq{
    int a, b, c, d;

    bool operator < (const qq &x) const
    {
        return d > x.d;
    }
}arr[50];

 int n, m, q;

ll mx = 0;
int v[11];
void cal(){
    ll sum  = 0;
//    for(int i  = 1; i<=n; i++)
//        cout<<v[i]<<" "; cout<<endl;
    for(int i = 0; i<q; i++){
        if(v[arr[i].b] - v[arr[i].a] == arr[i].c) sum += arr[i].d;
    }
    mx = max(mx, sum);
}
int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    cin>>n>>m>>q;

    for(int i =0; i<q; i++)cin>>arr[i].a>>arr[i].b>>arr[i].c>>arr[i].d;

        lp(i, 1, m){
            v[1] = i;
           lp(i2, i, m){
                v[2] = i2;
                lol(2);
                lp(i3, i2, m){
                    v[3] = i3;
                    lol(3);
                    lp(i4, i3, m){
                        v[4] = i4;
                        lol(4);
                        lp(i5, i4, m){
                            v[5] = i5;
                            lol(5);
                            lp(i6, i5, m){
                                v[6] = i6;
                                lol(6);
                                lp(i7, i6, m){
                                    v[7]  = i7;
                                    lol(7);
                                    lp(i8, i7, m){
                                        v[8] = i8;
                                        lol(8);
                                        lp(i9, i8, m){
                                            v[9] = i9;
                                            lol(9);
                                            lp(i10, i9, m){
                                                v[10] = i10;
                                                cal();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
    }
    cout<<mx;
	return 0;
}


Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    FastScanner fs = new FastScanner();
    String s = fs.next();
    int maxCount = 0;
    int idx = 0;
    while (idx < 3) {
      int start = idx;
      while (idx < 3 && s.charAt(idx) == 'R') {
        idx++;
      }
      maxCount = Math.max(maxCount, idx - start);
      idx++;
    }
    System.out.println(maxCount);
  }

  static class FastScanner {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");

    String next() {
      while (!st.hasMoreTokens()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    int[] readArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    long nextLong() {
      return Long.parseLong(next());
    }
  }
}


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

int main(void){
    int N;
    cin>>N;
    int odd = 1;
    rep(i,N){
        int a;
        cin>>a;
        if(a%2==0) odd*=2;
    }
    cout<<pow(3,N)-odd<<endl;
    return 0;
}


Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][10000],a[200000], b[2000000];
string str, ss, dd;
bool f,ff;
char c[10000][10000];
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> h >> w;
	rep(i,h)
		rep(j, w) {
		cin >> c[i][j];
		if (c[i][j] != '#')
			ans++;
	}
	rep(i, h)
		rep(j, w)
		dp[i][j] = INF;
	queue<Pll>q;
	dp[0][0] = 0;
	q.push(Pll(0, 1));
	while (!q.empty()) {
		Pll v = q.front();
		q.pop();
		v.sec++;
		rep(i, 4) {
			LL X = v.fir%h+di[i][0], Y = v.fir / h+di[i][1];
			if (X < h&&X >= 0 && Y < w&&Y >= 0 && dp[X][Y] > v.sec&&c[X][Y]!='#') {
				dp[X][Y] = v.sec;
				q.push(Pll(X+Y*h,v.sec));
			}
		}
	}
	cout << (dp[h-1][w-1] == INF ? -1 :ans-dp[h-1][w-1]) << endl;
	return 0;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<cstring>
#include <cstdio>
#include<cmath>

typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

int main ()
{
    int a,b;
    cin>>a>>b;
    if (a<=b || a<=2*b) cout<<"0"<<endl;
    else cout<<a-2*b<<endl;

    return 0;
}



Measured memory_bytes: 256
import heapq
N,M = map(int,input().split())
A=[-int(i) for i in input().split()]
heapq.heapify(A)
for _ in range(M):
    s = heapq.heappop(A)
    if s % 2 == 0:
        heapq.heappush(A, s//2)
    else:
        heapq.heappush(A, s//2 + 1)
print(-sum(A))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(bool f){
    cout << (f ? "Alice" : "Brown") << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x, y;
    cin >> x >> y;
    pr(abs(x-y) > 1);
    return 0;
}

Measured memory_bytes: 256
INF = 10**9

N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))
W = [[INF for _ in range(N+1)] for __ in range(N+1)]
for i in range(1, N+1):
    W[i][i] = 0

for _ in range(M):
    A, B, C = list(map(int, input().split()))
    W[A][B] = C
    W[B][A] = C

import heapq

for i in range(1, N+1):
    heap = []
    checked = [False for _ in range(N+1)]
    for j in range(1, i+1):
        heapq.heappush(heap, (W[i][j], j))
    while len(heap) > 0:
        wij, j = heapq.heappop(heap)
        if checked[j]:
            continue
        for k in range(i+1, N+1):
            wik = wij + W[j][k]
            if wik <= W[i][k]:
                W[i][k] = wik
                W[k][i] = wik
                heapq.heappush(heap, (wik, k))
        checked[j] = True

from itertools import permutations

ans = INF
for r_ in permutations(r):
    count = 0
    for i in range(R-1):
        x = W[r_[i]][r_[i+1]]
        if x >= INF:
            break
        count += x
        if count >= ans:
            break
    else:
        ans = count
print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	int N;
	cin >> N;

	string S;
	cin >> S;

	stack<char> stk;
	for (int i = 0; i < N; ++i) {
		if (stk.empty() || stk.top() != S[i]) stk.push(S[i]);
	}

	cout << sz(stk);

	return 0;
}

Measured memory_bytes: 512
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 1000000000000000000
#define N 1000000007
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

vector<int> s, t;
vector<vector<int>> dp;
vector<vector<bool> > done;
int f(int n,int m){
	if(done[n][m]){return dp[n][m];}
	done[n][m]=1;	
	if(n==0 or m==0){dp[n][m]=1;return dp[n][m];}
	if(s[n-1]!=t[m-1]){
		dp[n][m]=f(n-1,m)+f(n,m-1)-f(n-1,m-1);
		dp[n][m]%=N;
	}
	else{
		dp[n][m]=f(n-1,m)+f(n,m-1);
		dp[n][m]%=N;
	}
	return dp[n][m];
}
//edge cases when n=1 , m=1. wrong variable in loop. if<->while;merge resize;LLONG_MAX
signed main()
{
	speed
	//global var

	int n,m;cin>>n>>m;
	dp.resize(n+1,vector<int> (m+1));
	done.resize(n+1,vector<bool>(m+1,0));
	s.resize(n);t.resize(m);
	for(int i=0;i<n;++i){cin>>s[i];}
	for (int i = 0; i < m; ++i)
	{
		cin>>t[i];
	}
	int ans=f(n,m);ans%=N;ans+=N;ans%=N;
	cout<<ans;
}

Measured memory_bytes: 32512
#include <iostream>

using namespace std;

#define lli long long int

lli min(lli a,lli b){
	if(a>=b)return b;
	else return a;
}

int main(){

	lli a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;

	lli cost = 0;
	if((c*2)<=(a+b)){
		cost += min(x,y)*(c*2);
		x -= cost/(c*2);
		y -= cost/(c*2);
	}
	if(x>0){
		cost += min(a,c*2)*x;
		x=0;
	}
	if(y>0){
		cost += min(b,c*2)*y;
		y=0;
	}

	cout<<cost<<endl;

	return 0;
}

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

using namespace std;
struct node{
	int x, y;
};
node a[100010];
bool cmp(node x, node y) {
	return x.x < y.x;
}
int main(){
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++){
		scanf("%d",&a[i].x);
		a[i].y = i;
	}
	sort(a+1, a+n+1, cmp);
	for (int i = 1; i <= n; i++){
		if(i > 1) printf(" ");
		printf("%d", a[i].y);
	}
	return 0;
} 

Measured memory_bytes: 1536
U, F, R, L, B, D = range(6)
while True:
    n = int(input())
    if n == 0:
        break
    s = list(range(1, 6 + 1))
    result = 1
    for _ in range(n):
        raw = input()
        assert raw.find('\t') == -1
        op = raw.strip()
        if op == "North":
            s[U], s[F], s[D], s[B] = s[F], s[D], s[B], s[U]
        elif op == "South":
            s[U], s[F], s[D], s[B] = s[B], s[U], s[F], s[D]
        elif op == "West":
            s[U], s[R], s[D], s[L] = s[R], s[D], s[L], s[U]
        elif op == "East":
            s[U], s[R], s[D], s[L] = s[L], s[U], s[R], s[D]
        elif op == "Right":
            s[F], s[R], s[B], s[L] = s[R], s[B], s[L], s[F]
        elif op == "Left":
            s[F], s[R], s[B], s[L] = s[L], s[F], s[R], s[B]
        else:
            assert False
        result += s[U]
    print(result)


Measured memory_bytes: 5632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        System.out.println((N == 1 ? 1L : (long) (N - 2)) * (M == 1 ? 1L : (long) (M - 2)));
    }

}



Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
from bisect import bisect_left
def inpl(): return list(map(int, input().split()))

N = int(input())
A = []
B = []
for i in range(2**16):
    A.append(int(("0{}"*16).format(*list(bin(i)[2:].zfill(16))), 2))
for i in range(2**16):
    B.append(-int(("{}0"*16).format(*list(bin(i)[2:].zfill(16))), 2))

for j, b in enumerate(B):
    i = bisect_left(A, N-b)
    if i == len(A):
        continue
    a = A[i]
    if a+b == N:
        ans = [""]*32
        ans[::2] = list(bin(j)[2:].zfill(16))
        ans[1::2] = list(bin(i)[2:].zfill(16))
        print(int("".join(ans)))
        break

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


int main() {
	int n; cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	sort(v.begin(), v.end());
	double c = v[0];
	for (int i = 1; i < n; i++) {
		c = (c + v[i]) / 2.;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func PrimeFactorsMap(n int) map[int]int {
	pfs := map[int]int{}
	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2]++
		} else {
			pfs[2] = 1
		}
		//pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i]++
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		if _, ok := pfs[n]; ok {
			pfs[n]++
		} else {
			pfs[n] = 1
		}
	}

	return pfs
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()

	if N%1000 == 0 {
		fmt.Println(0)
		return
	}
	fmt.Println(1000 - N%1000)

}


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

int main(){
  ll A,B,X;
  cin >> A >> B >> X;
  if(A==0){
    cout << (B/X+1) << endl;
    return 0;
  }
  cout << (B/X+1)-((A-1)/X+1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll e=b/c-(a-1)/c;
    ll f=b/d-(a-1)/d;
    ll temp=c/__gcd(c,d)*d;
    ll g=b/temp-(a-1)/temp;
    cout<<(b-a+1)-(e+f-g)<<endl;
}

Measured memory_bytes: 3588
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(N, M, D):

    if D == 0:
        print((1.0 / N) * (M - 1))
    else:
        print((2.0 * (N - D)) / (1.0 * N * N) * (M - 1))


def main():
    N, M, D = map(int, input().split())
    solve(N, M, D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9992
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if (m1+1==m2&&d2==1) {
        cout<<1<<endl;
    } else {
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 272727;

int main(){
    string s;
    cin >> s;
    cout << s.substr(0, 3) << "\n";
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define append push_back
#define endl "\n"
#define N 100000
#define M 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define cover(arr,val) memset(arr,val,sizeof(arr)) 
using namespace std;
int main()
{
	IOS;
	int n,k;
	cin >> n >> k;
	ll arr[N],dp[N];
	for(int i=0;i<n;i++)
		cin >> arr[i];
	dp[n-1]=0;
	for(int i=n-2;i>=0;i--)
	{
		dp[i] = INT_MAX;
		int j=i+1;
		while(j<min(i+k+1,n))
		{
			dp[i] = min(dp[i],abs(arr[i]-arr[j])+dp[j]);
			j++;
		}
	}
	cout << dp[0] << endl;
	return 0;
}


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

static int ans = 0;

void check_ACGT(string S){
	int count = 0;
	for(int i = 0; i < S.length(); i++){
		if(S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T'){
			count++;
			if(ans < count){
				ans = count;
			}
		}else{
			count = 0;
		}
	}
}


int main(){
	string S;
	cin>>S;
	check_ACGT(S);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(i64, H, N);
    vector<i64> a(N);
    read(a);

    print((accumulate(all(a), 0LL) >= H) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <iostream>
using namespace std;vector<string> A;bool ap[30];string s;int S;void dfs(int n,char c,string now){if(n==s.size()){S++;A.push_back(now);return ;}    int C=c-'a';if(ap[C]==true || c=='a'){bool bac=ap[C];ap[C]=true;dfs(n+1,s[n+1],now+c);ap[C]=bac;}if(ap[C+1]==false && c!='z'){bool bac=ap[C+1];ap[C+1]=true;dfs(n+1,s[n+1],now+(char)(c+1));ap[C+1]=bac;}}int main(){while(1){while(A.size())A.pop_back();S=0;cin>>s;if(s=="#")break;dfs(0,s[0],"");cout<<S<<endl;if(S<=10){for(int i=0;i<S;i++){cout<<A[i]<<endl;}}else{for(int i=0;i<5;i++){cout<<A[i]<<endl;}for(int i=A.size()-5;i<A.size();i++){cout<<A[i]<<endl;}}}return 0;}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  double sum = 0.;
  for (int i = 0; i < N; ++i) {
    double A;
    cin >> A;
    sum += 1. / A;
  }
  cout << (1. / sum) << endl;
}


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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int n;
ll a[3010];
ll dp[3010][3010];
bool flag[3010][3010][2];

ll saiki(int p,int q,int s){
    if(p==q){
        return a[p];
    }
    if(flag[p][q][s]){
        return dp[p][q];
    }
    flag[p][q][s] = 1;
    
    if(s==1){
        ll tmp = a[q] - saiki(p,q-1,1-s);
        ll tmp2 = a[p] - saiki(p+1,q,1-s);
        return dp[p][q] = max(tmp,tmp2);
    }else{
        ll tmp = a[q] - saiki(p,q-1,1-s);
        ll tmp2 = a[p] - saiki(p+1,q,1-s);
        return dp[p][q] = max(tmp,tmp2);
    }
}

int main(){
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    cout << saiki(0,n-1,1) << endl;
    return 0;
}

Measured memory_bytes: 88704
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
#include <chrono>
#include<unordered_map>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

int main()
{
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	if (A + B + C >= 22)
		printf("bust\n");
	else
		printf("win\n");

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  rep(i,n) cin >> c[i];
  
  sort(c.begin(),c.end());

  vector<mint> pow(n+1);
  pow[0] = 1;
  rep(i,n) pow[i+1] = pow[i]*2;
  mint ans = 0;
  rep(i,n) { 
    mint x = pow[n-1-i];
    if(i<n-1) x += pow[n-1-i-1] * (n-1-i);
    x *= pow[i] * c[i];
    ans += x;
  }
  ans *= pow[n];
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;
int cnt[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		int sz;
		cin >> sz;
		while (sz--)
		{
			int x;
			cin >> x;
			cnt[x]++;
		}
	}
	cout << count(cnt + 1, cnt + m + 1, n) << endl;
	return 0;
}

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

int main()
{
  int n;
  while (cin >> n && n != 0){
    int a[7] = {0};
    while (n--){
      int age;
      cin >> age;
      if (age > 60){
        a[6]++;
        continue;
      }

      a[age / 10]++;
    }
    for (int i = 0; i < 7; i++){
      cout << a[i] << endl;
    }
  }
}

Measured memory_bytes: 1160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i64,
        k: i64,
    }
    let mut ans: i64 = 0;
    for i in k..n + 2 {
        ans += n * i - i * (i - 1) + 1;
        ans %= 1000000007;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	v := scanInts(n)
	cnt := make([]map[int]int, 2)
	cnt[0] = map[int]int{}
	cnt[1] = map[int]int{}
	for i := 0; i < n; i++ {
		cnt[i&1][v[i]]++
	}
	p := make([]pairs, 2)
	for i := 0; i < 2; i++ {
		for v, c := range cnt[i] {
			p[i] = append(p[i], pair{v, c})
		}
	}
	sort.Sort(p[0])
	sort.Sort(p[1])
	if p[0][0].v == p[1][0].v {
		ma := p[0][0].c
		if len(p[0]) != 1 {
			ma = max(ma, p[0][1].c+p[1][0].c)
		}
		if len(p[1]) != 1 {
			ma = max(ma, p[0][0].c+p[1][1].c)
		}
		fmt.Fprintln(wr, n-ma)
	} else {
		fmt.Fprintln(wr, n-p[0][0].c-p[1][0].c)
	}

}

type pair struct{ v, c int }
type pairs []pair

func (a pairs) Len() int           { return len(a) }
func (a pairs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a pairs) Less(i, j int) bool { return a[i].c > a[j].c }


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

int main(){
  int C[3][3];
  for (int i=0;i<3;i++){
    for (int j=0;j<3;j++){
      cin>>C[i][j];
    }
  }
  int flagA=1;
  int flagB=1;
  if(!((C[0][1]-C[0][0]==C[1][1]-C[1][0])&&(C[0][1]-C[0][0]==C[2][1]-C[2][0]))){
    flagA=0;
  }
  if(!((C[0][1]-C[0][2]==C[1][1]-C[1][2])&&(C[0][1]-C[0][2]==C[2][1]-C[2][2]))){
    flagA=0;
  }
  
  if(!((C[1][0]-C[0][0]==C[1][1]-C[0][1])&&(C[1][0]-C[0][0]==C[1][2]-C[0][2]))){
    flagB=0;
  }
  if(!((C[1][0]-C[2][0]==C[1][1]-C[2][1])&&(C[1][0]-C[2][0]==C[1][2]-C[2][2]))){
    flagB=0;
  }
  
  if((flagA==1)&&(flagB==1)){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;

  return 0;
}
  

Measured memory_bytes: 256