akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,p,i,a;
  unsigned long long ans=1;
  bool e=true;
  cin >> n >> p;
  for (i=0;i<n;i++){
    cin >> a;
    if (a%2) e=false;
  }
  if (e){
    if (p) ans=0;
    else for (i=0;i<n;i++) ans*=2;
  }else for (i=0;i<n-1;i++) ans*=2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
12
WEWEWEEEWWWE
)");
#define cin input
#endif

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

    vector<int> v(1, 0);
    int t = 0;
    for (auto c : s)
    {
        if (c == 'W')
            ++t;
        v.push_back(t);
    }

    int m = n;
    REP (i, n + 1)
    {
        m = min(m, v[i] + (n - i - (t - v[i])));
    }

	cout << m << endl;

	return 0;
}


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

int main() {
  char S;
  int num = 1;
  cin >> S;

  if(S == 'a'){   
 cout << "vowel" << endl;
  }else if(S == 'i'){
     cout << "vowel" << endl;
  }else if(S == 'u'){
     cout << "vowel" << endl;
  }else if(S == 'e'){
     cout << "vowel" << endl;
  }else if(S == 'o'){
     cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int N;
    cin >> N;
    pair <int,int> A[N];
    for(int i=0;i<N;i++){
        cin >> A[i].first;
        A[i].second=i+1;
    }
    sort(A,A+N);
    for(int i=0;i<N;i++)cout << A[i].second << " ";
    cout << endl;
}

Measured memory_bytes: 4400
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned 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 vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &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
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  ll ans = 0;
  if(s.find("R") != string::npos) ans = 1;
  if(s.find("RR") != string::npos) ans = 2;
  if(s.find("RRR") != string::npos) ans = 3;
  print(ans);
}


Measured memory_bytes: 3588
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
	static class Edge{
		int idx;
		int color;
		int src;
		int dst;
		public Edge(int i , int c , int s , int d) {
			idx = i;
			color = c;
			src = s;
			dst = d;
		}
	}
	static class Node{
		int id;
		HashMap<Integer,Edge> adj;
		public Node(int i) {
			id = i;
			adj = new HashMap<Integer,Edge>();
		}
		void add(Edge e) {
			adj.put(e.dst , e);
		}
		void paint(int root_color , int root , Node[] ns) {
			Edge er = adj.get(root);
			er.color = root_color;
			int color = 0;
			for(int e0 : adj.keySet()) {
				Edge e = adj.get(e0);
				if(e.dst == root) {
					continue;
				}
				if(color == root_color) {
					color++;
				}
				e.color = color;
				ns[e.dst].paint(color, e.src , ns);
				color++;
			}
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Node ns[] = new Node[N];
		for(int i = 0 ; i < N ; ++i) {
			ns[i] = new Node(i);
		}
		for(int i = 0 ; i < N - 1; ++i) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			Edge ab = new Edge(i, -1, a, b);
			Edge ba = new Edge(i, -1, b, a);
			ns[a].add(ab);
			ns[b].add(ba);
		}
		int color = 0;
		for(int e0 : ns[0].adj.keySet()) {
			Edge e = ns[0].adj.get(e0);
			e.color = color;
			ns[e.dst].paint(color, 0 , ns);
			color++;
		}
		int results[] = new int[N - 1];
		int C = 0;
		for(Node n : ns) {
			for(Edge e : n.adj.values()) {
				results[e.idx] = e.color + 1;
				C = Math.max(C, e.color + 1);
//				System.out.println(e.src+" "+e.dst+" "+e.idx+" "+e.color);
			}
		}
		System.out.println(C);
		for(int i = 0 ; i < results.length ; ++i) {
			System.out.println(results[i]);
		}
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n, k;
int a[5252], dp[5252];

bool is_need(int mid){
	REP(i, k){
		dp[i]=0;
	}
	int cnt=0;
	dp[0]=1;
	REP(i, n){
		if(i==mid){
			continue;
		}
		FORR(j, 0, k){
			if(dp[j]){
				dp[j]=1;
				if(j+a[i]<k){
					dp[j+a[i]]=1;
				}
			}
		}
	}
	// DEBUG(mid);
	// REP(i, k){
	// 	DEBUG(dp[cnt][i]);
	// }
	FOR(i, max(0, k-a[mid]), k){
		if(dp[i]){
			return true;
		}
	}
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	cin>>n>>k;
	REP(i, n){
		cin>>a[i];
	}
	if(n==1){
		cout<<(a[0]>=k ? 0 : 1)<<'\n';
		return 0;
	}
	sort(a, a+n);
	int lb=-1, ub=n;
	while(ub-lb>1){
		int mid=(lb+ub)/2;
		if(is_need(mid)){
			ub=mid;
		}
		else{
			lb=mid;
		}
	}
	cout<<ub<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

typedef long long i64;
typedef pair<i64,i64> P;


int a, b;

int main(){
	cin >> a >> b;
	
	cout << max(max(a+b,a-b),a*b) << endl;
	
	return 0;
}

Measured memory_bytes: 256
//   :(
#include<bits/stdc++.h>
#define read(i) scanf("%d", &i)
#define mem(a, b) memset(a, b, sizeof(a))
#define MX 100005
using namespace std;
typedef long long ll;
typedef long double ld;

int x[MX], y[MX];
int cnt[MX];
bool chk[MX];

int main(){
     int i, j, k;
     int n, m, ans=0;
     cin >> n >> m;
     for(i=1; i<=n; ++i) cnt[i]=1;
     for(i=0; i<m; ++i) scanf("%d %d", &x[i], &y[i]);
     chk[1]=1;
     for(i=0; i<m; ++i){
          chk[y[i]]+=chk[x[i]];
          cnt[x[i]]--;
          cnt[y[i]]++;
          if(cnt[x[i]]==0) chk[x[i]]=0;
     }
     for(i=1; i<=n; ++i) if(chk[i] && cnt[i]) ans++;
     cout << ans << endl;
}


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

int main() {
    int a, b;
    int d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = double(a) / double(b);
    cout << fixed << setprecision(5) << d << " " << r << " " << f << endl;
    return 0;
}




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

int main(){
    int x,n;cin>>x>>n;
    vi p(102,1);
    int q;
    rep(i,n){
        cin>>q;
        p[q] = 0;
    }
    
    int dif = 200, ans = 0;
    
    rep(i,102){
        if(p[i] && abs(x-i)<dif){
            dif = abs(x-i);
            ans = i;
        }
    }
    cout << ans <<endl;
    
    return 0;
}

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

#define INF 100000000
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  int N;
  cin >> N;
  int min = INF;
  int max = -1;

  REP(i, N){
    int po;
    cin >> po;
    min = MIN(min, po);
    max = MAX(max, po);
  }
  cout << ABS(min-max) << endl;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;

	Main() {
		sc = new Scanner(System.in);
	}
	
	void calc() {
		int N = sc.nextInt();
		System.out.println((double)((N+1)/2)/N);
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 22736
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())


st = [0 for _ in range(n)]
for i in range(n):
    if i < k: 
        if t[i] == 'r' :
            st[i] = 'p'
        elif t[i] == 's' :
            st[i] = 'r'
        elif t[i] == 'p':
            st[i] = 's'
    else:
        if t[i] == 'r' and st[i-k] != 'p':
            st[i] = 'p'
        elif t[i] == 's' and st[i-k] != 'r':
            st[i] = 'r'
        elif t[i] == 'p'and st[i-k] != 's':
            st[i] = 's'
        
score = 0
for i in st:
    if i == 'r' :
        score += r
    elif i == 's' :
        score += s
    elif i == 'p' :
        score += p

print(score)
    
    

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define nmax 100005
#define inf 999999999
#define lld long long
#define ld long double
using namespace std;

int main(){
    char ch;
    cin>>ch;
    ++ch;
    cout<<ch<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
struct node
{
    char a[60];
    int b[30];
} c[60];
char d[3000];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int i,j,k,m,n,o;
    int flag=0;
    int T;
    cin>>T;
    for(i=1; i<=T; i++)
    {
        cin>>c[i].a;
        n=strlen(c[i].a);
        for(j=0; j<n; j++)
            c[i].b[c[i].a[j]-'a']++;
    }
    int ans=0;
    for(i=0; i<26; i++)
    {
        flag=0;
        m=99999;
        for(j=1; j<=T; j++)
        {

            if(c[j].b[i]==0)
            {
                flag=1;
                break;
            }
            else
            m=min(m,c[j].b[i]);
        }
        if(flag==0)
        {
            for(k=0; k<m; k++)
                d[ans++]='a'+i;
        }
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N;
  vi w(N);
  int rsum = 0;
  rep(i,N){
    cin >> w[i];
    rsum += w[i];
  }
  int lsum=0;
  int ans = 1e9;
  rep(i,N-1){
    lsum += w[i];
    rsum -= w[i];
    ans = min(ans, abs(lsum-rsum));
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
int arr[10];
int main() {
	

	for(int i = 0 ; i< 4 ; i++){
		int k;
		cin>>k;
		arr[k]++;
	}
	if(arr[1]==1&&arr[7]==1&&arr[9]==1&&arr[4]==1){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}

}

Measured memory_bytes: 256
#combination
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


X, Y = map(int, input().split())
X, Y = max(X, Y), min(X, Y)
mod = 10 ** 9 + 7
if (2 * Y - X) % 3 != 0:
    ans = 0
elif 2 * Y < X:
    ans = 0
else:
    a = (X + Y)//3
    b = min((2 * X - Y)//3, (2 * Y - X)//3)
    ans =cmb(a, b)
print(ans%mod)


Measured memory_bytes: 45560
import math

A, B, C = map(int, input().split())
N = [A, B, C]
N.sort()

minN = N[0]
midN = N[1]
maxN = N[2]
diff1 = maxN - midN
diff2 = maxN - minN

if (diff1 % 2 == 0 and diff2 % 2 == 0) or (diff1 % 2 != 0 and diff2 % 2 != 0):
    print((diff1 + diff2) // 2)
else:
    print(math.ceil((diff1 + diff2) / 2) + 1)

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

/*----------------------------------------------------------------*/

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define umap unordered_map
#define uset unordered_set
#define to_str to_string

/*----------------------------------------------------------------*/

using ld = long double;
using vld = std::vector<ld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using str = std::string;
using vstr = std::vector<str>;
using vb = std::vector<bool>;
using vvb = std::vector<vb>;

/*----------------------------------------------------------------*/

template<class T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<class T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }
template<class T> T min(std::vector<T> a) { return *std::min_element(all(a)); }
template<class T> T max(std::vector<T> a) { return *std::max_element(all(a)); }
template<class T> T sum(std::vector<T> a) { return std::accumulate(all(a), (T)0); }

/*----------------------------------------------------------------*/

constexpr ld PI = 3.141592653589793L;
constexpr ll MOD = (ll)(1e9 + 7);
constexpr ll INF = (ll)1e9;

/*----------------------------------------------------------------*/

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
ll ctz(ll n) { ll ans = 0; for (; ~n & 1; n >>= 1) ans++; return ans; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll popcnt(ll n) {
    n = ((n & 0xaaaaaaaaaaaaaaaa) >> 1) + (n & 0x5555555555555555);
    n = ((n & 0xcccccccccccccccc) >> 2) + (n & 0x3333333333333333);
    n = ((n & 0xf0f0f0f0f0f0f0f0) >> 4) + (n & 0x0f0f0f0f0f0f0f0f);
    n = ((n & 0xff00ff00ff00ff00) >> 8) + (n & 0x00ff00ff00ff00ff);
    n = ((n & 0xffff0000ffff0000) >> 16) + (n & 0x0000ffff0000ffff);
    n = ((n & 0xffffffff00000000) >> 32) + (n & 0x00000000ffffffff);
    return n;
}
ll len(std::string s) { return (ll)s.length(); }
str zfill(str s, ll n) { return str(n - len(s), '0') + s; }
ll to_ll(char c) { return (ll)c - '0'; }
ll to_ll(str s) {
    ll ans = 0;
    for (ll i = 0; i < len(s); i++)
        ans = 10 * ans + to_ll(s[i]);
    return ans;
}

/*----------------------------------------------------------------*/

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

    while (true) {
        ll n, x; std::cin >> n >> x;
        if (n == 0 && x == 0) break;

        ll ans = 0;
        for (ll i = 1; i <= n; i++)
            for (ll j = i + 1; j <= n; j++)
                for (ll k = j + 1; k <= n; k++)
                    ans += i + j + k == x;

        std::cout << ans << '\n';
    }
}



Measured memory_bytes: 3212
import math

a,b,C = map(float,input().split())
sinC = math.sin(math.radians(C))
cosC = math.cos(math.radians(C))
c = (a**2 + b**2 - 2*a*b*cosC) ** 0.5
S = a * b * sinC / 2
L = a + b + c
h = S * 2 / a
print('{:.8f}'.format(S))
print('{:.8f}'.format(L))
print('{:.8f}'.format(h))


Measured memory_bytes: 5700
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int L, R, d;
	cin >> L >> R >> d;

	int ans = 0;
	for (int i = L; i <= R; i++) {
		if (i % d == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;
 
 
int main(){
	int a, b;
	cin >> a >> b;
	if (a != 1 && b != 1) {
		if (a > b) {
			cout << "Alice";
		}
		else if(a<b){
			cout << "Bob";
		}
		else {
			cout << "Draw";
		}
	}
	else if(a==1){
		if (b == 1) {
			cout << "Draw";
		}
		else{
			cout << "Alice";
		}
	}
	else {
		cout << "Bob";
	}
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
dic = defaultdict(int)

for i in range(3):
    a,b,c = map(int,input().split())
    dic[a] = i*3+1
    dic[b] = i*3+2
    dic[c] = i*3+3
ansl = []
n = int(input())
for _ in range(n):
    k = int(input())
    if dic[k] and dic[k] not in ansl:
        ansl.append(dic[k])
if 1 in ansl and 2 in ansl and 3 in ansl:
    print("Yes")
    exit()
if 4 in ansl and 5 in ansl and 6 in ansl:
    print("Yes")
    exit()
if 7 in ansl and 8 in ansl and 9 in ansl:
    print("Yes")
    exit()
if 1 in ansl and 4 in ansl and 7 in ansl:
    print("Yes")
    exit()
if 2 in ansl and 5 in ansl and 8 in ansl:
    print("Yes")
    exit()
if 3 in ansl and 6 in ansl and 9 in ansl:
    print("Yes")
    exit()
if 1 in ansl and 5 in ansl and 9 in ansl:
    print("Yes")
    exit()
if 3 in ansl and 5 in ansl and 7 in ansl:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 3316
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 100000;
int N, M; ll K;
int x[MAXN + 5];
int a[MAXN + 5], b[MAXN + 5], res[MAXN + 5];
void Pow(ll p) {
	for(int i=1;i<N;i++)
		res[i] = i;
	while( p ) {
		if( p & 1 ) {
			for(int i=1;i<N;i++)
				res[i] = a[res[i]];
		}
		p >>= 1;
		for(int i=1;i<N;i++)
			b[i] = a[a[i]];
		for(int i=1;i<N;i++)
			a[i] = b[i];
	}
}
int main() {
	scanf("%d", &N);
	for(int i=0;i<N;i++)
		scanf("%d", &x[i]);
	for(int i=N-1;i>0;i--)
		x[i] = x[i] - x[i-1];
	scanf("%d%lld", &M, &K);
	for(int i=1;i<N;i++)
		a[i] = i;
	for(int i=1;i<=M;i++) {
		int k;
		scanf("%d", &k);
		swap(a[k-1], a[k]);
	}
	Pow(K);
	ll nw = x[0];
	printf("%lld\n", nw);
	for(int i=1;i<N;i++) {
		nw = nw + x[res[i]];
		printf("%lld\n", nw);
	}
}

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

int main(){
  char s[1111];
  scanf("%s",s);
  char *N=strchr(s,'N'),*S=strchr(s,'S'),*E=strchr(s,'E'),*W=strchr(s,'W');
  int ans=0;
  if((N!=0&&S!=0)||(N==0&&S==0)){
    if((E!=0&&W!=0)||(E==0&&W==0)){
      ans=1;
    }
  }
  puts(ans?"Yes":"No");
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

  int n;
  cin >> n;

  
  int d=0;

  long double a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]==0)d++;
  }

  long long int s=0;
  long long int l=1;
  int c=0;
  long double w=1000000000000000000;
  if(d!=0)cout << 0 <<endl;
  else{
    for(int i=0;i<n;i++){
      w/=a[i];
      if(w<1){
        cout << -1 << endl;
        c++;
        break;
      }
    }
    if(c!=0) ;
    else{
      int m=1;
      for(int i=0;i<n;i++){
        l*=a[i];
        if(m>l || l>1000000000000000000 || l<=0){
          cout << -1 << endl;
          c++;
          break;
        }
        m=l;
      }
    }
    if(c==0)cout << l << endl;
  }

}

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

using namespace std;

int n;
int a,b,c;

int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(a==b && c !=b || a==c && b!=a || b==c && a!=c)
		puts("Yes");
	else
		puts("No");
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;
using namespace std;

int main() {
  int k, x;
  cin >> k >> x;
  if ((500 * k) >= x)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int b=n;
	int tmp=0;
	while(n>0){
		tmp+=n%10;
		n/=10;
	}
	if(b%tmp==0)	puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

D = lines[0][0]
Inf = 10 ** 10

last_date = []
for i in 1..26 do
  last_date.push(0)
end

for i in 1..D do
  max_satis = - Inf
  best_contest = 0
  for k in 1..26 do
    now_satis = 0
    now_satis += lines[i+1][k-1]  #current_benefit
    now_satis += lines[1][k-1] * (i - last_date[k-1])  #current_harm_avoidance
    now_satis += lines[1][k-1] * 325  #expected_future_harm_avoidance
    if now_satis > max_satis then
      max_satis = now_satis
      best_contest = k
    end
  end
  last_date[best_contest-1] = i
  if i < D then
    puts best_contest
  else
    print best_contest
  end
end

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

struct UnionFind {
    vector<int> Parent;
    vector<int> Size;

    explicit UnionFind(int N) : Parent(N), Size(N,1){
        for(int i = 0; i < N; i++) Parent[i] = i;
    }

    int root(int A) {
        if (Parent[A] == A) return A;
        return Parent[A] = root(Parent[A]);
    }

    bool merge(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) return false;

        if (Size[A] < Size[B]) swap(A, B);

        Size[A] += Size[B];
        Parent[B] = A;
        return true;
    }

    bool issame(int A, int B) { //
        return root(A) == root(B);
    }

    int findsize(int A) {
        return Size[root(A)];
    }
};

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

    vector<int> x(m), y(m), z(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> z[i];
        z[i] %= 2;
    }

    UnionFind Tree(n + 1);
    for (int i = 0; i < m; i++) {
        int l = x[i];
        int r = y[i];

        Tree.merge(l, r);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if(Tree.Parent[i] == i) ans++;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 2176
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll l = 0;
    ll r = s.size()-1;
    ll ans = 0;
    while(l<r){
        while((l<s.size())&&(s[l]!='W')){
            l++;
        }
        while((r>=0)&&s[r]!='R'){
            r--;
        }
        if(l>=r) break;
        swap(s[l], s[r]);
        ans++;
        l++;
        r--;
    }
    cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;
int dy[2] = {0, 0};
int dx[2] = {-1, 1};

int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	int m;
	cin >> m;
	ll numberOfDigit = 0;
	ll sumOfDigit = 0;
	rep(i,0,m) {
		ll d, c;
		cin >> d >> c;
		numberOfDigit += c;
		sumOfDigit += (d * c);
	}
	ll S = 9 * numberOfDigit + sumOfDigit;
	if(S%9) {
		cout << (S/9 - 1) << endl;
	} else {
		cout << (S/9 - 2) << endl;
	}
	return 0;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 10;

int n, a[maxN];
map <int, int> mp;
ll ans = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for1(i, n)
    {
        cin >> a[i];
        ++mp[a[i]];
    }
    for (auto &p: mp)
    {
        ans += (ll)p.se * (p.se - 1) / 2;
    }
    for1(i, n)
    {
        cout << ans - mp[a[i]] + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for (int i = 0; i < N; i++) {
            par[i] = i;
        }
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int a[m], b[m];
    rep(i, m) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }

    int res = 0;
    rep(i, m) {
        UnionFind tree(n);
        rep(j, m) {
            if (i == j) continue;
            tree.unite(a[j], b[j]);
        }

        if (!tree.same(a[i], b[i])) {
            ++res;
        };
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            if (S.charAt(S.length() - 1) == '3') {
                out.println("bon");
            } else if (S.charAt(S.length() - 1) == '0' || S.charAt(S.length() - 1) == '1' || S.charAt(S.length() - 1) == '6' || S.charAt(S.length() - 1) == '8') {
                out.println("pon");

            } else {
                out.println("hon");

            }

        }

    }
}



Measured memory_bytes: 35676
#include <bits/stdc++.h>
using namespace std;
int w[101],v[101];
long long f[101][100001];
int main()
{
	int n,w1,i,j;
	scanf("%d %d",&n,&w1);
	for(i=1;i<=n;i++)
		scanf("%d %d",&w[i],&v[i]);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=w1;j++)
		{
			if(j<w[i])
				f[i][j]=f[i-1][j];
			
			else
				f[i][j]=max(f[i-1][j],f[i-1][j-w[i]]+v[i]);
		}
	}
	printf("%lld",f[n][w1]);
	return 0;
}

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

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

int dfs(vector<int>& c){
  int ans = c.size();
  for(int i=0; i<c.size(); i++){
    for(int j=0; j<4; j++){
      int nx = i%4+dx[j];
      int ny = i/4+dy[j];
      if((ny*4+nx)<c.size() && 0<=nx&&nx<4 && c[i]==c[ny*4+nx]){
	vector<int> cards(c);
	cards.erase(cards.begin()+ny*4+nx);
	cards.erase(cards.begin()+i);
	ans = min(ans, dfs(cards));
	if(ans==0)
	  return 0;
      }
    }
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    vector<int> cards(20);
    for(int i=0; i<20; i++)
      cin >> cards[i];
    cout << dfs(cards) << endl;
  };
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
using namespace std;
#define abs(n) ((n) < 0 ? -(n): (n))
int kij(int n) {
    int ret = 1;
    for(int i = 2; i <= n; i++) {
        ret *= i;
    }
    return ret;
}
int f(vector<int> v) {
    int ret = 0, count = 0;
    for(int i = 0; i < v.size(); i++) {
        for(int j = 0; j < i; j++) {
            if(v[j] < v[i]) count++;
        }
        ret += (v[i] - count) * kij(v.size() - i - 1);
        count = 0;
    }
    return ret;
}
int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];
    cout << abs(f(p) - f(q)) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <ctime>

#define MOD 1000000007

const long long INF = 10000000000000000;

using namespace std;


int main(){
	long long N,M,ans=1;
	cin>>N>>M;
	if(abs(N-M)>=2){
		cout<<"0"<<endl;
		return 0;
	}
	if(N==1 &&M==1 ){
		cout<<"2"<<endl;
		return 0;
	}
	long long tmp=1, tmp2=1;
	for(int i=1;i<=N;i++){
		tmp=(tmp*i)%MOD;
	}
	for(int i=1;i<=M;i++){
		tmp2=(tmp2*i)%MOD;
	}
	ans=tmp*tmp2%MOD;
/*	if(N==M){
		ans=(tmp*tmp)%MOD;
	}else if(N>M){
		ans=(tmp*tmp/N)%MOD;
	}else{
		ans=(((tmp*tmp)%MOD)*M)%MOD;
	}
*/	
	if(N==M){
		ans=(ans*2)%MOD;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        String input = stdIn.next();

        //System.out.println(input);

        if("AAA".equals(input) || "BBB".equals(input)) {
        	System.out.println("No");
        }else {
        	System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5;

int a[N+10];

int main()
{
    int n, k;
    int cnt0 = 0;
    cin >> n >> k;
    for(int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        if(a[i] == 0)
            cnt0++;
    }
    if(!cnt0)
        a[++n] = 0;
    sort(a+1,a+1+n);
    int idx = 1;
    for(int i = 1; i <= n; ++i)
        if(a[i] == 0)
            idx = i;
    int ans = INF;
    for(int i = 1; i <= n; ++i)
    {
        if(i == idx)
        {
            if(!a[i] && k == 1)
                ans = 0;
            continue;
        }
        int tmp = abs(a[idx]-a[i]);
        int cnt = abs(idx-i);
        if(cnt0)
            cnt++;
        if(cnt > k)
            continue;
        if(cnt == k)
        {
            ans = min(ans,tmp);
            continue;
        }
        //cnt<k
        if(i < idx)
        {
            if(idx+k-cnt <= n)
                ans = min(ans, tmp + 2*a[idx+k-cnt]);
            else
                continue;
        }
        else
        {
            if(idx-k+cnt >= 1)
                ans = min(ans, tmp - 2*a[idx-k+cnt]);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define pll pair<ll,ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define ff first
#define ss second

void solve() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    /*ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }*/
    ll n;
    cin >> n;
    vll a(n);
    for (auto &i: a) cin >> i;

    for(int i = n-1; i >= 1; --i){
        if(a[i] < a[i-1]){
            a[i-1] --;
        }
        if(a[i] < a[i-1]){
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
struct Point {
	int x{ 0 }, y{ 0 };
	Point() {}
	Point(int a, int b) :x{ a }, y{ b } {}
	int manhattan(Point other) const {
		return std::abs(x - other.x) + std::abs(y - other.y);
	}
};
template<typename T>
class TwoD_vec {
	std::vector<std::vector<T>> vec;
public:
	TwoD_vec(int h, int w) :vec( h, std::vector<T>(w) ) {};
	int height() const {
		return vec.size();
	}
	int width() const {
		return vec.begin()->size();
	}
	T &operator[](Point p) {
		return vec[p.x][p.y];
	}
	const T&operator[](Point p) const {
		return vec[p.x][p.y];
	}
};
class Point_to_num {
	TwoD_vec<int> vec;
	Point_to_num(int h, int w) :vec( h, w ) {}
public:
	static Point_to_num read(int h, int w, std::istream &is) {
		auto res = Point_to_num(h, w);
		for (auto i = 0; i < h; ++i) {
			for (auto j = 0; j < w; ++j) {
				std::cin >> res[Point{ i, j }];
			}
		}
		return res;
	}
	int &operator[](Point p) {
		return vec[p];
	}
	const int operator[](Point p) const {
		return vec[p];
	}
	int height() const {
		return vec.height();
	}
	int width() const {
		return vec.width();
	}
};
class Num_to_Point {
	std::vector<Point> vec;
public:
	Num_to_Point(int h, int w) :vec( h * w + 1 ) {}
	void accumlate(const Point_to_num &pn) {
		for (auto i = 0; i < pn.height(); ++i)
			for (auto j = 0; j < pn.width(); ++j)
				vec[pn[{i, j}]] = (Point(i, j));
	}
	const Point &operator[](int a) const {
		return vec[a];
	}
};

int main() {
	int h, w, d;
	std::cin >> h >> w >> d;
	auto points = Point_to_num::read(h, w, std::cin);
	auto num_to_point = Num_to_Point(h, w);
	num_to_point.accumlate(points);
	std::vector<int> distances(h * w + 1, 0);
	for (int i = distances.size() - d - 1; i >= 0; --i) {
		distances[i] = num_to_point[i].manhattan(num_to_point[i + d]) + distances[i + d];
	}
	int q, l, r;
	std::cin >> q;
	for (auto i = 0; i < q; ++i) {
		std::cin >> l >> r;
		std::cout << distances[l] - distances[r] << std::endl;
	}
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{
    static int sum;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();

        tuple[] tup = new tuple[q];

        for(int i=0; i<q; i++){
            tup[i] = new tuple(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
        }
        
        int[] seq = new int[n+1];
        seq[0] = 1;
        sum = 0;
        gene(1, n, m, seq, tup, q);
        System.out.println(sum);

        sc.close();

    }
    static int eval(int[] seq, tuple[] tup, int q) {
        int score = 0;
        for(int i=0; i < q; i++){
            if((seq[tup[i].b]-seq[tup[i].a])==tup[i].c) score += tup[i].d;
        }
        return score;
    }
    static void gene(int i, int n, int m, int[] seq, tuple[] tup, int q){
        if(i==n+1){
            int temp = eval(seq, tup, q);
            sum = Math.max(sum, temp);
            return;
        }
        for(int j=seq[i-1]; j<=m; j++){
            seq[i] = j;
            gene(i+1, n, m, seq, tup, q);
        }
    }
    static class tuple{
        int a;
        int b;
        int c;
        int d;
        tuple(int a, int b, int c, int d){
            this.a = a;
            this.b = b;
            this.c = c;
            this.d = d;
        }
    }
}

Measured memory_bytes: 37380
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  cout << (n+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[3],i,j,m;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<3;i++)
    {
        for(j=i+1;j<3;j++)
        {
            if(a[i]>a[j])
            {
                m=a[i];
                a[i]=a[j];
                a[j]=m;
            }
        }
    }
    for(i=0;i<2;i++)
    {
        printf("%d ",a[i]);
    }
    printf("%d\n",a[2]);
    return 0;
}



Measured memory_bytes: 2040
#include <cstdio>
#include <cstdlib>

void chmax(int* a,int b){
    if(*a<b){
        *a=b;
    }
}

int main(void){
    int N;
    int h[100000][3]; //a,b,c
    int dp[100001][3];
    
    scanf("%d",&N);
    for(int i = 0;i<N;i++){
        scanf("%d%d%d",&h[i][0],&h[i][1],&h[i][2]);
        dp[i][0] = 0;
        dp[i][1] = 0;
        dp[i][2] = 0;
    }
    
    for(int i=1;i<=N;i++){
        for(int j=0;j<3;j++){
            for(int z=0;z<3;z++){
                if(j!=z){
                chmax(&dp[i][z],dp[i-1][j]+h[i-1][j]);
                }    
            }
        }
    }
    
    int ans;
    if(dp[N][0] > dp[N][1]){
        ans = dp[N][0];
    }
    else{
        ans = dp[N][1];
    }
    if(ans < dp[N][2]){
        ans = dp[N][2];
    }
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cmath>
#define N 55
using namespace std;

int T = 5e5;
double n, tx, ty, p = 1, pr = 0.999, mx, t, x[N], y[N];
int main()
{
	int i, j, num;
	cin >> n;
	for (i =0; i < n; i++) {
		cin >> x[i] >> y[i];
		tx += x[i];
		ty += y[i];
	}
	tx /= (double)n;
	ty /= (double)n;
	while (T--) {
		mx = -1;
		for (i = 0; i < n; i++) {
			t = (x[i] - tx) * (x[i] - tx) + (y[i] - ty) * (y[i] - ty);
			if (t > mx) {
				mx = t;
				num = i;
			}
		}
		p *= pr;
		tx = (x[num] - tx) * p + tx;
		ty = (y[num] - ty) * p + ty;
	}
	printf("%.10f", sqrt(mx));
    return 0;
}


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

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

static const double EPS = 1e-10;
static const int MAX_N = 50;
static const double G = 9.8;

int N;
double V, X, Y;
double L[MAX_N], B[MAX_N], R[MAX_N], T[MAX_N];

double calc(double vy, double t) {
  return vy * t - 0.5 * G * t * t;
}

int cmp(double a, double b, double x) {
  if (x < a + EPS) return -1;
  if (x > b - EPS) return 1;
  return 0;
}

bool check(double tx, double ty) {
  double a = (1.0 / 4.0) * G * G;
  double b = G * ty - V * V;
  double c = tx * tx + ty * ty;

  double D = b * b - 4.0 * a * c;
  if (fabs(D) <= EPS) D = 0.0;
  if (D < 0) return false;
  for (int d = -1; d <= 1; d+=2) {
    double t_squared = (-b + d * sqrt(D)) / (2.0 * a);
    if (t_squared <= 0) continue;

    // calc initial velocity to hit (tx, ty)
    double t = sqrt(t_squared);
    double vx = tx / t;
    double vy = (ty + 0.5 * G * t * t) / t;

    // check if the course is beyond pig
    double py = calc(vy, X / vx);
    if (py < Y - EPS) continue;

    // check if the course is clear
    bool isClear = true;
    for (int i = 0; i < N; i++) {
      if (L[i] >= X) continue;
      if (R[i] >= X && T[i] >= Y && B[i] <= py) {
        isClear = false;
        break;
      }
      double ly = calc(vy, L[i] / vx);
      double ry = calc(vy, R[i] / vx);
      int posL = cmp(B[i], T[i], ly);
      int posR = cmp(B[i], T[i], ry);
      if (posL * posR <= 0) {
        isClear = false;
        break;
      }

      double ht = vy / G;
      int posX_high = cmp(L[i], R[i], vx * ht);
      double hy = calc(vy, ht);
      int posH = cmp(B[i], T[i], hy);
      if (posX_high == 0 && posH >= 0 && posL < 0) {
        isClear = false;
        break;
      }
    }
    if (isClear) return true;
  }
  return false;
}

bool solve() {
  for (int i = 0; i < N; i++) {
    R[i] = min(R[i], X);
  }
  if (check(X, Y)) return true;
  for (int i = 0; i < N; i++) {
    if (check(L[i], T[i]) || check(R[i], T[i])) return true;
  }
  return false;
}

int main() {
  cin >> N >> V >> X >> Y;
  for (int i = 0; i < N; i++) {
    cin >> L[i] >> B[i] >> R[i] >> T[i];
  }

  bool isOK = solve();
  cout << (isOK ? "Yes" : "No") << endl;
}

Measured memory_bytes: 0
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	s := readBytes()
	zero := byte('0')
	one := byte('1')
	var x, y int
	for i := range s {
		if i%2 == 0 {
			if s[i] != zero {
				x++
			}
			if s[i] != one {
				y++
			}
		} else {
			if s[i] != one {
				x++
			}
			if s[i] != zero {
				y++
			}
		}
	}
	fmt.Println(min(x, y))
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
#define ll long long 
int main(){
  int n;
  ll a=1,b=1;
  ll s=1,t=1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s>>t;
    ll h =max((a+s-1)/s,(b+t-1)/t);
    a=s*h;
    b=t*h;
  }
  cout<<(a+b)<<endl;
}

Measured memory_bytes: 256
// Author: 23forever
#include <bits/stdc++.h>
//#define debug
const int MAXN = 40;
const int N = 5 + 7 + 5;
const int P = 1e9 + 7;
using namespace std;

inline void read(int &x) {
  x = 0; char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
}

int n, x, y, z;
int dp[MAXN + 5][1 << N];
int banned, S;

void print(int x) {
  bitset < 20 > tmp(x);
  cout << tmp << endl;
}

void init() {
  read(n), read(x), read(y), read(z);
  //cout << (1 << 5 - 1) << endl;
  banned = (1 << x + y + z - 1) | (1 << y + z - 1) | (1 << z - 1); 
  S = (1 << x + y + z) - 1;
  //print(S);
}

int main() {
#ifdef forever23
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  init();

  int ans = 1; dp[0][0] = 1; 
  for (int i = 1; i <= n; ++i) {
    for (int s = 0; s <= S; ++s) {
      for (int j = 1; j <= 10; ++j) {
        int nxt_state = ((1 << j - 1) | (s << j)) & S;
        /*print(s); printf("%d\n", j);
        print(nxt_state);
        puts("");*/   
        if ((nxt_state & banned) != banned) {
          dp[i][nxt_state] = (dp[i][nxt_state] + dp[i - 1][s]) % P;
        }
      }
    }
    ans = 1LL * ans * 10 % P;
  }
  
  for (int s = 0; s <= S; ++s) {
    ans = (ans - dp[n][s] + P) % P;
  }
  printf("%d\n", ans);  
  return 0;
}


Measured memory_bytes: 22272