akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    lint x; cin>>x;
    lint set = (x+10)/11;
    set*=2;    
    if((x%11)<=6&& x%11!=0) set--;
    cout<<set<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int A[MAXN];
int B[MAXN];
int X[MAXN];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int M,K;cin>>M>>K;
	if(M==1&&K==0){
		cout<<"0 0 1 1\n";
		return 0;
	}
	if(M==1&&K==1){
		cout<<"-1\n";
		return 0;
	}
	if(!(0<=K&&K<=(1<<M)-1)){
		cout<<"-1\n";
		return 0;
	}
	FOR(i,0,(1<<M)-1)if(i!=K)cout<<i<<' ';
	cout<<K<<' ';
	DEC(i,(1<<M)-1,0)if(i!=K)cout<<i<<' ';
	cout<<K<<"\n";
	
	//~ int M=2;
	//~ vector<int>v;
	//~ FOR(i,0,(1<<M)-1){
		//~ v.pb(i);
		//~ v.pb(i);
	//~ }
	//~ do{
		//~ DEC(i,2*(1<<M)-1,0){
			//~ A[v[i]]=i;
		//~ }
		//~ FOR(i,0,2*(1<<M)-1){
			//~ B[v[i]]=i;
		//~ }
		//~ FOR(i,0,2*(1<<M)-1)X[i+1]=X[i]^v[i];
		//~ int K=0;bool poss=true;
		//~ K=X[B[0]+1]^X[A[0]];
		//~ FOR(i,0,(1<<M)-1){
			//~ assert(A[i]<=B[i]);
			//~ int cur=X[B[i]+1]^X[A[i]];
			//~ if(cur!=K){
				//~ poss=false;
				//~ break;
			//~ }
		//~ }
		//~ if(poss&&K){
			//~ cout<<K<<": ";for(auto i:v)cout<<i<<' ';cout<<"\n";
		//~ }
	//~ }while(next_permutation(all(v)));
	
}
/*
1 3
#.#


2 3
#.#
..#

3 3
##.
#.#
..#

3
2 5
6 1
3 7
Ans:6

4
3 7
2 9
8 16
10 8
Ans:9
*/


Measured memory_bytes: 1792
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 a: u32 = read();
    let b: u32 = read();
    let mut ans: u32 = 0;
    let mut outlet: u32 = 1;

    while outlet < b {
        outlet -= 1;
        outlet += a;
        ans += 1;
    }

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


Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var h, n int
	fmt.Scanf("%d %d", &h, &n)
	var sum int
	var skill int
	for i := 0; i < n; i++ {
		fmt.Scan(&skill)
		sum += skill
	}
	if sum >= h {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	cout << N*N*N << endl;

	return 0;
}

Measured memory_bytes: 256
(setq s(concatenate 'list(read-line)))
(setq m 0)
(setq p 0)
(loop for c in s do(if(or(char= c #\A)(char= c #\T)(char= c #\G)(char= c #\C))(incf p)(progn(setq m(max m p))(setq p 0))))
(princ(max m p))

Measured memory_bytes: 5092
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#define prev aewrxew
#define next fawexsr
using namespace std;
typedef long long ll;
typedef long double ld;
const ll inf = numeric_limits<ll>::max() / 2 - 1;
const ld eps = 1e-7;
const ll mod = 1e9 + 7;
const ll maxn = 2456;
ll n;
string s;

char pr(char c) {
    if (c == 'S') return 'W';
    else return 'S';
}

void test(string ans) {
    for (int i = 1; i < n; ++i) {
        if (ans[i] == 'S') {
            if (s[i] == 'o') {
                ans.push_back(ans[i - 1]);
            } else {
                ans.push_back(pr(ans[i - 1]));
            }
        } else {
            if (s[i] == 'o') {
                ans.push_back(pr(ans[i - 1]));
            } else {
                ans.push_back(ans[i - 1]);
            }
        }
    }
    if (ans[0] != ans[n]) {
        return;
    }
    ans.pop_back();
    if (ans[0] == 'S') {
        if (s[0] == 'o' && ans[1] != ans[n - 1]) return;
        if (s[0] == 'x' && ans[1] == ans[n - 1]) return;
    } else {
        if (s[0] == 'x' && ans[1] != ans[n - 1]) return;
        if (s[0] == 'o' && ans[1] == ans[n - 1]) return;
    }
    if (ans[1] == 'S') {
        if (s[1] == 'o' && ans[0] != ans[2]) return;
        if (s[1] == 'x' && ans[0] == ans[2]) return;
    } else {
        if (s[1] == 'x' && ans[0] != ans[2]) return;
        if (s[1] == 'o' && ans[0] == ans[2]) return;
    }
    cout << ans;
    exit(0);
}

signed run() {
    cin >> n;
    cin >> s;
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 2; ++j) {
            string ans = "";
            if (i) ans.push_back('S');
            else ans.push_back('W');
            if (j) ans.push_back('S');
            else ans.push_back('W');
            test(ans);
        }
    }
    cout << -1;
    return 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#else
#define TASK ""
    if(strlen(TASK)>0) {
        freopen(TASK".in","r",stdin);
        freopen(TASK".out","w",stdout);
    }
#endif
    run();
    cout.flush();
    cerr << "time: " << clock() * 1000 / CLOCKS_PER_SEC << endl;
    return 0;
}

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define endl            "\n"

#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define mii             map <int, int>
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))


#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3e5 + 7;
int dp[3005][3005];

void solve()
{
	string s, t;
	cin >> s >> t;

	int n1 = s.length();
	int n2 = t.length();
	s = " " + s;
	t = " " + t;
	mset(dp, 0);
	loop(i, 1, n1 + 1)
	{
		loop(j, 1, n2 + 1)
		{
			if ( s[i] == t[j] )
			{
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	vector<char> v;
	int x = n1, y = n2;
	while ( x > 0 and y > 0 )
	{
		if ( s[x] == t[y] )
		{
			v.pb(s[x]);
			x--; y--;
		}
		else
		{
			if ( dp[x][y - 1] > dp[x - 1][y] ) y = y - 1;
			else x = x - 1;
		}
	}
	int cnt = v.size();
	rloop(i, cnt - 1, 0) cout << v[i];

	return;
}

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

	cout << setprecision(9) << fixed;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 70784
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc155/tasks/abc155_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string N; cin >> N;
    int len = (int)N.length();
    auto dp = make_v<ll>(len+1,2);
    fill_v(dp,LINF);
    
    dp[0][0] = 0; dp[0][1] = 1;
    
    for(int i = 0; i < len; i++){
        int n = N[i] - '0';
        dp[i+1][0] = min(dp[i][0]+n,dp[i][1]+(10-n));
        dp[i+1][1] = min(dp[i][0]+(n+1),dp[i][1]+10-(n+1));
    }
    res = dp[len][0];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	int Min = a * (n - 1) + b;
	int Max = a + b * (n - 1);
	if (Min > Max)cout << 0 << endl;
	else cout << Max - Min + 1;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,k,a,ans,allcnt;
vector<int> v,cnt;

main() {
    cin >> n >> k;
    rep(i,n) cin >> a,v.pb(a)
    sort(all(v));
    int tmp=v[0],c=1;
    rep1(i,n) {
        if (v[i]==tmp) c++;
        else {
            cnt.pb(c)
            c=1;
            tmp = v[i];
            allcnt++;
        }
    }
    sort(all(cnt));
    rep(i,allcnt-k) ans+=cnt[i];
    ct(ans)
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    if (2 * Q < H)
        H = 2 * Q;
    if (2 * H < S)
        S = 2 * H;
    if (2 * S < D)
        D = 2 * S;

    cout << (D * (N / 2)) + (S * (N % 2)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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



int main() {
    int a, b;
    cin >> a >> b;
    if(a <= b) {
        cout << a << endl;
    }
    else {
        cout << a - 1 << endl;
    }
}

Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
lst = [int(a) for a in stdin.readline().rstrip().split()]

ans = 0
while True:
    count = len([a for a in lst if a % 2 == 1])
    if count > 0:
        break
    else:
        ans += 1

    lst = list(map(lambda x: x // 2, lst))

print(ans)


Measured memory_bytes: 2940
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse = True)
q.sort(reverse = True)

for i in range(x):
  r.append(p[i])
for j in range(y):
  r.append(q[j])
           
r.sort(reverse = True)  

ans = 0
for i in range(x+y):
  ans += r[i]
print(ans)

Measured memory_bytes: 23328
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 25;

int n;
int a[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = 0;
	for(int i = 2; i <= n - 1; i++)
	{
		vector<int> v;
		v.push_back(a[i - 1]);
		v.push_back(a[i]);
		v.push_back(a[i + 1]);
		sort(v.begin(), v.end());
		ans += (a[i] == v[1]);
	}
	cout << ans;
	return 0;
}

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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define db(...) 42
#endif

using ll = long long;

int main() {
  int n;
  cin >> n;
  ll a = 1, b = 1;
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    ll d = max((a + x - 1)/x, (b + y - 1) / y);
    a = d * x;
    b = d * y;
  }
  cout << a + b << endl;
  return 0;
}


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

int main() {
    int num, i;
    int *a;

    cin >> num;
    a = new int[num];
    for(i=0;i<num;i++){
        cin >> a[i];
    }
    for(i=num-1;i>0;i--){
        cout << a[i] << " ";
    }
    cout << a[0] << endl;
    return 0;
}


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  while(1){
    int q1,b,c1,c2,q2,p,n;
    cin >> q1;
    if(!q1)break;
    cin >> b >> c1 >> c2 >> q2;
    p = min(b/c1,q2);
    b -= p*c1;
    n = b/c2;
    b -= n*c2;
    int f=0;
    while(p){
      if(p+n >= q1){
	f=1;
	break;
      }
      p--;
      b+=c1;
      int t = b/c2;
      n+=t;
      b-=t*c2;
    }
    if(f){
      cout << p << ' ' << n << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+5;
const long long mod=1000000000+7;
int n;
long long ans=1,cou=0;
bool a[maxn*2];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
	{
		char ch;ch=getchar();
		while(ch!='B'&&ch!='W') ch=getchar();
		if(ch=='B') a[i]=1;
		else a[i]=0;
	}
	for(int i=1;i<=2*n;i++)
	{
		if(((i-1)&1)==a[i]) {ans=ans*cou%mod;--cou;}
		else ++cou;
		if(cou<0) {printf("0\n");return 0;}
	}
	if(cou>0) {printf("0\n");return 0;}
	for(long long i=1;i<=n;i++) ans=ans*i%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
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
 *
 * @author ZYCSwing
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();
            if (a > b) {
                out.println(a - 1);
            } else {
                out.println(a);
            }
        }

    }
}



Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		int sumAngle;
		double area1, area2;

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			area1= 0;
			sumAngle = 0;
			for (int i = 0; i < n - 1; i++) {
				int angle = sc.nextInt();
				area1 += Math.sin(Math.toRadians(angle));
				sumAngle += angle;
			}
			area1 += Math.sin(Math.toRadians(360 - sumAngle));

			m = sc.nextInt();
			area2 = 0;
			sumAngle = 0;
			for (int i = 0; i < m - 1; i++) {
				int angle = sc.nextInt();
				area2 += Math.sin(Math.toRadians(angle));
				sumAngle += angle;
			}
			area2 += Math.sin(Math.toRadians(360 - sumAngle));

			if ((int)(area1 * 10000000) == (int)(area2 * 10000000)) {
				System.out.println("0");
			} else if (area2 < area1) {
				System.out.println("1");
			} else {
				System.out.println("2");
			}
		}
	}
}

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

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	for(int i = 0;i<10000;i++)
	{
		c-=b;
		if(c<=0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		a-=d;
		if(a<=0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int n, k;
int a[N];
int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

int32_t main()
{
	IOS;
	precompute();
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int ans = 0;
	for(int i = k; i <= n; i++)
	{
		ans += a[i] * nCr(i - 1, k - 1);
		ans %= MOD;
		ans += MOD;
		ans %= MOD;
	}
	for(int i = 1; i + k - 1 <= n; i++)
	{
		ans -= (a[i] * nCr(n - i, k - 1)) % MOD;
		ans += MOD;
		ans %= MOD;
		ans += MOD;
		ans %= MOD;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 
int main() {
    int n; cin >> n;
    ll a, b, c, d; cin >> a >> b >> c >> d;
    b -= a;
    ll l = -(n-1) * d, r = -(n-1) * c;
    for (int i = 0; i < n; i++) {
        if (l <= b && b <= r) {
            puts("YES");
            return 0;
        }
        l += c + d;
        r += c + d;
    }
    puts("NO");
    return 0;
}

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


string M = "MARCH";
int main() {
	int N;
	long long cnt[5] = {};
	cin >> N;
	for(int i = 0; i < N; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < 5; j++) {
			if(s[0] == M[j]) {
				cnt[j]++;
				break;
			}
		}
	}

	long long res = 0;
	for(int i = 0; i < 3; i++) {
		for(int j = i + 1; j < 4; j++) {
			for(int k = j + 1; k < 5; k++) {
				res += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	cout << res << endl;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

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

ll N;
int a[100001];

int main(){
    cin>>N;
    rep(i,N){
        ll x;cin>>x;
        a[i]=x;
    }

    ll ans=0;
    for(int i=0;i<N;i++){
        ans += a[i]/2;
        a[i] = a[i]%2;

        if(a[i]==1 and a[i+1]>0){
            a[i]=0;
            a[i+1]--;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w; cin >> h >> w;
    vector<string> s(h); cin >> s;

    auto a = defvec<char>('.', h, w);
    for (int y = 1, x = 1; y < h - 1; (--(++y))++) {
        a[y][x] = '#';
        if (y % 2 == 0)continue;
        if (x == 1) {
            while (x + 1 < w - 1) {
                ++x;
                a[y][x] = '#';
            }
        }
        else {
            while (1 <= x - 1) {
                --x;
                a[y][x] = '#';
            }
        }
    }

    FOR(y, 0, h) {
        FOR(x, 0, w) {
            if (s[y][x] == '#' || a[y][x] == '#')cout << '#';
            else cout << '.';
        }
        cout << "\n";
    }
    cout << "\n";
    FOR(y, 0, h) {
        FOR(x, 0, w) {
            if (s[y][x] == '#' || a[y][x] == '.')cout << '#';
            else cout << '.';
        }
        cout << "\n";
    }
}

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

using namespace std;

const int N = 2103;

int n, m;
int top, fi[N], ne[N << 1], to[N << 1];
int fa[N][N], from[N][N];
bool line[N][N];
int res;
queue<int> q;

void add(int u, int v);
void getfa(int t, int fa, int p);
void buildGraph(int u, int v);
void getres(int t, int fa, int p);

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 2, u, v; i <= n; ++i) {
    scanf("%d%d", &u, &v);
    add(u, v), add(v, u);
  }
  for (int i = 1; i <= n; ++i) getfa(i, 0, i);
  for (int i = 1, u, v; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    buildGraph(u, v);
  }
  for (int i = 1; i <= n; ++i) getres(i, i, i);
  printf("%d\n", res / 2);
  return 0;
}

void add(int u, int v) {
  ne[++top] = fi[u], fi[u] = top, to[top] = v;
}

void getfa(int t, int f, int p) {
  fa[p][t] = f;
  for (int i = fi[t]; i; i = ne[i]) {
    if (to[i] == f) continue;
    getfa(to[i], t, p);
  }
}

void buildGraph(int u, int v) {
  if (from[u][v] == v) return ;
  if (from[u][v]) return buildGraph(from[u][v], v);
  if (from[v][u]) return buildGraph(from[v][u], u);
  line[u][v] = line[v][u] = true;
  from[u][v] = v, from[v][u] = u;

  vector<pair<int, int> > need;

  for (int times = 1; times <= 2; ++times) {
    q.push(v);
    while (!q.empty()) {
      int f = q.front();
      q.pop();
      for (int i = fi[f]; i; i = ne[i]) {
        if (to[i] == fa[u][f]) continue;
        if (from[u][to[i]]) {
          line[from[u][to[i]]][u] = line[u][from[u][to[i]]] = false;
          need.push_back(make_pair(from[u][to[i]], v));
        } else {
          from[u][to[i]] = v;
          q.push(to[i]);
        }
      }
    }
    swap(u, v);
  }

  for (int i = need.size() - 1; i >= 0; --i) 
    buildGraph(need[i].first, need[i].second);
}

void getres(int t, int f, int p) {
  if (line[f][t]) f = t, res++;
  for (int i = fi[t]; i; i = ne[i]) {
    if (to[i] == fa[p][t]) continue;
    getres(to[i], f, p);
  }
}



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

int main(){
  int n,k;
  cin >> n >> k;
  int res = 0;
  rep(i,n) {
    int h;
    cin >> h;
    if(h>=k) res++;
  }
  cout << res << endl;
  return 0;
}

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

int main(){
  int n,i;
  double sum, average;
  double s2;
  cin >> n;
  while(n != 0){
    int student[n];
    sum = 0;
    average = 0;
    s2 = 0;
    for(i = 0; i < n; i++){
      cin >> student[i];
      sum += student[i];
    }
    average = sum/n;
    for(i = 0; i < n; i++){
      s2 += pow((student[i] - average) , 2);
    }
    s2 = s2/n;
    cout << fixed << setprecision(16) << sqrt(s2) << endl;
    cin >> n;
  }
}



Measured memory_bytes: 3276
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

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

const long long INF = 1e18;

using namespace std;

int main(){
    int n;
    cin >> n;
    ll a[n];
    ll sum = 0LL;
    map<ll, ll> M;
    for(int i=0;i<n;++i){
        cin >> a[i];
        sum += a[i];
        ++M[a[i]];
    }
    int Q;
    cin >> Q;
    for(int i=0;i<Q;++i){
        ll B, C;
        cin >> B >> C;
        ll rem = M[B];
        M[C] += M[B];
        M[B] = 0LL;
        sum += rem * (C - B);
        cout << sum << endl;
    }
}


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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;



const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
 
     




int main() {
    //ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';
    cout.precision(16);
    

    int h, w;
    cin >> h >> w;
    vector<vector<int> > grid(h, vector<int>(w, 0));
    yy (h)
    xx (w)
        cin >> grid[y][x];

    map<pii, int> best;
    best[pp(0, 0)] = grid[0][0];
    ii (h + w - 2) {
        map<pii, int> next;
        fe (it, best) {
            int x1 = it->uu.uu;
            int x2 = it->uu.vv;
            int y1 = i - x1;
            int y2 = i - x2;
            xx (2) {
                int x1n = x1 + x;
                int y1n = y1 + (1-x);
                if (! (x1n < w && y1n < h))
                    continue;
                yy (2) {
                    int x2n = x2 + y;
                    int y2n = y2 + (1-y);
                    if (! (x2n < w && y2n < h))
                        continue;

                    int here = grid[y1n][x1n];
                    if (x1n != x2n)
                        here += grid[y2n][x2n];
                    pii key = pp(min(x1n, x2n), max(x1n, x2n));
                    next[key] = max(next[key], it->vv + here);
                    //printf("put %d %d %d\n", x1n, x2n, it->vv + here);
                }
            }
        }
        //printf("\n");
        swap(best, next);
    }
    int rr = 0;
    fe (it, best) {
        rr = it->vv;
    }

    cout << rr << '\n';
    

    return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
int n,a,b,c,d;
string s;

bool enable(int x,int y){
  FOR(i,x,y){
    if(s[i]=='#' && s[i+1] == '#')
      return false;
  }
  return true;
}

bool afford(int x,int y){
  FOR(i,x,y+1){
    //cerr<<i<<s[i-1]<<" "<<s[i]<<" "<<s[i+1]<<endl;
    if(s[i-1]=='.' && s[i] == '.' && s[i+1] == '.')
      return true;
  }
  return false;
}

int main(){
  cin>>n>>a>>b>>c>>d;
  cin>>s;
  a--;b--;c--;d--;
  if(c<d){
    cout<<((enable(a,c) && enable(b,d))?"Yes":"No")<<endl;
  }else{
    cout<<((enable(a,c) && afford(b,d))?"Yes":"No")<<endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
signed main(){
long long  h,n,a[1000000],sum=0;
  cin>>h>>n;
  for(int i=0;i<n;i++){
	cin>>a[i];
    sum+=a[i];
  }
  if(sum>=h){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
}
 

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a;
    double b;
    cin >> a >> b;
    b *= 100;
    cerr << b << endl;
    ll lb = round(b);
    cerr << lb << endl;
    a *= lb;
    cout << a/100 << endl;

}

Measured memory_bytes: 3776
N, M = map(int, input().split())
li = []
for _ in range(N):
    L = [int(x) for x in input().split()]
    li.append(L[1:])

# print(li)

ans = 0
for i in range(1, M+1):
    s = 0
    for j in range(N):
        s += li[j].count(i)
    if s == N:
        ans += 1
    # all_in = True
    # for j in range(N):
    #     print(li[j][1:])
    #     if i in li[j][1:] is True:
    #         continue
    #     else:
    #         all_in = False
    #         break
    # if all_in is True:
    #     ans += 1

print(ans)


Measured memory_bytes: 3060
n = int(input())

A =[]
for i in range(n):
    m = int(input())
    A.append([list(map(int,input().split())) for i in range(m)])

# print(A)
ans = 0
for i in range(2**n):
    r = 1
    ib = list(format(i, "b").zfill(n))
    # print(ib)
    for j in range(n):
        if ib[j] == "1":
            for k in range(len(A[j])):
                if int(ib[A[j][k][0]-1]) != A[j][k][1]:
                    r = 0
    if r == 1:
        ans = max(ans, ib.count("1"))
print(ans)


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

int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int a = 0, b = 0;
   cin >> a >> b;
   if (b<a)
      --a;
   cout << a;
   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
  int timeH(int);
  int timeM(int);
  int timeS(int);
  int main(void)
  {
    int h,m,s;
    int S;
    scanf("%d",&S);
    h=timeH(S);
    m=timeM(S);
    s=timeS(S);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
  }
  int timeH(int x)
  {
    int h;
    h=x/3600;
    return h;
  }
  int timeM(int y)
  {
    int m;
    m=(y%3600)/60;
    return m;
  }
  int timeS(int z)
  {
    int s;
    s=z%60;
    return s;
  }


Measured memory_bytes: 2140
#include <stdio.h>

char map[32][32];

int black(int y, int x)
{
    if (map[y][x] == '#') return 0;
    map[y][x] = '#';
    return black(y - 1, x) + black(y + 1, x) + black(y, x - 1) + black(y, x + 1) + 1;
}

int main(void)
{
    int w, h;

    while (scanf("%d %d", &w, &h), w != 0){
        int i, j;

        for (j = 1; j <= w; j++){
            map[0][j] = '#';
            map[h + 1][j] = '#';
        }
        for (i = 1; i <= h; i++){
            map[i][0] = '#';
            scanf("%s", map[i] + 1);
            map[i][w + 1] = '#';
        }
        for (i = 1; i <= h; i++){
            for (j = 1; j <= w; j++){
                if (map[i][j] == '@'){
                    printf("%d\n", black(i, j));
                    i = h, j = w;
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int N,D,X[20][20],ans;

int main()
{
	scanf("%d%d",&N,&D);
	for(int i=1;i<=N;i++)
	    for(int j=1;j<=D;j++)
	        scanf("%d",&X[i][j]);
	for(int i=1;i<=N;i++)
	{
		for(int j=i+1;j<=N;j++)
		{
			int sum=0;
			for(int k=1;k<=D;k++)
			    sum=sum+(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			int sum1=sqrt(sum);
			if(sum==sum1*sum1)
			    ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
 } 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a;
    cin >> b;
    if (a > b)
    cout << "a > b" << endl;
    else if (a < b)
    cout << "a < b" << endl;
    else cout << "a == b" << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct Dice{
  int s[6];
  void roll(char c){
    //the view from above
    // N
    //W E
    // S
    //s[0]:top
    //s[1]:south
    //s[2]:east
    //s[3]:west
    //s[4]:north
    //s[5]:bottom
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
  }
  int top() {
    return s[0];
  }
};
signed main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  string s;cin >> s;
  for(int i=0;i<(int)s.size();i++) d.roll(s[i]);
  cout << d.top() << endl;
  return 0;
}

Measured memory_bytes: 3132
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, k;
ll a[MAXN], f[MAXN], inv[MAXN];

ll binPowMod(ll a, ll b) {
    a %= MODBASE;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % MODBASE;
        a = a * a % MODBASE;
        b >>= 1LL;
    }
    return res;
}

ll add(ll a, ll b) {
    return (a+b) % MODBASE;
}

ll mul(ll a, ll b) {
    return (a*b) % MODBASE;
}

ll sub(ll a, ll b) {
    return (a-b+MODBASE) % MODBASE;
}

ll C(int N, int K) {
    if (K > N || K < 0) return 0;
    return mul(f[N], mul(inv[N-K], inv[K]));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    f[0] = 1;
    inv[0] = binPowMod(f[0], MODBASE-2);
    FOR(i,1,100000) {
        f[i] = mul(f[i-1], i);
        inv[i] = binPowMod(f[i], MODBASE-2);
    }
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    sort(a+1, a+n+1);
    ll res = 0;
    FOR(i,1,n) {
        res = add(res, mul(a[i], C(i-1, k-1)));
        res = sub(res, mul(a[i], C(n-i, k-1)));
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

string rotate(string moji){
    string result = "";
    result += moji[moji.size()-1];
    rep(i, moji.size()-1){
        result += moji[i];
    }
    return result;
}

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

    bool flg = false;
    string tmp = s;
    rep(i,s.size()){
        if(tmp == t){
            flg = true;
            break;
        }
        tmp = rotate(tmp);
    }

    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <map>
#include <iostream>
#include <queue>

using namespace std;

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

const ll M = 1e9+7;

ll n, zero, ans;
map<P, ll> mp1;
map<P, ll> mp2;

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

ll mpow(ll a, ll n) {
  if (n == 0) return 1;
  if (n % 2) return mpow(a, n-1) * a % M;
  return mpow(a * a % M, n/2);
}

int main()
{
  cin >> n;
  
  for (ll i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 and b == 0) zero++;
    else if (a == 0) mp1[P(0, 1)]++;
    else if (b == 0) mp2[P(0, 1)]++;
    else if (a > 0 and b > 0 or a < 0 and b < 0) {
      a = abs(a);
      b = abs(b);
      ll tmp = gcd1(a, b);
      a /= tmp;
      b /= tmp;
      mp1[P(a, b)]++;
    } else {
      a = abs(a);
      b = abs(b);
      ll tmp = gcd1(a, b);
      a /= tmp;
      b /= tmp;
      mp2[P(b, a)]++;
    }
  }
  
  ll cnt = 1;
  for (auto p: mp1) {
    ll x = p.second;
    ll y = mp2[p.first];
    if (y == 0) {
      cnt *= mpow(2, x);
      cnt %= M;
      continue;
    }
    cnt = cnt * ((mpow(2, x) + mpow(2, y) - 1 + M) % M) % M;
  }
  
  for (auto p: mp2) {
    ll x = p.second;
    ll y = mp1[p.first];
    if (y == 0) {
      cnt *= mpow(2, x);
      cnt %= M;
    }
  }
  
  cnt = (cnt - 1 + zero + M) % M;
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 28568
N = input()
a = list(map(int,input().split()))
over3200 = 0
syurui_min = 0
syurui_max = 0
b = [0] * 8
for i in a:
    if 3200 <= i and i <= 4800:
        over3200 += 1
    else:
        b[i // 400] = 1
for i in b:
    if(i == 1):
        syurui_min += 1
syurui_max = syurui_min + over3200
if syurui_min == 0:
    syurui_min = 1
print("{0} {1}".format(syurui_min, syurui_max))


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

int main() {
    std::vector<int> n(4);
    for(int i = 1; i <= 3; i++) std::cin >> n[i];
    std::sort(n.begin(),n.end(),std::greater<int>());
    std::cout << 10*n[0]+n[1]+n[2] << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}


int main(){
  int n;
  cin>>n;
  int s[n];
  int sum=0;
  int d=1000;
  bool flag = false;
  for(int i = 0; i < n; i++){
    cin>>s[i];
    sum+=s[i];
    if(s[i]%10!=0){
      d = min(d,s[i]);
      flag = true;
    }
  }
  if(sum%10!=0){
    cout<<sum<<endl;
  }
  else{
    if(flag){
      cout<<sum-d<<endl;
    }
    else{
      cout<<0<<endl;
    }
  }
  return 0;
}

  



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

const int MN = 100005;

int N, A[MN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	std::sort(A + 1, A + N + 1);
	int o = 0;
	for (int i = 1, S = 0; i < N && S < 5e8; ++i)
		S += A[i], o = 2 * S < A[i + 1] ? i : o;
	printf("%d\n", N - o);
	return 0;
}

Measured memory_bytes: 2124
import math
import sys
sys.setrecursionlimit(100000)
N=int(input())
edges=[[] for i in range(N+1)]
d=[-1 for i in range(N+1)]
for i in range(1,N):
	u,v,w=[int(i) for i in input().split()]
	edges[u].append([v,w])
	edges[v].append([u,w])
def kyori(u):
	for v,w in edges[u]:
		if d[v]==-1:
			d[v]=d[u]+w
			kyori(v)
d[1]=0
kyori(1)
for i in d[1:]:
	if i%2==0:
		print(1)
	else:
		print(0)

Measured memory_bytes: 88748
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S, T; cin >> S >> T;
	string ans = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
	if (S.size() < T.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < S.size() - T.size() + 1; i++) {
			bool flg = true;
			for (int j = 0; j < T.size(); j++) {
				if (S[i + j] != T[j] && S[i + j] != '?') flg =false;
			}
			if (flg) {
				string temp; temp = S;
				for (int j = 0; j < T.size(); j++) {
					temp[i + j] = T[j];
				}
				for (int j = 0; j < S.size(); j++) {
					if (temp[j] == '?') temp[j] = 'a';
				}
				if (temp < ans) ans = temp;
			}
		}
	}
  if(ans== "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"){
  cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
	cout << ans << endl;
}

Measured memory_bytes: 256
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = list(map(int,ipti().split()))

    temp = c-a-b

    if temp > 0:
        if 4*a*b < temp**2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384