akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cctype>
#include <cstdlib>
using namespace std;

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

	for (int j = 0; j < n; j++) {
		char num1[10], num2[10];
		cin >> num1 >> num2;

		int m = 0, x = 0, c = 0, i = 0;
		int pos = 0;
		while (num1[pos]) {
			bool flag = false;
			int tmpi;
			if (isdigit(num1[pos])) {
				char tmpc[2] = { num1[pos], '\0' };
				tmpi = atoi(tmpc);
				pos++;
				flag = !flag;
			}
			switch (num1[pos]) {
			case 'm':
				m += flag ? tmpi : 1;
				break;
			case 'x':
				x += flag ? tmpi : 1;
				break;
			case 'c':
				c += flag ? tmpi : 1;
				break;
			case 'i':
				i += flag ? tmpi : 1;
				break;
			default:
				break;
			}
			pos++;
		}

		pos = 0;
		while (num2[pos]) {
			bool flag = false;
			int tmpi;
			if (isdigit(num2[pos])) {
				char tmpc[2] = { num2[pos], '\0' };
				tmpi = atoi(tmpc);
				pos++;
				flag = !flag;
			}

			switch (num2[pos]) {
			case 'm':
				m += flag ? tmpi : 1;
				break;
			case 'x':
				x += flag ? tmpi : 1;
				break;
			case 'c':
				c += flag ? tmpi : 1;
				break;
			case 'i':
				i += flag ? tmpi : 1;
				break;
			default:
				break;
			}
			pos++;
		}

		if (i > 9) {
			x += i / 10;
			i %= 10;
		}
		if (x > 9) {
			c += x / 10;
			x %= 10;
		}
		if (c > 9) {
			m += c / 10;
			c %= 10;
		}

		if (m > 1) {
			cout << m;
		}
		if (m > 0) {
			cout << 'm';
		}
		if (c > 1) {
			cout << c;
		}
		if (c > 0) {
			cout << 'c';
		}
		if (x > 1) {
			cout << x;
		}
		if (x > 0) {
			cout << 'x';
		}
		if (i > 1) {
			cout << i;
		}
		if (i > 0) {
			cout << 'i';
		}
		cout << endl;
	}

	return 0;
}

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

typedef long long int   ll;
#define int             ll
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%lld",&n)
#define pb              push_back
#define PI              3.1415926535897932384626433832795
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int t=1;
//    scan(t);
    while(t--){
        int n,k;cin>>n>>k;
        int ar[n];
        for(int i=0;i<n;i++) cin>>ar[i];
        sort(ar,ar+n);
        int ans=0;
        for(int i=0;i<k;i++) ans+=ar[i];
        cout<<ans;
    }
}


Measured memory_bytes: 3636
INF = 10**13
N, M, X = map(int, input().split())
C = []
A = []
for i in range(N):
    CA = list(map(int, input().split()))
    C += [CA[0]]
    A += [CA[1:]]
ans = INF
for b in range(2**N):
    tmpA = [0] * M
    cost = 0
    for i in range(N):
        if (b >> i) & 1:
            cost += C[i]
            for ii, ai in enumerate(A[i]):
                tmpA[ii] += ai
    flag = True
    for ai in tmpA:
        if ai >= X:
            continue
        flag = False
        break
    if flag:
        ans = min(ans, cost)
if ans == INF:
    print(-1)
else:
    print(ans)

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

typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, A, B;
int ret;

int main() {
	cin >> N >> A >> B;
	rep(i, N) {
		int t;
		cin >> t;
		if (t>=A&&t<B) ++ret;
	}
	cout << N - ret << endl;
	return 0;
}

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

int main() {
 int n;
  cin >>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
   cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  int total=0;
   for(int i=0;i<n-1;i++){
    total+=v.at(i);
   }
  if(total>v.at(n-1))
    cout << "Yes";
  else
    cout << "No";
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <deque>

using namespace std;

int solve(int K) {

    deque<pair<int, int> > dq;
    vector<bool> visited(K, false);

    dq.push_front(make_pair(1, 1));
    while (! dq.empty()) {
        pair<int, int> p = dq.front();
        dq.pop_front();

        int current = p.first, cnt = p.second;
        if (current == 0) return cnt;

        visited[current] = true;
        int next = (current + 1) % K;
        if (visited[next] == false) {
            dq.push_back(make_pair(next, cnt + 1));
        }

        next = (current * 10) % K;
        if (visited[next] == false) {
            dq.push_front(make_pair(next, cnt));
        }
    }

    return 0;
}

int main() {
    int K;
    scanf("%d", &K);

    int cnt = solve(K);
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

const int CMax = 100002;

int n, m, A[CMax];

int main(){
    scanf("%d %d", &n, &m);
    printf("%d\n", (n-1)*(m-1));
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int  an[4][2]={{2, 2},{2,1},{1,1},{1,2}};//WW WS SS SW
int i,j,kind[100005],n;
char ans[100005];
int main()
{
    while(cin>>n&&(n>=3))
    {
        int flag=0;
        memset(kind,0,sizeof(kind));
        for(i=1;i<=n;i++)
        {
            cin>>ans[i];
        }

        for(j=0;j<4;j++)
        {
            kind[1]=an[j][0];
            kind[2]=an[j][1];
            for(i=2;i<=n;i++)
            {
             if(kind[i]==2)//is wolf
             {
                 if(ans[i]=='o') kind[i+1]=kind[i-1]%2+1;
                 else kind[i+1]=kind[i-1];
             }
             else if(kind[i]==1)
                 if(ans[i]=='x')  kind[i+1]=kind[i-1]%2+1;
                 else kind[i+1]=kind[i-1];
            }



            if(kind[n+1]==kind[1])
            {


                if(kind[1]==1)
                {
                    if(ans[1]=='o'&&kind[2]==kind[n]){flag++;break;}
                    if(ans[1]=='x'&&kind[2]!=kind[n]){flag++;break;}
                }
                else if(kind[1]==2)
                {
                    if(ans[1]=='x'&&kind[2]==kind[n]){flag++;break;}
                    if(ans[1]=='o'&&kind[2]!=kind[n]){flag++;break;}
                }
            }


        }

        if(flag==0)cout<<"-1"<<endl;
        else
        {


        for(i=1;i<=n;i++)
        {
            if(kind[i]==1)cout<<'S';
            else cout<<'W';
        }
            cout<<endl;
           // cout<<kind[n+1]<<endl;

        }
    }

}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
vector<VL> G(10000);
VL c, d(10000), tree;
map<ll, ll> sel;
vector<bool> used(10000, false);

void dfs(ll now) {
    used[now] = true;
    FOREACH(to, G[now]) {
        if(!used[to]) {
            tree.emplace_back(to);
            dfs(to);
        }
    }
}

signed main() {
    cin >> N;
    REP(i, N - 1) {
        LCIN(a, b);
        G[--a].emplace_back(--b);
        G[b].emplace_back(a);
        sel[a]++;
        sel[b]++;
    }
    ll start = 0;
    FOREACH(s, sel) if(s.second > sel[start]) start = s.first;
    tree.emplace_back(start);
    dfs(start);
    REP(i, N) c.emplace_back(IN());
    sort(All(c), greater<ll>());
    ll ans = 0;
    REP(i, N) {
        d[tree[i]] = c[i];
        if(i != 0) ans += c[i];
    }
    cout << ans << "\n";
    REP(i, N) { cout << d[i] << " "; }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 2044
#include<iostream>
using namespace std;
int main()
{
    int k,p,z=0,c=0;
    cin >> k;
    for(int i=0; i<k; i++)
        {
            cin >> p;
            z++;
            if(p!=z)
                {
                    c++;
                }
        }
    if(c<=2)
        {
            cout << "YES";
        }
    else
        cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <utility>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;

#define init() ios::sync_with_stdio(false); cin.tie();
#define for0(i, n) for (int i=0; i<n; i++)
#define for1(i, n) for (int i=1; i<=n; i++)
#define for2(i, a, b) for (int i=a; i<=b; i++)
#define bac0(i, n) for (int i=n-1; i>=0; i--)
#define bac1(i, n) for (int i=n; i>0; i--)
#define bac2(i, a, b) for (int i=a; i>=b; i--)
#define PB push_back
#define MOD 1000000009
#define S second
#define F first

#define xL ((x<<1)+1)
#define xR ((x<<1)+2)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, char> ic;

const int N = (int) (4e5 + 5);

int n, m;
char grid[100][100];

bool alone(int i, int j) {
    if (grid[i][j] == '.') return false;
    return (i == 0 || grid[i - 1][j] == '.')
           && (i == n - 1 || grid[i + 1][j] == '.')
           && (j == 0 || grid[i][j - 1] == '.')
           && (j == m - 1 || grid[i][j + 1] == '.');
}

int main() {
    init()

    cin >> n >> m;
    for0 (i, n) cin >> grid[i];

    for0 (i, n) for0 (j, m) if (alone(i, j)) { cout << "No\n"; return 0; }
    cout << "Yes\n";

    return 0;
}

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

int main() {
  long long n;
  long long i = 1;
  long long sum = 0;
  cin >> n;
  while (i <= n) {
    if (i%3 > 0 && i%5 > 0) {
      sum += i;
    }
    i++;
  }
  cout << sum;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll N,H;
vector<ll> a,b;

int main(){
  ll x,y;
  cin >> N >> H;
  for(int i=0;i<N;i++){
    cin >> x >> y;
    a.push_back(x);
    b.push_back(y);
  }
  sort(a.begin(),a.end(),greater<ll>());
  sort(b.begin(),b.end(),greater<ll>());
  ll attack = 0;
  for(int i=0;i<N;i++){
    if(b[i] < a[0]) break;
    H -= b[i];
    attack++;
    if(H <= 0) break;
  }
  if(H > 0){
    attack += H / a[0];
    if(H % a[0] != 0) attack++;
  }
  cout << attack << endl;
  return 0;
}


Measured memory_bytes: 2036
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;


int main(){
	vector<int> a;
	int x;
	for (int i = 0; i < 3; ++i){
		cin >> x;
		a.push_back(x);
	}
	if (count(a.begin(), a.end(), 5) == 2 && count(a.begin(), a.end(), 7) == 1){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
n,r,k,m[101][101],t[101],p;
i,j,s,d,v0,v,f;
main(){
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&r,&k);
		for(;k--;){
			scanf("%d",&d);
			m[r][d]=1;
		}
	}
	scanf("%d",&p);
	for(;p--;){
		scanf("%d%d%d",&s,&d,&v0);
		memset(t,0,sizeof(t));
		t[s]=v=v0;
		f=1;
		while(f&&!t[d]&&--v>0){
			f=0;
			for(i=1;i<=n;i++){
				if(t[i]==v+1){
					for(j=1;j<=n;j++){
						if(m[i][j]&&t[j]==0)
							t[j]=v,f=1;
					}
				}
			}
		}
		if(t[d])
			printf("%d\n",v0-t[d]+1);
		else
			puts("NA");
	}
	exit(0);
}

Measured memory_bytes: 0
from collections import defaultdict
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort()
bc=defaultdict(int)
for i in range(m):
  b,c=map(int,input().split())
  bc[c]+=b
i=0
newc=[0]*n
for c,b in sorted(bc.items(),key=lambda x:x[0],reverse=True):
  for _ in range(b):
    if i==n:
      break
    newc[i]=c
    i+=1
ans=sum(a)
for i in range(n):
  if newc[i]>a[i]:
    ans+=newc[i]-a[i]
print(ans)

Measured memory_bytes: 104672
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String [] args){
        Scanner sc =new Scanner(System.in);
        int N =sc.nextInt();
        Set set =new HashSet();
        int ans =0;
        for (int i=0;i<N;i++){
            String s = sc.next();
            if(!set.contains(s)){
                set.add(s);
                ans++;
            }
        }
        if(ans ==3){
            System.out.println("Three");
        }else{
            System.out.println("Four");
        }
    }
}

Measured memory_bytes: 23892
words = lambda t : list(map(t, input().split()))
x1,y1,x2,y2 = words(int)

x3 = x2 + y1 - y2
y3 = y2 + x2 - x1

x4 = x3 + x1 - x2
y4 = y3 + y1 - y2

print(x3,y3,x4,y4)


Measured memory_bytes: 38384
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
	let s: Vec<char> = read::<String>().chars().collect();
    let k:i64 = read();
    let n = s.len();
    let mut f = 0;
    let mut cnt:i64 = 0;
    for i in 0..n {
    cnt += 1;
    	if cnt == k && f == 0 {
        	println!("{}",s[i]);
            f = 1;
		}
        if s[i] != '1' && f == 0 {
        	println!("{}",s[i]);
            f = 1
        }
    }
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a[N];
namespace Seg {
	int xb, f[N << 2];
	inline void Pre() {
		xb = n * 2 + 1;
		for (int i = 1; i <= xb * 2; ++i) f[i] = 0;
	}
	inline void Add(int x, int y = 1) {
		x += n + 1;
		for (int i = xb + x; i; i >>= 1) f[i] += y;
	}
	inline int Ask(int x, int y) {
		x += n + 1; y += n + 1;
		int ans = 0;
		for (int l = xb + x - 1, r = xb + y + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
			if (~l & 1) ans += f[l ^ 1];
			if ( r & 1) ans += f[r ^ 1];
		}
		return ans;
	}
}
inline long long Calc(int x) {
	long long ans = 0;
	Seg::Pre();
	int sm = 0;
	Seg::Add(sm);
	for (int i = 1; i <= n; ++i) {
		sm -= (a[i] >= x ? 1 : -1);
		ans += Seg::Ask(-n, sm - 1);
		Seg::Add(sm);
	}
	return ans;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	int ans = 0;
	for (int l = 1, r = 1e9, mid; l <= r; Calc(mid = (l + r) >> 1) <= (1ll * n * (n - 1) / 2 + n) / 2 ? ans = mid, l = mid + 1 : r = mid - 1);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll ADD(ll ADD_X,ll ADD_Y)
{
    return (ADD_X+ADD_Y)%MOD;
}
ll SUB(ll SUB_X,ll SUB_Y)
{
    return ((SUB_X-SUB_Y)+MOD)%MOD;
}
ll LCM(ll LCM_X,ll LCM_Y)
{
    return (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll lcm=LCM(c,d);
    ll y=b/c - (a-1)/c;
    ll x=b/d - (a-1)/d;
    ll cm=b/lcm - (a-1)/lcm;
    ll ans=x+y-cm;
    ll range=(b-a)+1;
    ans=range-ans;
    cout<<ans<<endl;

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int s,m,h; cin>>s;
    m=s/60; s%=60;
    h=m/60; m%=60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 3216
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    N = len(S)
    head = S[:(N-1)//2]
    tail = S[(N-1)//2+1:]

    reversed_head = head[::-1]
    reversed_tail = tail[::-1]
    reversed_S = S[::-1]
    if head == reversed_head and tail == reversed_tail and reversed_S == S:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    string s;
    cin>>s;
    if(s=="SUN"){
        cout<<7<<endl;
    }
    if(s=="MON"){
        cout<<6<<endl;
    }
    if(s=="TUE"){
        cout<<5<<endl;
    }
    if(s=="WED"){
        cout<<4<<endl;
    }
    if(s=="THU"){
        cout<<3<<endl;
    }
    if(s=="FRI"){
        cout<<2<<endl;
    }
    if(s=="SAT"){
        cout<<1<<endl;
    }
}


Measured memory_bytes: 256
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
using namespace std;

int main() {
	int x;
	cin >> x;
	int y;
	if (x >= 9) {
		y = (x - 9) % 7;
	}
	else {
		y = (x + 21 - 9) % 7;
	}
	string day;
	switch (y) {
	case 0:
		day = "sat";
		break;
	case 1:
		day = "sun";
		break;
	case 2:
		day = "mon";
		break;
	case 3:
		day = "tue";
		break;
	case 4:
		day = "wed";
		break;
	case 5:
		day = "thu";
		break;
	case 6:
		day = "fri";
		break;
	}
	cout << day << endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    int n,m; cin >> n;;
    map<int,int> mp;
    //int ans = 0;
    vector<int> v;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if (mp[a] == 0){
            mp[a]++;
            v.push_back(a);
        }
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        int b; cin >> b;
        if (mp[b] == 0){
            v.push_back(b);
        }
    }
    sort(v.begin(),v.end());
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << endl;
    }
}


Measured memory_bytes: 23100
args = int(input().rstrip())

def snuke(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s

def find_snuke(args):
    result = []
    i = 1
    while len(result) < args:
        push = True
        p = 0
        for power in range(0,len(str(i))):
            if((i+10**power)/snuke(i+10**power))<(i/snuke(i)):
                push = False
                p = power
                break
        if push:
            result.append(i)
        i=i+10**p
            
    return result

arr = find_snuke(args)
for a in arr:
   print(a)

Measured memory_bytes: 3188
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define track  1;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

const int N=1e5+1738;
int n,k;
vector<int>dp(N,-1),a;

int sol(int ind)
{
	if(ind==n)
	{
		return 0;
	}
	if(ind>n)
	{
		return INT_MAX;
	}
	int ans = INT_MAX;

	if(dp[ind]!=-1)
	{
		return dp[ind];
	}

	for(int i=ind+1;i<=min(ind+k,n);i++)
	{
		 ans= min(ans,((abs(a[ind]-a[i])+sol(i))));
	}
	return dp[ind]=ans;
}

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j,cnt=0;
	bool flag=0;
	cin>>n>>k;

	a.resize(n+1);

	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	d(a);

	int res = sol(1);

	cout<<res<<endl;

}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;

/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	ll arr[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	ll k = 0;
	for(i=0;i<n;i++)
	{
		if((i+1)%2!=0 && arr[i]%2!=0)
			k++;
	}
	cout<<k<<endl;

	


	
	

	
	


	
	return 0;
}

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

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

	int da = abs(x - a);
	int db = abs(x - b);

	if (da < db) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}

    return 0; 
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

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

ll lcm(ll a,ll b){
	return a*b/gcd(a,b);
}


int main(void){
	ll n,ans=1;
	cin>>n;
	rep(i,n){
		ll a;
		cin>>a;
		ans=lcm(ans,a);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll a,b,c;
    cin >> a >> b >> c;
    if (a + b >= c) {
        cout << b + c << endl;
    }else{
        cout << b + a + b + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {
  string S;
  cin >> S;

  map<char, int> sMap;
  for(int i = 0; i < S.size(); i++) {
    if (sMap.find(S[i]) != sMap.end()) {
      sMap[S[i]] += 1;
    } else {
      sMap[S[i]] = 1;
    }
  }

  string ans = "Yes";
  for (auto a = sMap.begin(); a != sMap.end(); a++) {
    if (a -> second != 2) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from sys import stdin, stderr

DPL = [0] * 56
DPP = [0] * 56

def F(n, x):
   if x == 0:
      return 0

   if x == 1:
      return 1 if n == 0 else 0

   if x == DPL[n]:
      return DPP[n]

   if x == 1 + DPL[n-1] + 1:
      return DPP[n-1] + 1
   elif x > 1 + DPL[n-1] + 1:
      return DPP[n-1] + 1 + F(n-1, x - (1 + DPL[n-1] + 1))
   else:
      return F(n-1, x-1)

def main():
   N, X = map(int, stdin.readline().split())

   DPL[0] = 1
   DPP[0] = 1
   for n in xrange(1, N+1):
      DPL[n] = 2*DPL[n-1] + 3
      DPP[n] = 2*DPP[n-1] + 1

   res = F(N, X)
   print(res)

   return 0

if __name__ == '__main__': main()


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

int n, k, x, nr;

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> x;
        if(x >= k) {
            nr++;
        }
    }
    cout << nr;
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define tezz std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    int a,b;
    cin>>a;
    int c=0;
    for(int i=1;i<=a;i++){
        if(i%2!=0){
            c++;
        }
    }
    double cc=c/(double)a;
    printf("%.10f",cc);
    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //i について全探索する
    for (int i = 0; i < N; i++)
    {
        //A[i+1] ... A[N] の値を更新する
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3988
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)

int p[MAXN];
int a[MAXN];

int main() {
	int n, m;
	cin >> n >> m;
	int ac = 0;
	int pen = 0;
	for (int i = 0; i < m; i++) {
		int prob;
		string s;
		cin >> prob >> s;
		if (!a[prob]) {
			if (s == "AC") {
				a[prob] = 1;
				ac++;
				pen += p[prob];
			} else {
				p[prob]++;
			}
		}
	}
	cout << ac << " " << pen << endl;
	return 0;
}


Measured memory_bytes: 3872
import sys
input = sys.stdin.readline

def factorization(num):
    import math
    # 因数分解した結果をタプルのリストで返す
    # [(prime, count), ...]
    MAX_PRIME = int(math.sqrt(num)) + 1
    primes = []
    is_prime = [True] * (MAX_PRIME+1)
    for i in range(2, MAX_PRIME+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_PRIME+1, i):
                is_prime[j] = False
    insu = []
    tmp = num
    max_count = 0
    for i in range(len(primes)):
        count = 0
        while tmp%primes[i] == 0:
            tmp //= primes[i]
            count += 1
        if count > 0:
            insu.append((primes[i], count))
            max_count = max(max_count, count)
        if tmp == 1:
            break
    if tmp != 1:
        insu.append((tmp, 1))
    return insu

def main():
    N = int(input())
    insu = factorization(N)

    print("{}:".format(N), end="")
    for prime, count in insu:
        for i in range(count):
            print(" {}".format(prime), end="")
    print()

if __name__ == "__main__":
    main()


Measured memory_bytes: 5908
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl H, A;

void solve(void) {
  cout << H / A + (((H % A) == 0) ? 0 : 1) << endl;
}

int main(void) {
  cin >> H >> A;
  solve();
  return 0;
}



Measured memory_bytes: 768
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, A, B, C = in_nn()
    S = [in_s() for _ in range(N)]

    ans = []
    for i in range(N):
        s = S[i]
        if s == 'AB':
            if A == 0 and B == 0:
                print('No')
                exit()
            elif A == 0:
                A += 1
                B -= 1
                ans.append('A')
            elif B == 0:
                A -= 1
                B += 1
                ans.append('B')
            elif A > B:
                A -= 1
                B += 1
                ans.append('B')
            elif A == 1 and B == 1 and i < N - 1 and S[i + 1] != 'AB':
                if S[i + 1] == 'BC':
                    A -= 1
                    B += 1
                    ans.append('B')
                elif S[i + 1] == 'AC':
                    A += 1
                    B -= 1
                    ans.append('A')
            else:
                A += 1
                B -= 1
                ans.append('A')
        elif s == 'BC':
            if B == 0 and C == 0:
                print('No')
                exit()
            elif B == 0:
                B += 1
                C -= 1
                ans.append('B')
            elif C == 0:
                B -= 1
                C += 1
                ans.append('C')
            elif B > C:
                B -= 1
                C += 1
                ans.append('C')
            elif B == 1 and C == 1 and i < N - 1 and S[i + 1] != 'BC':
                if S[i + 1] == 'AC':
                    B -= 1
                    C += 1
                    ans.append('C')
                elif S[i + 1] == 'AB':
                    B += 1
                    C -= 1
                    ans.append('B')
            else:
                B += 1
                C -= 1
                ans.append('B')
        elif s == 'AC':
            if A == 0 and C == 0:
                print('No')
                exit()
            elif A == 0:
                A += 1
                C -= 1
                ans.append('A')
            elif C == 0:
                A -= 1
                C += 1
                ans.append('C')
            elif A > C:
                A -= 1
                C += 1
                ans.append('C')
            elif A == 1 and C == 1 and i < N - 1 and S[i + 1] != 'AC':
                if S[i + 1] == 'BC':
                    A -= 1
                    C += 1
                    ans.append('C')
                elif S[i + 1] == 'AB':
                    A += 1
                    C -= 1
                    ans.append('A')
            else:
                A += 1
                C -= 1
                ans.append('A')

    print('Yes')
    print('\n'.join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 17512
object Main extends App {
  val MOD = 1000000007
  val n = readLine.toInt
  val a = readLine.split(" ").map(_.toInt)

  val groupByMap = a.groupBy(x => x)

  val ans = groupByMap.foldLeft(0){case (s, (n, arr)) =>
    if(arr.length >= n) s + arr.length - n
    else s + arr.length
  }

  println(ans)
}


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


using namespace std ; 

const int N =2e5 + 7 ; 

long long n ; 
long long a[N] , b[N] ; 

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ;
       // freopen("in.in" , "r" , stdin) ; 
        cin>>n ; 
        for(int i= 0 ; i < n;i++){
                cin>>a[i] >> b[i] ; 
        }
        sort(a ,a +n) ; 
        sort(b , b+n) ; 

        if(n%2){
                cout<< b[n/2] - a[n/2] +1 ; 
        }
        else{
                long long d1 = b[n/2] + b[n/2-1] ;
                long long d2 = a[n/2] + a[n/2-1]; 
                cout<< (d1 - d2 + 1) ; 
        }
        return 0 ; 
}

Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define tcase int _; cin >> _; while(_--)
const int MOD = 1e9+7;
const int MAX = 1e6;

int n;

void solve() {
	cin >> n;
	int cnt=0;
	int ans=0;
	for(int i=0; i<n; i++) {
		int a, b;
		cin >> a >> b;
		if(a == b) cnt++;
		else cnt=0;
		ans = max(ans, cnt);
	}

	if(ans >= 3) cout << "Yes";
	else cout << "No";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	cout << A * B - A - B + 1 << endl;
	PAU;
	return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    ll N, A, B;
    cin >> N >> A >> B;

    if (A > B || (A != B && N == 1)) {
        cout << 0 << endl;
        return 0;
    }

    cout << (B - A) * (N - 2) + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for _ in range(m)]


# Union FInd
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf=UnionFind(n)
ans=n
for x,y,_ in xyz:
  x,y=x-1,y-1
  if uf.same(x,y):continue
  uf.union(x,y)
  ans-=1
print(ans)
#print(uf.same(1,2))


Measured memory_bytes: 94604
#include<stdio.h>

int main(){
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if((a < b)&&(b<c)){
            printf("Yes\n");
    }
    else{
            printf("No\n");
    }   
    
    return 0;
}

Measured memory_bytes: 580
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val a = readInteger()
    println(a + a * a + a * a * a)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


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

int main() {
    while (true) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        int combinations = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                for (int k = j+1; k <= n; k++) {
                    if (i + j + k == x) {
                        combinations++;
                    }
                }
            }
        }
        cout << combinations << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(1 << n);
  for (int i = 0; i < (1 << n); i++) {
    cin >> a[i];
  }

  auto merge = [&](pair<int,int> p, int i) {
    int x, y;
    tie(x, y) = p;
    if (x == i || y == i) return p;
    if (x == -1 || a[i] > a[x]) {
      return make_pair(i, x);
    } else if (y == -1 || a[i] > a[y]) {
      return make_pair(x, i);
    } else {
      return p;
    }
  };

  vector<pair<int,int>> dp(1 << n, make_pair(-1, -1));

  for (int i = 0; i < (1 << n); i++) {
    dp[i] = merge(dp[i], i);
    for (int j = 0; j < n; j++) {
      dp[i | (1 << j)] = merge(dp[i | (1 << j)], dp[i].first);
      dp[i | (1 << j)] = merge(dp[i | (1 << j)], dp[i].second);
    }
  }

  vector<int> ans(1 << n);
  for (int i = 1; i < (1 << n); i++) {
    ans[i] = a[dp[i].first] + a[dp[i].second];
    ans[i] = max(ans[i], ans[i - 1]);
  }

  for (int i = 1; i < (1 << n); i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 7452
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;
#define bit(n, k) ((n) >> (k) & 1)

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for (auto &ai: a) cin >> ai;
    long long ans = 0;
    for (int k = 0; k < 60; k++) {
        long long cnt = 0;
        for (auto ai: a) cnt += bit(ai, k);
        long long tmp = (1LL << k) % MOD;
        (tmp *= cnt) %= MOD;
        (tmp *= n - cnt) %= MOD;
        (ans += tmp) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
N = int(input())
a = []
cnt = 0
if N % 2 == 0:
    for i in range(1, N+1):
        for j in range(i + 1, N+1):
            if i + j != N+1:
                a.append('{0} {1}'.format(i, j))
                cnt += 1
else:
    for i in range(1, N+1):
        for j in range(i + 1, N+1):
            if i + j != N:
                a.append('{0} {1}'.format(i, j))
                cnt += 1
print(cnt)
for i in range(cnt):
    print(a[i])

Measured memory_bytes: 3592
n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))
ans = 0
for x in t:
    low,up = 0,n
    while up - low > 1:
        mid = (up + low) // 2
        if s[mid] <= x:
            low = mid
        else:
            up = mid
    ans += (x == s[low])
print(ans)


Measured memory_bytes: 16708
#include <iostream>

int main(){
    int a,b;
    std::cin >> a >> b;
    int plus=a+b;
    int minus=a-b;
    int cross=a*b;
    
    int max=plus;
    
    if(max<minus){
        max=minus;
    }
    
    if(max<cross){
        max=cross;
    }
    
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
N=sorted(P)
c=0
a=0
b=0
for i in itertools.permutations(N):
    c+=1
    if i==P:
        a=c
    if i==Q:
        b=c
print(abs(a-b))

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

int main(){
    ll n;
    cin >> n;
    ll sum = 0;
    vector<ll> a(n);
    rep(i,n){ 
        cin >> a[i];
        sum += a[i];
    }
    ll minx = sum ,s = 0;
    rep(i,n){
        s += a[i];
        minx = min(minx,abs(s - (sum - s)));
    }
    cout << minx << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define Rep(i,x) for(int i=head[x];i+1;i=nxt[i])
#define rep2(i,a,b) for(int i=(a);i<(b);i++)
#define ff first
#define ss second
using namespace std;
const int N=200005;
const int inf=1e9+7;
typedef long long ll;
//------------------------------------------head---------------------------------------------------//
set<int>con[N][2];
map<pair<int,int>,int> mp;
pair<int,int>cur[N];
int h,r;
inline void upd(pair<int,int> xjt)
{
	//printf("Case 233:%d %d %d\n",xjt.ff,xjt.ss,mp[xjt]);
	if(mp[xjt] && xjt.ff<xjt.ss){cur[r++]=xjt;}
	mp[xjt]++;
}
inline void del(int x,int y,int z)
{
	mp[make_pair(x,y)]--;
	con[x][z].erase(y);
}
void Merge(int x,int y)
{
	int d1=con[x][0].size()+con[x][1].size(),d2=con[y][0].size()+con[y][1].size();
	del(x,y,0);del(y,x,0);del(x,y,1);del(y,x,1);
	if(d1>d2)swap(x,y);
	set<int>::iterator it;set<int>xjt=con[x][0]; set<int>xjt2=con[x][1];
	for(it=xjt.begin();it!=xjt.end();it++){del(x,*it,0);del(*it,x,0);}
	for(it=xjt2.begin();it!=xjt2.end();it++){del(x,*it,1);del(*it,x,1);}
	for(it=xjt.begin();it!=xjt.end();it++)
	{
		con[*it][0].insert(y);con[y][0].insert(*it);
		upd(make_pair(*it,y));upd(make_pair(y,*it));
	}
	for(it=xjt2.begin();it!=xjt2.end();it++)
	{
		con[*it][1].insert(y);con[y][1].insert(*it);
		upd(make_pair(*it,y));upd(make_pair(y,*it));
	}
}
inline int chk(pair<int,int> x)
{
	if(!con[x.ff][0].count(x.ss) || !con[x.ss][0].count(x.ff)) return 0;
	if(!con[x.ff][1].count(x.ss) || !con[x.ss][1].count(x.ff)) return 0;
	return 1;
}
int main()
{
	int n;scanf("%d",&n);
	rep(i,1,n-1)
	{
		int x,y;scanf("%d%d",&x,&y);
		con[x][0].insert(y);
		con[y][0].insert(x);
		upd(make_pair(x,y));upd(make_pair(y,x));
	}
	rep(i,1,n-1)
	{
		int x,y;scanf("%d%d",&x,&y);
		con[x][1].insert(y);
		con[y][1].insert(x);
		upd(make_pair(x,y));upd(make_pair(y,x));
	}
	rep(i,1,n-1)
	{
		if(h==r){puts("NO");return 0;}
		pair<int,int>qq=cur[h++];while(h<r && !chk(qq))qq=cur[h++];
		if(!chk(qq)){puts("NO");return 0;}
		Merge(qq.ff,qq.ss);
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 68224
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

/////////////         qsortのラッピング

int qsort_long_compare_ascend(const void *a, const void *b) {//long型
	long c = *(long*)a - *(long*)b;
	if (c > 0) { return 1; }
	else if (c < 0) { return -1; }
	return 0;
}
int qsort_long_compare_descend(const void *a, const void *b) {//long型
	long c = *(long*)b - *(long*)a;
	if (c > 0) { return 1; }
	else if (c < 0) { return -1; }
	return 0;
}
void ascendOrder(int size, long *array) {//昇順
	qsort(array, size, sizeof(long), qsort_long_compare_ascend);
}
void descendOrder(int size, long *array) {//降順
	qsort(array, size, sizeof(long), qsort_long_compare_descend);
}

int main() {
	long N;
	long C, K, *T;

	cin >> N >> C >> K;

	T = new long[N];
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}

	ascendOrder(N, T);

	long b = 0;
	long c = 0;
	long t1 = T[0] + K;

	for (long i = 0; i < N; i++) {
		if (i >= c + C || T[i] > t1) {
			c = i;
			t1 = T[i] + K;
			b++;
		}
	}
	b++;
	cout << b << endl;

	return 0;
}

Measured memory_bytes: 1788