akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n, m := io.NextInt(), io.NextInt()
		if n == 0 {
			break
		}
		dat := make([]Dat, m)
		for i := 0; i < m; i++ {
			dat[i] = Dat{io.NextInt(), io.NextInt(), io.NextInt()}
		}
		sort.Slice(dat, func(i, j int) bool { return dat[i].t < dat[j].t })
		infected := make([]bool, n+1)
		infected[1] = true
		for i := 0; i < m; i++ {
			infected[dat[i].d] = infected[dat[i].d] || infected[dat[i].s]
		}
		cnt := 0
		for i := 0; i <= n; i++ {
			if infected[i] {
				cnt++
			}
		}
		io.Println(cnt)
	}
}

type Dat struct {
	t, s, d int
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



Measured memory_bytes: 6140
#include<bits/stdc++.h>
#define re register
using namespace std;

/*inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}*/

signed main(void){
	double r;
	cin>>r;
	double pai = 3.14159265358;
	cout<<r*pai*2;
	return 0;
}

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

void dfs(set<int>& s, vector<int>& ans, vector<vector<int>>& to, int n)
{
  for (auto&& e : to[n]) {
    if (s.count(e) == 0) {
      s.insert(e);
      ans[e] += ans[n];
      dfs(s, ans, to, e);
    }
  }
}

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

  vector<int> ans(n);
  vector<vector<int>> to(n);

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  for (int i = 0; i < q; i++) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }

  set<int> s;
  s.insert(0);
  dfs(s, ans, to, 0);

  for (const auto& e : ans) {
    cout << e << endl;
  }
}


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


int main() {
int N,Q;
ll ans = 0;
cin >> N;
vector<int> num(N);
map<int,int> score;
rep(i,N) {
    cin >> num.at(i);
    if (score.count(num.at(i))) score.at(num.at(i)) += 1;
    else score[num.at(i)] = 1;
    ans += num.at(i);
}
cin >> Q;
vector<pair<int,int>> vec(Q);

rep(i,Q) {
    cin >> vec.at(i).first >> vec.at(i).second;
    if(score.count(vec.at(i).first)) {
        ll a = vec.at(i).second - vec.at(i).first;
        ans += a*score[vec.at(i).first];
        if (score.count(vec.at(i).second)) {
            score[vec.at(i).second] += score[vec.at(i).first];
        } else{
        score[vec.at(i).second] = score[vec.at(i).first];
        }
        score[vec.at(i).first] = 0;
         
    }
    cout << ans << endl;
}


return 0;
}


Measured memory_bytes: 8112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define _GLIBCXX_DEBUG
const int MOD = 1000000007;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max(A*B, C*D) << endl;
}

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

int main(){
	int N;
	cin >> N;
	if(N%10==3)	cout << "bon" << endl;
	else if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
		cout << "pon" << endl;
	}
	else		cout << "hon" << endl;
	
	return 0;
}


Measured memory_bytes: 3640
# coding: utf-8
# Your code here!
a,b,c=map(int, input().split())
if a>b:
    if a>c:
        if b>c:
            print(c,b,a)
        else:
            print(b,c,a)
    else:
        print(b,a,c)
else:
    if a>c:
        print(c,a,b)
    else:
        if b>c:
            print(a,c,b)
        else:
            print(a,b,c)



Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int>v(n);
  for(int i=0; i<n; i++)cin >> v[i];
  int a=min(n, k);
  vector<int>f;
  int ret=0;
  for(int l=0; l<=a; l++){
    for(int r=0; r<=a-l; r++){
      for(int m=0; m<=k-l-r; m++){
        if(m>l+r)break;
        f.resize(0);
        for(int i=0; i<l; i++)f.push_back(v[i]);
        for(int i=0; i<r; i++)f.push_back(v[n-1-i]);
        sort(f.rbegin(), f.rend());
        ret=max(ret, accumulate(f.begin(), f.begin()+l+r-m, 0));
      }
    }
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 384
#include"iostream"
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int a = 1;
	for (int i = 0; i < m; i++)
	{
		a = 2 * a;
	}	
	cout << (1900 * m + 100 * (n - m))*a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs


int main() {
  string s;
  cin >> s;
  bool ok = true;
  for (i64 i = 0; i < s.size(); ++i) {
    if (i % 2 == 0 && s[i] == 'L') ok = false;
    if (i % 2 == 1 && s[i] == 'R') ok = false;
  }
  cout << (ok ? "Yes\n" : "No\n");
  return 0;
}


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

int main(void){
 int a,b;
 cin >> a >> b;
 a = (a+11)%13;
 b = (b+11)%13;
 if (a>b) cout << "Alice" << endl;
 else if (a<b) cout << "Bob" << endl;
 else cout << "Draw" << endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin>>s;
  if(n%2==1){
    cout<<"No"<<endl;
  }
  else{
    string t = s.substr(0,n/2);
    if(s==t+t){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 
    string s,s_back;
    cin>>s;
    //s="xabxa";
    int opnum=0;




    NEXT:;
    //cerr<<s<<endl;
    for(int pos=0;pos<s.size();pos++){

        int posback=s.size()-1-pos;
        char sa=s[pos];
        char sb=s[posback];
        //cerr<<sa<<" "<<sb<<endl;
        if(sa!=sb){
            if(sa=='x'){
                //sbの場所にxを入れる
                s.insert(posback+1,"x");
                opnum++;
                //goto NEXT;
            }
            else if(sb=='x'){
                //saの場所にxを入れる
                s.insert(pos,"x");
                opnum++;
                //goto NEXT;
            }
            else{
                //回文にはできない
                cout<<-1<<endl;
                exit(0);
            }

        }
    }

    cerr<<s<<endl;
    cout<<opnum<<endl;



}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int main(){
    int A,B,C;
    cin >> A >> B >>C;

    string ans = "";
    if((B-A)*(C-A) < 0) ans = "No";
    else{
        if(abs(B-A) < abs(C-A)) ans = "No";
        else ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int di[(int)1e7+2];

int32_t main(){
	fastio();
	int n;
	cin >> n;
	
	di[1] = 1;
	for(int i = 2; i <= n; i++){
		if(!di[i]){
			for(int j = 2*i; j <= n; j+=i){
				
				int cnt = 0;
				int k = j;
				while(k%i==0){
					k = k/i;
					cnt++;
				}
				if(!di[j])
					di[j] = (cnt+1);
				else di[j] = di[j] * (cnt+1);
			}
		}
	}

	int ans = 0;

	for(int i = 1; i <= n; i++){

		if(!di[i]) di[i] = 2;
		//cout<< i <<" "<<di[i] << "\n";
		ans += (i*di[i]);
	}

	cout << ans;
}

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

int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  a = N / 1000;
  b = (N - a * 1000) / 100;
  c = (N - a * 1000 - b * 100) / 10;
  d = (N - a * 1000 - b * 100 - c * 10) / 1;
  if ((a == b && b == c) || (b == c && c == d)) 
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 60
#define INF 1000000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n,L;
    cin>>n>>L;
    vector<int>a(n);
    REP(i,n)cin>>a[i];
    int tmp=-1;
    REP(i,n-1){
        if(a[i]+a[i+1]>=L){
            tmp=i;
            break;
        }
    }
    if(tmp==-1){
        OUT("Impossible");
    }else{
        OUT("Possible");
        REP(i,tmp)OUT(i+1);
        for(int i=n-2;i>tmp;i--)OUT(i+1);
        OUT(tmp+1);
    }
    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h> 
int main(void){
  int a,b,c,sum;
  scanf("%d %d %d",&a,&b,&c);
  if(a>=b){
    if(a>=c)  sum=a*10+b+c;
    else  sum=c*10+a+b;
  }
  else{
    if(b>=c)  sum=b*10+a+c;
    else  sum=c*10+a+b;
  }
  printf("%d",sum);
  return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 111;
int K, n;
int a[N];

int main() {
    cin >> K >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int res = a[n - 1];
    for (int i = 0; i < n - 1; i++) res -= a[i];
    res--;
    res = max(res, 0);
    cout << res << endl;
}


Measured memory_bytes: 256
N, a, b = map(int, input().split())
mod = 10 ** 9 + 7

def cal_Combination_mod(n, r, mod):
    r = min(n - r, r)
    
    X = 1
    Y = 1
    
    for i in range(1, r + 1):
        X *= n - i + 1
        Y *= i
        X %= mod
        Y %= mod
    
    ans = X * pow(Y, mod - 2, mod) % mod
    
    return(ans)

ans = (pow(2, N, mod) -1 - cal_Combination_mod(N, a, mod) - cal_Combination_mod(N, b, mod)) % mod


print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 n, a, b; scanf("%lld%lld%lld", &n, &a, &b);
	
	i64 c = a + b;
	i64 ans = n / c * a + std::min(n % c, a);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>

using namespace std;
using ll = long long;

double eta = 1e-10;

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

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

ll div_and_ceil(ll a, ll b) {
  if (0 < a - a / b * b)
    return a / b + 1;
  else
    return a / b;
}

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

  ll e1 = ll(b / c) - div_and_ceil(a, c) + 1;
  ll e2 = ll(b / d) - div_and_ceil(a, d) + 1;
  ll e3 = ll(b / lcm(d, c)) - div_and_ceil(a, lcm(d, c)) + 1;
  cout << b - a + 1 - (e1 + e2 - e3) << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<queue>
#include<map>
using namespace std;
pair<int,int> p[100010],pp;
int a[100010];
queue<int> q[100010];
bool b[100010];
map<pair<int,int>,int>mp; 
void func(int n,int m)
{
	int len=q[n].size();
	int c=1;
	for(int i=0;i<len;i++)
	{
		int f=q[n].front();
		q[n].pop();
		if(b[f])
		{
			continue;
		}
		b[f]=1;
		if(m==c)
		{
			c++;
		}
		pp.first=n;
		pp.second=f;
		mp[pp]=c;
		pp.second=n;
		pp.first=f;
		mp[pp]=c;
		func(f,c);
		c++;
	}
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		cin>>p[i].first>>p[i].second;
		a[p[i].first]++;
		a[p[i].second]++;
		q[p[i].first].push(p[i].second);
		q[p[i].second].push(p[i].first);
	}
	int maxi=a[1];
	for(int i=1;i<=n;i++)
	{
		if(a[i]>maxi)
		{
			maxi=a[i];
		}
	}
	cout<<maxi<<endl;
	b[p[1].first]=1;
	func(p[1].first,0);
	for(int i=1;i<n;i++)
	{
		cout<<mp[p[i]]<<endl; 
	}
	return 0;
}

Measured memory_bytes: 81536
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
res = 0
for _ in range(n):
  a = list(map(int, input().split()))
  s = sum(a[i]*b[i] for i in range(m))
  if s + c > 0:
    res += 1
print(res)

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

using namespace std;

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

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

    set<string> sets;
    rep(start, s.size()){
        repi(i, 0, n){
            sets.insert(s.substr(start, i+1));
        }
    }

    auto itr = sets.begin();
    rep(i, n-1) itr++;
    cout << *itr << endl;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    cout << (1000 - n%1000)%1000 << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
int a,b,c,d,i,j,max,min;
  d=0;
 
scanf("%d %d",&a,&b);

  int st[b],en[b];
  scanf("%d %d",&st[0],&en[0]);
  max=en[0];
  min=st[0];
for(i=1;i<b;++i)
  {scanf("%d %d",&st[i],&en[i]);
  if(st[i]>min) min=st[i];
  if(en[i]<max) max=en[i];
  }
if(max>=min) printf("%d",max-min+1);
else printf("0");
return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
    int S, W;
    cin >> S >> W;

    if (S<=W) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3128
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
n,m = ma()
G = [[]for i in range(3*n)]
for i in range(m):
    u,v = ma();u-=1;v-=1
    G[3*u].append(3*v+1)
    G[3*u+1].append(3*v+2)
    G[3*u+2].append(3*v)
s,t = ma()
s=(s-1)*3
t=(t-1)*3
visited=[False]*(3*n)
INF=10**9
dist = [INF]*(3*n)
que = collections.deque()
que.append(s)
visited[s]=True
dist[s]=0
while que:
    prev = que.popleft()
    for nex in G[prev]:
        if not visited[nex]:
            visited[nex]=True
            dist[nex]=dist[prev]+1
            que.append(nex)
if dist[t]==INF:
    print(-1)
else:
    print(dist[t]//3)


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

int main() {
	int W,H,x,y,r;
	cin >>W>>H>>x>>y>>r;
	if (0<=y-r && y+r<=H && 0<=x-r && x+r<=W){
		cout <<"Yes"<<endl;
	} else {
		cout <<"No"<<endl;
	}
}



Measured memory_bytes: 3096
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0 for _ in range(26)]
calc = [0 for _ in range(26)]

for i in range(D):
  for j in range(26):
    day = i + 1
    calc[j] = c[j] * (day - last[j]) - s[i][j]
  min_idx = calc.index(max(calc))
  last[min_idx] = day
  print(min_idx + 1)

Measured memory_bytes: 9392
package main

import (
	"fmt"
	"sort"
)

func asc(nums ...int) []int{
	sort.Ints(nums)
	return  nums
}

func main() {
	var a, b, c int
	nums := make([]int, 3)
	fmt.Scan(&a, &b, &c)
	nums = asc(a, b, c)
	for i := range nums {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Print(nums[i])
	}
	fmt.Print("\n")
}


Measured memory_bytes: 1152
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,W,w[101],v[101],dp[101][10001]={0};
	cin>>n>>W;
	for(int i=0;i<n;i++)cin>>v[i]>>w[i];
	for(int i=n-1;i>=0;i--)for(int j=0;j<=W;j++)
	{
		if(j<w[i])dp[i][j]=dp[i+1][j];
		else dp[i][j]=max(max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]),dp[i][j-w[i]]+v[i]);
	}
	cout<<dp[0][W]<<endl;
	return 0;
}


Measured memory_bytes: 7028
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
aa = inpl()
tmp = ans = 0
cnt = defaultdict(int)
cnt[0] += 1
ed = set()
for a in aa:
    tmp += a
    cnt[tmp] += 1
    ed.add(tmp)

for e in ed:
    ans += cnt[e]*(cnt[e]-1)//2
print(ans)


Measured memory_bytes: 47232
#include<bits/stdc++.h>
using namespace std;
 
#define inf 0x3f3f3f3f
#define pi acos(-1)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define int long long
template<class T> bool mmin(T &a,T b){return (a>b ?(a=b,true):false);};
template<class T> bool mmax(T &a,T b){return (a<b ?(a=b,true):false);};


int32_t main(){
	
	int l,r;
	cin >> l >> r;
	if(r-l+1>=2019){
		cout << "0\n";
		return 0;
	}
	int ans=2019;
	for(int i=l;i<r;i++)
		for(int j=i+1;j<=r;j++)
			mmin(ans,(i*j)%2019);
	cout << ans << '\n';
	
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

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

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

    int n, m;
    cin >> n >> m;
    
    vector<int> A(n), B(m);
    set<int> st1, st2;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        st1.insert(A[i]);
    }
    for(int i = 0; i < m; i++){
        cin >> B[i];
        if(st1.count(B[i])){
            st2.insert(B[i]);
        }
        st1.insert(B[i]);
    }

    cout << st2.size() << ' ' << st1.size() << endl;
    for(auto x : st2){
        cout << x << endl; 
    }
    for(auto x : st1){
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 15048
#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define pb push_back
#define fo(i,a,b) for(int i=a;i<b;i++)
#define foe(i,a,b) for (int i=a,i<=b;i++)

ll dp[400][400];
ll cost[400][400];

ll fundp(int a[],int i,int j)
{
    if (dp[i][j]!=1e18)
        return dp[i][j];
    if (i==j)
        dp[i][j]=0;
    else
    {
        fo(k,i,j)
           dp[i][j]=min(dp[i][j],fundp(a,i,k)+fundp(a,k+1,j)+cost[i][k]+cost[k+1][j]);
    }
    return dp[i][j];
}

void solve()
{
    fo(i,0,400)
       fo(j,0,400)
         dp[i][j]=1e18;  
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++)
        cin>>a[i];
    fo(i,0,n)
    {
        cost[i][i]=a[i];
        fo(k,i+1,n)
        {
            cost[i][k]=cost[i][k-1]+a[k];
        }
    }
    ll ans=fundp(a,0,n-1);
    cout<<ans<<endl;
}

signed main()
{
   faster;
  // #ifndef ONLINE_JUDGE
    // freopen("ip.txt", "r", stdin);
     //freopen("op.txt", "w", stdout);
   //#endif
    // int t;cin>>t;
     //while(t--)
        solve();
}

Measured memory_bytes: 2816
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
a=lnii()

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

for i in ans:
  print(i)

Measured memory_bytes: 31008
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005
#define PI 3.1415926535897932384626433
#define gcd(a,b) __gcd(a,b)

using namespace std;

ll power(ll x,ll y,ll p)
{
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0)
    {
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}


ll tot=0;

ll cal(ll n){
    ll cur=1;
    ll ans=0;
    ll tot=0,temp=1;
    while(1){
        temp*=2;
        if(n%temp==0){
            n/=temp;
            //cout<<temp<<endl;
            ans++;
            tot+=cur;
            cur++;
        }
        else break;
    }
    while(n%2==0){
        n/=2;
        tot++;
    }
    for(ll i=3;i*i<=n;i+=2){
        if(n%i==0){
            cur=1;
            temp=1;
            while(1){
                temp=i*temp;
                //cout<<n<<" "<<temp<<endl;
                if(n%temp==0){
                    n/=temp;
                    //cout<<temp<<endl;
                    ans++;
                    tot+=cur;
                    cur++;
                }
                else break;
            }
            while(n%i==0){
                n/=i;
                tot++;
            }
        }
    }
    if(n>1) {tot++;ans++;}
    //cout<<n;
    return ans;

}

int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);

    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        if(n==1){
            cout<<0;
            return 0;
        }
        ll temp=cal(n);
        if(tot==1){
            cout<<1;
            return 0;
        }
        cout<<temp;




    }


    return 0;
}

Measured memory_bytes: 3688
N = int(input())
S = input()
MOD = 998244353

r = g = b = 0
rg = gb = br = 0
ans = 1
for c in S:
    if c=='R':
        if gb:
            ans *= gb
            gb -= 1
        elif g:
            ans *= g
            g -= 1
            rg += 1
        elif b:
            ans *= b
            b -= 1
            br += 1
        else:
            r += 1
    elif c=='G':
        if br:
            ans *= br
            br -= 1
        elif b:
            ans *= b
            b -= 1
            gb += 1
        elif r:
            ans *= r
            r -= 1
            rg += 1
        else:
            g += 1
    else: #'B'
        if rg:
            ans *= rg
            rg -= 1
        elif r:
            ans *= r
            r -= 1
            br += 1
        elif g:
            ans *= g
            g -= 1
            gb += 1
        else:
            b += 1
    ans %= MOD

for n in range(1,N+1):
    ans *= n
    ans %= MOD

print(ans)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    int ans = 2*n;
    for(int i = 1;i <= n;i++){
        string sx = s.substr(n-i,i);
        string tx = t.substr(0,i);
        if(sx == tx)ans = 2*n - i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
// Crt. 2019-12-04  20:20:35
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#define N 400005
using namespace std;

int n, m, sh[N], a[N], b[N], num[N], fa[N], vis[N];

int find(int x) {
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

int main() {
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i), sh[++m] = a[i], sum ^= a[i];
    for (int i = 1; i <= n; ++i)
        scanf("%d", b + i), sh[++m] = b[i];
    a[++n] = sh[++m] = sum;

    sort(sh + 1, sh + m + 1);
    m = unique(sh + 1, sh + m + 1) - (sh + 1);

    for (int i = 1; i <= n; ++i)
        ++num[a[i] = lower_bound(sh + 1, sh + m + 1, a[i]) - sh];
    for (int i = 1; i < n; ++i)
        --num[b[i] = lower_bound(sh + 1, sh + m + 1, b[i]) - sh];

    for (int i = 1; i <= m; ++i) if (num[i]) {
            if (b[n]) return puts("-1"), 0;
            else b[n] = i;
        }

    for (int i = 1; i <= n; ++i)
        if (a[i] != b[i]) vis[a[i]] = 1, vis[b[i]] = 1;
    vis[a[n]] = vis[b[n]] = 1;

    for (int i = 1; i <= m; ++i)
        if (vis[i]) fa[i] = i;

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == b[i]) continue;
        if (i < n) ++ans;
        if (find(a[i]) != find(b[i])) fa[find(a[i])] = find(b[i]);
    }

    for (int i = 1; i <= m; ++i)
        ans += (fa[i] == i);

    if (!ans) puts("0");
    else cout << ans - 1 << endl;

    return 0;
}


Measured memory_bytes: 9088
#include <algorithm>
#include <iostream>
#include <string>

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

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

    int ans = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (S.at(i) != T.at(i)) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3856
#include <stdio.h>

int main(void){
	
	int i, n;
	
	scanf("%d", &n);
	
	if(n / 100 == 9){
		n -= 900;
		printf("1");
	}else if(n / 100 == 1){
		n -= 100;
		printf("9");
	}
	
	if(n / 10 == 9){
		n -= 90;
		printf("1");
	}else if(n / 10 == 1){
		n -= 10;
		printf("9");
	}
	
	if(n  == 9){
		printf("1");
	}else if(n == 1){
		printf("9");
	}
	
	return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<ll> a(n);
    rep(i, n){
        int a;
        cin >> a;
        if(a%2) {
            ppp("first");
            return 0;
        }
    }
    ppp("second");
    return 0;


}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define FF first
#define SS second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define inf 1e18
#define mod 1000000007
#define PI 3.1415926535
#define endl "\n"
#define runtime cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

inline int sbt(int x) {return __builtin_popcount(x);}
inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }



int32_t main() {
	fastio
	int n;
	cin >> n;
	int a[n];
	rep(i, 0, n)cin >> a[i];
	int mx = a[0], ans = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] < mx) {
			ans += mx - a[i];
		}
		else {
			mx = a[i];
		}
	}
	cout << ans;



	runtime
	return 0;
}


Measured memory_bytes: 5212
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static int[] s;
	static int[][] a;
	static int[] dp;
	static int ans=int.MaxValue;
	static void Main(){
		s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		a=new int[s[0]][];
		dp=new int[1024];
		for(int i=0;i<s[0];i++){a[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}
		fu(0,0,0);
		Console.WriteLine(ans);
	}
	static void fu(int p,int t,int b){
		if(dp[b]==0){dp[b]=p;}
		else if(dp[b]==p){return;}
		if(t>=ans){return;}
		if(p>=s[1]){ans=t;}
		else{
			for(int i=0;i<s[0];i++){
				if((b&(1<<i))==0){
					fu(p+a[i][1]+a[i][0]*(i+1)*100,t+a[i][0],b|(1<<i));
				}
			}
			
			for(int i=s[0]-1;i>=0;i--){
				if((b&(1<<i))==0){
					if(dp[b|(1<<i)]>=s[1]){
						int q=1;
						while(q!=a[i][0]&&t+q<ans){
							p+=(i+1)*100;
							if(p>=s[1]){ans=t+q;break;}
							q++;
						}
					}
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 13268
N = int(input())
A = list(map(int,input().split()))
ans = [0]*N
sum_A = [0]*N
for i in range(N):
    if i %2 == 0:
        sum_A[0] += A[i]
    else:
        sum_A[0] -= A[i]
for i in range(1,N):
    sum_A[i] = -sum_A[i-1] + 2*A[i-1]
for i in sum_A:
    print(i,end = " ")

Measured memory_bytes: 14616
N = gets.to_i
names = Hash.new(0)
N.times do
  name = gets.chomp
  names[name[0]] += 1
end

ans = 0
%w(M A R C H).combination(3).to_a.each do |s|
  ans += names[s[0]] * names[s[1]] * names[s[2]]
end

puts ans


Measured memory_bytes: 4220
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int mod = 1e9+7;
int dp[5010][5010],n,m;
char s[5010]; 
inline int pw(int x,int p){
	x%=mod;
	int res=1;
	while(p){
	  if(p&1)res=(long long)res*x%mod;
	  x=(long long)x*x%mod;
	  p>>=1;
	}
	return res;
}
int main(){
	int i,j,k;
	scanf("%d",&n);
	scanf("%s",s);
	m=strlen(s);
	dp[0][0]=1;
	for(i=1;i<=n;i++)
	  for(j=0;j<=i;j++){
	  	if(j)dp[i][j]=(dp[i][j]+dp[i-1][j-1]*2)%mod;
	  	if(j==0)dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
	  	dp[i][j]=(dp[i][j]+dp[i-1][j+1])%mod;
	  }
	int Ans=(long long)dp[n][m]*pw(pw(2,m),mod-2)%mod;
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 96512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long C;
  cin >> C;
  vector<long long> x(N);
  vector<int> v(N);
  for (int i = 0; i < N; i++){
    cin >> x[i] >> v[i];
  }
  vector<long long> L1(N + 1, 0);
  L1[1] = v[0] - x[0];
  for (int i = 1; i < N; i++){
    L1[i + 1] = L1[i] + (v[i] - (x[i] - x[i - 1]));
  }
  vector<long long> L2(N + 1, 0);
  for (int i = 1; i <= N; i++){
    L2[i] = L1[i] - x[i - 1];
  }
  vector<long long> R1(N + 1, 0);
  R1[N - 1] = v[N - 1] - (C - x[N - 1]);
  for (int i = N - 2; i >= 0; i--){
    R1[i] = R1[i + 1] + v[i] - (x[i + 1] - x[i]);
  }
  vector<long long> R2(N + 1, 0);
  for (int i = 0; i < N; i++){
    R2[i] = R1[i] - (C - x[i]);
  }
  for (int i = 1; i <= N; i++){
    L1[i] = max(L1[i], L1[i - 1]);
    L2[i] = max(L2[i], L2[i - 1]);
  }
  for (int i = N - 1; i >= 0; i--){
    R1[i] = max(R1[i], R1[i + 1]);
    R2[i] = max(R2[i], R2[i + 1]);
  }
  long long ans = 0;
  for (int i = 0; i <= N; i++){
    ans = max(ans, L1[i] + R2[i]);
    ans = max(ans, L2[i] + R1[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 7492
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int result = 0;

		String str[] = br.readLine().split(" ");
		int list[] = new int[n];

		for (int i = 0; i < n; i++) {
			list[i] = Integer.parseInt(str[i]);
		}

		for (int i = 1; i < n - 1; i++) {
			if (list[i - 1] < list[i] && list[i] < list[i + 1]) {
				result++;
			} else if (list[i - 1] > list[i] && list[i] > list[i + 1]) {
				result++;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 23124
<?php
//???ALDS1_1 Insertion Sort

$n = trim(fgets(STDIN));
$data = trim(fgets(STDIN));
echo "${data}" . PHP_EOL;

$a = explode(" ", $data);
for ($i=1; $i<=$n-1; $i++) {
  $v = $a[$i];
  $j = $i - 1;
  while ($j >= 0 and $a[$j] > $v) {
    $a[$j+1] = $a[$j];
    $j--;
  }
  $a[$j+1] = $v;
  echo implode(" ", $a) . PHP_EOL;
}

Measured memory_bytes: 15432
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    int num[2], a;
    scanf("%d%d", &num[0], &num[1]);
    a = (num[0] * num[1]) % 2;
    if(a == 0){
        printf("Even");
    }else{
        printf("Odd");
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(register int i = a;i <= b; ++i)

const int N = 5e6+10, B1=37,P1=19260817,B2=137,P2=998244353;
ll n;
int main() {
	cin>>n;
	cout<<1ll*(n)*(n+1)/2-(n/3)*(n/3+1)/2*3-(n/5)*(n/5+1)/2*5+(n/15)*(n/15+1)/2*15;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    cin>>n;
    vector<int> a;
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        a.push_back(temp);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll sum=0;
//   int i=1;
    if(n==2){
        cout<<a[0]<<endl;
    }else if(n%2==0){
        for(int i=1;i<ceil((double)n/2);i++){
            sum+=a[i-1];
        }
        // cout<<sum<<endl;
        for(int j=1;j<ceil((double)n/2);j++){
            if(j==ceil((double)n/2)-1){
                sum+=a[j]*2;   
            }else{
                sum+=a[j];
            }
        }
        cout<<sum<<endl;
    }else{
        for(int i=1;i<=ceil((double)n/2);i++){
            sum+=a[i-1];
        }
        for(int j=1;j<n/2;j++){
                sum+=a[j];
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 4304
K = int(input())

cnt = 0
a = 0
ans = False

for i in range(K):
    a = 10 * a +7
    cnt += 1
    if a % K == 0 :
        print(cnt)
        ans = True
        break
    else:
        a = a % K

if ans == False:
    print(-1)

Measured memory_bytes: 9068
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;


using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

string IN;

int az[27] = {};
bool f = false;

int main(){
	cin >> IN;
	for( auto a : IN){
		az[a - 'a'] ++;
		if(az[a - 'a'] > 1){
			 f = true;
			 break;
		}
	}
	if(f){
		cout << "no" << endl;
	}else{
		cout << "yes" << endl;
	}
  return 0;
}

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

using namespace std;

int main() {
  unordered_set<int> set2;
  set2.insert(4);
  set2.insert(6);
  set2.insert(9);
  set2.insert(11);
  int x, y;
  cin >> x >> y;
  if (x == 2 || y == 2) {
    cout << "No" << endl;
  } else if (set2.count(x) && set2.count(y)) {
    cout << "Yes" << endl;
  } else if (!set2.count(x) && !set2.count(y)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll adj[510][510];
ll ptr = 1;

void rec( const std::vector<ll> &vs, ll lev )
{
  if( vs.size() == 1 )
    return;

  std::vector<ll> vs1, vs2;

  rep( i, vs.size()/2 )
    vs1.emplace_back( vs[i] );
  repi( j, vs.size()/2, vs.size() )
    vs2.emplace_back( vs[j] );

  rep( i, vs.size()/2 ) repi( j, vs.size()/2, vs.size() )
    adj[vs[i]][vs[j]] = lev;

  rec( vs1, lev+1 );
  rec( vs2, lev+1 );

  return;
}

int main()
{
  std::cin >> N;

  std::vector<ll> vs( N );
  std::iota( all(vs), 0 );

  rec( vs, 1 );

  rep( i, N-1 ) repi( j, i+1, N )
    std::cout << adj[i][j] << (j==N-1?'\n':' ');

  return 0;
}

Measured memory_bytes: 2560
//start:13:35
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
const int inf=5e18;
const int mod=1e9+7;
const int N=1e5+100;
int a[N],sum[N],dp[N],A,B,bef[N];
signed main(){
	cin >> n >> A >> B;
	if (A<B) swap(A,B);
	for (int i=1;i<=n;i++) cin >> a[i];
	bef[1]=bef[2]=0;
	for (int i=3;i<=n+1;i++){
		if (a[i-1]-a[i-2]>=B) bef[i]=bef[i-1];
		else bef[i]=i-2;
	}
//	for (int i=1;i<=n+1;i++) cout << bef[i] << ' ';cout << endl;
	a[0]=-inf,a[n+1]=inf;
	for (int i=1;i<=n-2;i++){
		if (a[i+2]-a[i]<B){
			cout << 0 << endl;
			return 0;
		}
	}
	dp[0]=1,sum[0]=1;
	for (int i=1;i<=n+1;i++){
		int j=upper_bound(a,a+1+n,a[i]-A)-a-1;
		if (j>=bef[i]-1) dp[i]=(sum[j]-(bef[i]?sum[bef[i]-1]:0)+mod*2)%mod;
//		if (dp[i]<0) dp[i]=0;
		sum[i]=(sum[i-1]+dp[i])%mod;
//		cout << i << ":" << dp[i] << ' ' << sum[i] << endl;
	}
//	for (int i=1;i<=n;i++) cout << dp[i] << ' ';cout << endl;
	cout << dp[n+1]%mod << endl;
	return 0; 
}

Measured memory_bytes: 6732
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int n,a,b,c;
vector<int> L;
int ans=1e9;
void dfs(vector<int> nums,int rest,int merge)
{
  sort(nums.begin(),nums.end());
  vector<int> save=nums;
  do
    {
      ans=min(ans,abs(a-nums[0])+abs(b-nums[1])+abs(c-nums[2])+10*merge);
    }while(next_permutation(nums.begin(),nums.end()));
  if(rest)
    {
      sort(nums.begin(),nums.end());
      for(int i=0;i<int(nums.size())-1;i++)
	{
	  for(int j=i+1;j<int(nums.size());j++)
	    {
	      int newlength=nums[i]+nums[j];
	      nums[i]=newlength;
	      nums.erase(nums.begin()+j);
	      dfs(nums,rest-1,merge+1);
	      nums=save;
	    }
	}
    }
}
int main(int argc,char const* argv[])
{
  cin >> n >> a>> b >> c;
  for(int i=0;i<n;i++)
    {
      int l;
      cin >> l;
      L.push_back(l);
    }
  sort(L.begin(),L.end());
  dfs(L,n-3,0);
  cout << ans << endl;
  return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    cout << n / 3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

vector<ll> A, F;    //Fは降順
vector<pair<ll, P> > S;
ll N, K;

bool check(ll x) {
    ll M = 0;

    for (int i = 0; i < N; i++) {
        if (S[i].first > x) {
            ll a = S[i].second.first, f = S[i].second.second, s = S[i].first;
            M += (s-x+f-1)/f;
        }
    }

    return M <= K;
}

int main() {
    cin >> N >> K;
    A.resize(N), F.resize(N), S.resize(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < N; i++)
        cin >> F[i];
    sort(A.begin(), A.end());
    sort(F.begin(), F.end());
    for (int i = 0; i < N; i++)
        S[i] = pair<ll,P> (A[i] * F[N-1-i], P(A[i], F[N-1-i]));
    
    sort(S.begin(), S.end(), greater<pair<ll,P> >());

    ll l = -1, r = 1e12, mid;
    while (r - l > 1) {
        mid = (l + r) / 2;

        if (check(mid))
            r = mid;
        else 
            l = mid;
    }

    cout << r << endl;
    return 0;
}

Measured memory_bytes: 11132
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    double t,x;
    cin >> t >> x;
    printf("%.10lf\n", t/x);
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  int n = (int)s.size();
  if (s == string(n, s[0])) {
    cout << n * k / 2 << '\n';
    return 0;
  }
  long long cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1]) {
      cnt++;
      i++;
    }
  }
  string ss = s + s;
  long long cnt2 = 0;
  for (int i = 0; i < 2 * n - 1; i++) {
    if (ss[i] == ss[i + 1]) {
      cnt2++;
      i++;
    }
  }
  cout << (cnt2 - cnt) * (k - 1) + cnt << '\n';
  return 0;
}


Measured memory_bytes: 3644
n,r,p,m;R(c){r--?R(scanf("%d",&c)),m=n-n/c/2*2*c,p=p<n-m?(p/c%2?0:n/2)+p/c/2*c+p%c:p<n-m/2?p+m/2:p+n/2-n:0;}main(){for(;~scanf("%d%d",&n,&r);printf("%d\n",p))R(p=n-1);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    rep(i, S.length()-1) {
        if (S[i] == 'A' && S[i+1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256