akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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; }

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi a(n+1),b(n+1,0);
  for (int i = 1; i < n+1; i++) cin >> a[i];

  for (int i = n; i >= 1; i--) {
    int cnt = 0;
    int j = 0;
    while(i*j <= n){
      cnt += b[i*j];
      j++;
    }
    if(cnt%2 != a[i]%2) b[i] = 1;
  }
  int m = 0;
  rep(i, n+1) m += b[i];
  std::cout << m << '\n';
  for (int i = 1; i < n+1; i++) {
    if(b[i] == 1) std::cout << i << '\n';
  }
}


Measured memory_bytes: 2432
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, m, xl, yl int
	n = nextInt()
	m = nextInt()
	xl = nextInt()
	yl = nextInt()

	x := make([]int, n)
	for i := range x {
		x[i] = nextInt()
	}

	y := make([]int, m)
	for i := range y {
		y[i] = nextInt()
	}

	if noWar(x, y, xl, yl) {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}

func noWar(x, y []int, xl, yl int) bool {
	sort.Ints(x)
	sort.Ints(y)
	x_max := x[len(x)-1]
	y_min := y[0]

	for z := xl + 1; z <= yl; z++ {
		if z > x_max && z <= y_min {
			return true
		}
	}
	return false
}


Measured memory_bytes: 640
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int a[10],N,tmp,j=0,d=0;
  REP(i,10)a[i] = 0;
  cin >> N;
  REP(i,N){
    cin >> tmp;
    if(tmp <= 3199)
      a[tmp/400] = 1;
    else
      j++;
  }
  REP(i,10)d += a[i];
  if(N == j){
    cout << 1;
  }else{
    cout << d;
  }
  cout << " " << (d+j) << endl;
  
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long 
#define mod 1000000007
int b[1000000];
int main()
{
	int n;
	cin>>n;
	int a[n+10];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int i=1,re=0;
	while(1)
	{
		if(b[i]==0)
		{
		b[i]=1;
		i=a[i];
		re++;
		if(i==2)
		{
			cout<<re<<endl;
			return 0;
		}
		}
		else
		{
			cout<<-1<<endl;
			return 0;
		}
	}
}

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

int N, t[100100], mx;
vector<int> v;

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> t[i];
        mx = max(mx, t[i]);
    }
    for(int i = 1; i <= mx; i++){
        if(mx % i == 0){
            v.push_back(i);
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += *lower_bound(v.begin(), v.end(), t[i]) - t[i];
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3532
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] l=new int[n];
        for(int i=0;i<n;i++) {
            l[i]=sc.nextInt();
        }
        Arrays.sort(l);
        List<Integer> a=new ArrayList<>();
        for(int i=0;i<Math.min(n, 4);i++) {
            for(int j=0;j<Math.min(n, 4);j++) {
                if(i==j)continue;
                a.add(Integer.parseInt(l[i]+""+l[j]));
            }
        }
        Collections.sort(a);
        System.out.println(a.get(2));
    }
}


Measured memory_bytes: 38532
#include <stdio.h>

int parent(int);
int left(int);
int right(int);


int main(){
  int n,i,A[250],j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(j=1;j<=n;j++){
    printf("node %d: ",j);
    printf("key = %d, ",A[j]);
    if(parent(j)>=1)
      printf("parent key = %d, ",A[parent(j)]);
    if(left(j)<=n)
      printf("left key = %d, ",A[left(j)]);
    if(right(j)<=n)
      printf("right key = %d, ",A[right(j)]);
    printf("\n");
  }
  return 0;
}
int parent(int j){
  return j/2;
}
int left (int j){
  return 2*j;
}
int right(int j){
  return 2*j+1;
}
	     
      



Measured memory_bytes: 2748
#include <stdio.h>
int dis(int (*A)[30], int a, int b, int D);//a番目とb番目の距離
int sq(int s);//平方数の判定
 
int main(void){
  int N, D, i, j, x[30][30], ans=0;
  scanf("%d %d", &N, &D);
  for(i=1; i<=N; i++){
    for(j=1; j<=D; j++){
      scanf("%d", &x[i][j]);
    }
  }
  for(i=1; i<N; i++){
    for(j=i+1; j<=N; j++){
      ans += dis(x, i, j, D);
    }
  }
  printf("%d", ans);
  return 0;
}
 
int dis(int (*A)[30], int a, int b, int D){
  int sum=0, i;
  for(i=1; i<=D; i++){
    sum += (A[a][i] - A[b][i])*(A[a][i] - A[b][i]);
  }
  return sq(sum);
}
int sq(int s){
  int i;
  if(s == 1) return 1;
  for(i=2; i*i <= s; i++){
    if(s == i*i) return 1;
  }
  return 0;
}

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

using namespace std; 
  
int main() {
  int n; cin >> n;
  string s; cin >> s;
  vector <char> ans(26);
  for(int i = 0; i < 26; i++) {
    ans[i] = i + 'A';
  }
  for(int i = 0; i < s.length(); i++) {
    s[i] = ans[(s[i] - 'A' + n) % 26];
  }
  cout << s << '\n';
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,A,B;
  cin>>N>>A>>B;
  cout<<min(A*N,B)<<endl;
  return 0;
}


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

/*long rec(int w[], int v[], int n, int W, int id, long **mem)
{
  if(W<0)
    return -1;
  if(id==n)
    return 0;
  if(W==0)
    return 0;
  if(mem[id][W]!=-1)
    return mem[id][W];
  long a=rec(w,v,n,W,id+1,mem);
  long b=rec(w,v,n,W-w[id],id+1,mem);
  if(b!=-1)
    b+=v[id];
  mem[id][W]=max(a,b);
  return max(a,b);
  
}*/


int main(){
  int n,W;
  cin>>n>>W;
  int w[n],v[n];
  for(int i=0;i<n;i++)
    cin>>w[i]>>v[i];
  /*long **mem=new long*[n+1];
  for(int i=0;i<=n;i++)
  {
    mem[i]=new long[W+1];
    for(int j=0;j<=W;j++)
      mem[i][j]=-1;
  }
  cout<<rec(w,v,n,W,0,mem)<<endl;*/
	  
  long dp[n+1][W+1];
  for(int i=0;i<=n;i++)
    dp[i][0]=0;
  for(int j=0;j<=W;j++)
    dp[0][j]=0;
  long ans=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=W;j++)
    {
      long a=0,b=0;
      a=dp[i-1][j];
      if(j>=w[i-1])
       b=v[i-1]+dp[i-1][j-w[i-1]];
      dp[i][j]=max(a,b);
    }
    
  }
  cout<<dp[n][W]<<endl;
  
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
     
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
     
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
     
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");
#define moshi printf("moshi moshi ! \n");
#define hi printf("hi ! \n");
#define bye printf("bye bye ! \n");
#define o_set(ll) tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define number_of_set_bits  __builtin_popcountll  
const ld PI=3.1415926535897932384626433; 



void func()
{ 
  ll x1,x2,x3,x4,x5;
  cin>>x1>>x2>>x3>>x4>>x5;
  if(x1==0) cout<<"1\n";
  else if(x2==0) cout<<"2\n";
  else if(x3==0) cout<<"3\n";
  else if(x4==0) cout<<"4\n";
  else cout<<"5\n";
}   

     
     
int main() 
{
    fast

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
        
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }     
    return 0;
}

Measured memory_bytes: 3596
#coding: utf-8
#AOJ vol1-0105

list = Hash.new{|index,key|index[key]=Array.new()}

while input = gets do
  break if input.chomp == ""
  input = input.split
  list[input[0]] << (input[1].to_i)
end

list.sort.each do |key,val|
  puts key
  puts val.sort.join(" ")
end

Measured memory_bytes: 6092
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll inf = (1 << 30);
const int MOD = 1000000007;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main() {
    ll n, t, a,N; cin >> N; ll l = 1, r = 1,h,g;
    rep(i, N) {
        cin >> t >> a;
        if (l % t != 0) h = l / t + 1;
        else h = l / t;
        if (r % a != 0) g = r / a + 1;
        else g = r / a;
        n = max(g, h);
        l = n * t; r = n * a;
    }cout << l + r << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<math.h>
typedef long long ll;
using namespace std;
int main()
{   
    ll a[200005];
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a, a + N);
    ll m = 0,c=0;
    for (int i = N-2,j=N-1; i >= 0; i--) {
        m += a[j];
        if (c == 0) {
            c = 1;
            j--;
        }
        else c = 0;

    }
    cout << m;
    return 0;
}

Measured memory_bytes: 5192
#include<stdio.h>
#include<stdlib.h>
#define N 36
#define TRUE 1
#define FALSE 0
 
typedef struct {
    char mark;
    int atai;
} Card;
 
int eq_cards(Card a, Card b){
    if(a.atai == b.atai && a.mark == b.mark) return TRUE;
    else return FALSE;
}
 
void swap(Card *a, Card *b){
    Card temp;
    temp = *a;
    *a = *b;
    *b = temp;
    return;
}
 
Card* selectionsort(int n, Card *r){
    int i,j,minj;
    Card *res;
    res = (Card *)malloc(N * sizeof(Card));
    for(i=0;i<n;i++) res[i] = r[i];
 
    for(i=0;i<n;i++){
        minj = i;
        for(j=i;j<n;j++){
            if(res[j].atai<res[minj].atai) minj = j;
        }
        swap(&res[i], &res[minj]);
    }
    return res;
}
 
Card* bubblesort(int n, Card *r){
    int flag = 1;
    int i;
    Card *res;
    res = (Card *)malloc(N * sizeof(Card));
    for(i=0;i<n;i++) res[i] = r[i];
 
    while(flag){
        flag = 0;
        for(i=n-1;i>0;i--){
            if(res[i].atai<res[i-1].atai){
                swap(&res[i], &res[i-1]);
                flag = 1;
            }
        }
    }
    return res;
}
 
void print_array(Card *cs, int n){
    int i;
    for(i=0;i<n-1;i++) printf("%c%d ", cs[i].mark, cs[i].atai);
    printf("%c%d\n", cs[n-1].mark, cs[n-1].atai);
 
}
 
int is_stable(Card *b, Card *a, int n){
    int i, j, k, l;
    for(i=0;i<n;i++)
        for(j=i+1;j<n;j++)
            for(k=0;k<n;k++)
                for(l=k+1;l<n;l++)
                    if(b[i].atai == b[j].atai && eq_cards(b[i], a[l]) && eq_cards(b[j], a[k])) return FALSE;
    return TRUE;
}
 
int main(){
    int n;
    Card r[N];
    int i, j;
    Card *b_res, *s_res;
 
    scanf("%d", &n);
    for(i=0;i<n;i++) scanf(" %c%d", &r[i].mark, &r[i].atai);
 
    b_res = bubblesort(n, r);
    s_res = selectionsort(n, r);
     
    print_array(b_res, n);
    if(is_stable(r, b_res, n)==TRUE) printf("Stable\n");
    else printf("Un stable\n");
    print_array(s_res, n);
    if(is_stable(r, s_res, n)==TRUE) printf("Stable\n");
    else printf("Not stable\n");
     
    free(b_res);
    free(s_res);
    return 0;
}

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 1e5+5;

vector <ll> prime(L);
vector <ll> factors(L);

void sieve()
{
    prime[1] = 1;

    for(ll i=2; i<L; i++)
    {
        if(prime[i]==0)
        {
            // prime[i] = 1;
            for(ll j=2*i; j<L; j+=i)
            {
                prime[j] = 1;
            }
        }
    }
}

ll modmul(ll a, ll b, ll c)
{
    ll ans = 0;
    a%=c;

    while(b)
    {
        if(b&1)
        {
            ans = (a+ans)%c;
        }

        a = (a+a)%c;
        b>>=1;
    }

    return ans;
}

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

    ll mod = 1e9+7;

    ll N;
    cin >> N;

    ll ans = 1;
    for(ll i=2; i<=N; i++)
    {
        ll temp = i;
        
        for(ll j=2; j<=i; j++)
        {
            while(temp%j==0)
            {
                factors[j]++;
                temp/=j;
            }
        }
    }

    for(ll i=2; i<=N; i++)
    {
        ans = modmul(ans, factors[i]+1, mod);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import collections

N = int(input().split()[0])
S = input()

index2count_dict = collections.defaultdict(int)
left_black_count = 0
for i, char in enumerate(S):
    index2count_dict[i] = left_black_count
    if char == "#":
        left_black_count += 1

right_white_count = 0
min_count = float("inf")
for i in range(N):
    index = N - (i + 1)
    count = index2count_dict[index] + right_white_count
    min_count = min(min_count, count)
    if S[index] == ".":
        right_white_count += 1

ans = min_count
print(ans)


Measured memory_bytes: 33112
#include<bits/stdc++.h>
using namespace std;
string x[1001];
int s[1001][26];
int main()
{
	int n;
	cin>>n;
	int i,j;
	for(i=1;i<=3;i++)
	{
		cin>>x[i];
		for(j=0;j<n;j++)
		{
			s[j+1][x[i][j]-'a']++;
		}
	}
	int ans=0;
	for(i=1;i<=n;i++)
	{
		int maxx=0;
		for(j=0;j<=25;j++)
			maxx=max(s[i][j],maxx);
		ans+=3-maxx;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll N, K, i;
  double pi, pc, ps = 0, pm = 0;
  deque<double> p;
  cin >> N >> K;

  for (i = 0; i < min(N, K); i++) {
    cin >> pi;
    pc = (pi + 1) / 2;
    p.push_back(pc);
    ps += pc;
  }
  pm = ps;

  for (; i < N; i++) {
    cin >> pi;
    pc = (pi + 1) / 2;
    p.push_back(pc);
    ps += pc;
    ps -= p.front();
    p.pop_front();
    pm = max(pm, ps);
  }

  cout << fixed << setprecision(10) << pm << endl;
}


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
constexpr int MX = 100005;
int n, m, p, c[MX], ac, pe;
string s;
bool ok[MX];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	rep(i,m){
		cin >> p >> s;
		p--;
		if(s == "AC") ok[p] = true;
		else if(!ok[p]) c[p]++;
	}
	rep(i,n) if(ok[i]){
		ac++;
		pe += c[i];
	}
	cout << ac << ' ' << pe << '\n';
}

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

typedef long long ll;
int dp[100100];
int main() {
  int N; cin >> N;
  int h[100100];
  for ( int i = 0; i < N; i++ ) {
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for ( int i = 2; i  < N; i++ ) {
    dp[i] = min( abs(h[i] - h[i-1]) + dp[i-1],
		 abs(h[i] - h[i-2]) + dp[i-2]);
  }

  cout << dp[N-1] << endl;
  return 0;
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int v[200005];

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

	ll tot = 0;
	for(int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
		tot += v[i];
	}

	ll ans = 1e18;
	ll cur = 0;

	for(int i = 0; i < n; i++) {
		ans = min(ans, abs((tot-cur) - cur));
		cur += v[i];
	}

	printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,m,A[200000],dp[200000]={0},mod=1e9+7,num[200000]={0};
    cin>>n>>m;
    rep(i,m) cin>>A[i],num[A[i]]++;
    dp[0]=1;
    if(A[0]==1) dp[1]=0;
    else dp[1]=1;
    rep(i,n-1){
        if(num[i]==0) dp[i+2]=(dp[i+2]+dp[i])%mod;
        if(num[i+1]==0) dp[i+2]=(dp[i+2]+dp[i+1])%mod;
    }
    cout<<dp[n]%mod;
}

Measured memory_bytes: 4992
#include <stdio.h>
 
int main(){
  int D,N,k;
  long ans = 1;
  scanf("%d%d", &D, &N);
  for (k = 0; k < D; k++){
    ans *= 100;
  }
  if (N != 100){
    ans = ans*N;
  }else{
    ans = ans*101;
  }
  printf("%ld", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<set>

using namespace std;

int n;
string s[100];
set<string> t;

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

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

	t.emplace(s[0]);
	for (int i = 1; i < n; i++) {
		if(t.count(s[i]) or s[i - 1].back() != s[i].front()){
			cout << "No" << '\n';
			return 0;
		}
		t.emplace(s[i]);
	}
	cout << "Yes" << '\n';
}


Measured memory_bytes: 256
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
mod = 10**9 + 7

inverse = [1] * (max_a + 1)
for i in range(2, max_a + 1):
  inverse[i] = -inverse[mod % i] * (mod // i) % mod

lcm = 1
for i in range(n):
  lcm = lcm * a[i] // gcd(lcm, a[i])
lcm %= mod

sum_b = 0
for i in range(n):
  sum_b = (sum_b + lcm * inverse[a[i]]) % mod
print(sum_b)

Measured memory_bytes: 45144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

ll a[100010];

int main() {
    int n;
    cin>>n;
    rep(i,n) cin>>a[i];

    int zero=0;
    rep(i,n){
        if(a[i]==0) zero++;
    }

    if(zero>0){
        cout<<0<<endl;
        return 0;
    }

    ll prod=1;
    rep(i,n){
        if(a[i]<=1000000000000000000/prod){
            prod*=a[i];
        }
        else{
            cout<<-1<<endl;
            return 0;
        }
    }

    cout<<prod<<endl;
}

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

using namespace std;

long long n,s;
int i;

vector <long long> ans,fact;

bool check(long long d){
	long long tmp = n;
	long long sum = 0;
	while(tmp){
		sum += tmp % d;
		tmp /= d;
	}
	return sum == s;
}

int main(){
	scanf("%lld%lld", &n, &s);
	
	if(s > n)
	return 0 * printf("-1\n");
	else if(n == s)
	return 0 * printf("%lld\n", n + 1);
	
	for(i = 2; i <= sqrt(n); i++){
		if(check(i))
		ans.push_back(i);
	}
	
	long long t = n - s;
	for(i = 1; i <= sqrt(t); i++){
		if(t % i == 0){
			fact.push_back(i);
			if(i != sqrt(t))
			fact.push_back(t / i);
		}
	}
	
	for(i = 0; i < fact.size(); i++){
		if(check(fact[i] + 1LL))
		ans.push_back(fact[i] + 1LL);
	}
	
	sort(ans.begin(), ans.end());
	if(ans.size())
	printf("%lld\n", ans[0]);
	else
	printf("-1\n");
}


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

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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

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; }

void Main(){
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    int i = ceil(a / d);
    int j = ceil(c / b);
    if (i >= j) cout << "Yes" << en;
    else cout << "No" << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3732
#include<iostream>
using namespace std;
int main(){
   int a,b,c,d,e,k;
   cin>>a>>b>>c>>d>>e>>k;
   if((b-a>k)||(c-a>k)||(d-a>k)||(e-a>k)||(c-b>k)||(d-b>k)||(e-b>k)||(d-c>k)||(e-c>k)||(e-d>k)){
    cout<<":(";
   }
   else cout<<"Yay!";
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long double ans, sol, cur, num; long long a, b, n;
vector<pair<long long, long long> > tocke;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n; for (int i=0; i<n; i++) {
	cin >> a >> b; tocke.push_back(make_pair(a, b));}
	sort (tocke.begin(), tocke.end());
	do {
		num+=1; 
		for (int i=1; i<n; i++){
			//cout << ((tocke[i-1].first-tocke[i].first)*(tocke[i-1].first-tocke[i].first))+((tocke[i-1].second-tocke[i].second)*(tocke[i-1].second-tocke[i].second)) << "  ";
			cur=(long double)sqrt((long double)(((tocke[i-1].first-tocke[i].first)*(tocke[i-1].first-tocke[i].first))+((tocke[i-1].second-tocke[i].second)*(tocke[i-1].second-tocke[i].second))));
			sol+=cur; //cout << cur << endl;
			}
	} while (next_permutation(tocke.begin(), tocke.end()));
	//cout << sol << " " << num << endl;
	ans=(long double)((long double)sol/(long double)num); //cout << ans;
	printf("%Lf", ans);
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int a=0,b=0;
  for(int i=0;i<4;i++){
    if(S.at(i)=='+'){
      a++;
    }else{
      b++;
    }
  }
  cout<<a-b<<endl;
}
 


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b;
	scanf("%d %d", &a, &b);
	if(a < b) {
	   printf("a < b\n");
	}else if(a > b){
	   printf("a > b\n");
	}else{
	   printf("a == b\n");
	}
    return 0;
}

Measured memory_bytes: 580
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(len(l)-1, 1, -1):
  for j in range(i-1, 0, -1):
    if l[i]//2 >= l[j]:
      break
    ind = bisect.bisect_left(l, l[i]-l[j]+1)
    ans += j - ind
print(ans)

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int H, W;
string G[51];
bool checked[51][51];

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

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

	int wc = 0;

	cin >> H >> W;
	rep(i, 0, H)
	{
		cin >> G[i];
		rep(j, 0, W)
		{
			if (G[i][j] == '.')
			{
				wc++;
			}
		}
	}

	queue<pair<pair<int, int>, int>> q;
	q.push(make_pair(make_pair(0, 0), 1));
	checked[0][0] = true;

	int dist = -1;

	while (!q.empty())
	{
		auto p = q.front();
		q.pop();

		if (p.first.first == W - 1 && p.first.second == H - 1)
		{
			dist = p.second;
			break;
		}

		rep(i, 0, 4)
		{
			int nx = p.first.first + dx[i];
			int ny = p.first.second + dy[i];

			if (0 <= nx && nx < W && 0 <= ny && ny < H && !checked[ny][nx] && G[ny][nx] == '.')
			{
				checked[ny][nx] = true;
				q.push(make_pair(make_pair(nx, ny), p.second + 1));
			}
		}
	}

	if (dist == -1)
	{
		cout << "-1" << endl;
	}
	else
	{
		cout << wc - dist << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

ld dp[3001][3001];

int main()
{
    fastio();

    memset(dp,0,sizeof(dp));

    int n;
    cin>>n;
    vector<ld>p(n);
    for(int i=0;i<n;i++) cin>>p[i];

    // dp[i][j] = prob of # of heads equal j, with index till i
    dp[0][0] = 1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i+1][j] = dp[i][j]*(1-p[i]);
            if( j )
                dp[i+1][j] += dp[i][j-1]*p[i];
        }
    }

    ld ans = 0;
    for(int j=(n+1)/2;j<=n;j++)
    {
        ans += dp[n][j];
    }
    cout<<fixed<<setprecision(12)<<ans,nl;
    return 0;
}

Measured memory_bytes: 141056
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]

def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]

def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]



nums = fetch_one_line()
tmp = ""

flag = True
for n in nums:
    if tmp == n:
        flag = False
        break
    tmp = n

answer = ["Bad", "Good"]
print(answer[int(flag)])



Measured memory_bytes: 38384
N = int(input())
S = [list(input()) for _ in range(N)]

A = 0
B = 0
BA = 0
ans = 0
for i in range(N):
    if S[i][0] == 'B' and S[i][-1] == 'A':
        BA += 1
    elif S[i][0] == 'B':
        B += 1
    elif S[i][-1] == 'A':
        A += 1
    for j in range(len(S[i])-1):
        if S[i][j] == 'A' and S[i][j+1] == 'B':
            ans += 1
if BA > 0:
    ans += BA - 1
    if B != 0:
        A += 1
    if A != 0:
        B += 1
ans += min(A, B)
print(ans)


Measured memory_bytes: 47960
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	a, b, c, d := nextInt4()

	puts(max(a*c, a*d, b*c, b*d))
}


Measured memory_bytes: 1784
#include<iostream>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 310000
using namespace std;
int vis[maxn];
char s[111111];
int main()
{
    int i,j,n,jj=0,sum=0,k,flag;
    cin>>s;
    n=strlen(s);
    if(n%2==0)
    {
        if(s[0]==s[n-1]) 
            printf("First\n");
        else printf("Second\n");
    }
    if(n%2!=0)
    {
        if(s[0]!=s[n-1]) 
            printf("First\n");
        else printf("Second\n");
    }
    return 0;
}


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

using namespace std;

vector<vector<pair<int, int>>> g;

vector<bool> used;
vector<int> pt;

void dfs(int u, int nw)
{
	if (used[u])
	{
		if (nw != pt[u])
		{
			cout << "No" << endl;
			exit(0);
		}
		return;
	}
	used[u] = true;
	pt[u] = nw;
	for (auto p : g[u])
		dfs(p.first, pt[u] + p.second);
}

int main()
{
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	g.resize(n);
	pt.resize(n);
	used.resize(n);
	while (m--)
	{
		int a, b, d;
		cin >> a >> b >> d;
		--a, --b;
		g[a].emplace_back(b, d);
		g[b].emplace_back(a, -d);
	}
	for (int i = 0; i < n; ++i)
		if (!used[i])
			dfs(i, 0);
	cout << "Yes" << endl;
}



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

int main(){
    int n;
    vector<int> a;
    cin>>n;
    vector<int> testx[n],testy[n];
    int at[n];
    for(int i=0;i<n;i++){
        cin>>at[i];
        for(int j=0;j<at[i];j++){
            int x,y;
            cin>>x>>y;
            testx[i].push_back(x);
            testy[i].push_back(y);
        }
    }
    int table[n];
    int ct=0,max=0;
    bool flag=true;
    for(int i=0;i<(1<<n);i++){
        int tmp = i;
        //printf("tmp:%d\n",tmp);
        for(int j=0;j<n;j++){
            table[j] = ((tmp>>j)&1);
           // table[j] = tmp%2;
           // tmp/=2;
            //printf("table[%d]:%d\n",j,table[j]);
            if(table[j]==1) ct++;
        }/*
        for(int j=0;j<n;j++)
            printf("table[%d]:%d ",j,table[j]);
        printf("\n");*/
        flag=true;
        for(int it=0;it<n;it++){
            for(int j=0;j<at[it];j++){
                if(table[it]==1){
                    if(table[testx[it][j]-1] != testy[it][j]){
                        flag = false;
                        break;
                    }

                }/*else if(table[it]==0){
                    if(table[testx[it][j]-1] == testy[it][j]){
                        flag = false;
                        break;
                    }
                }*/
            }
        }
        if(flag && ct > max){
            max=ct;
            //cout <<"max:"<< max << " i:"<< i<<endl;
        }
        //cout <<ct << " " << max <<endl;
        ct =0;
    }
    cout << max << endl;
}


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

const int INF = 2000000000;
int n;
int res;

int main(){
    int temp;
    int minC = INF;
    int maxP = -INF;

    //freopen("D:\\zhouyu\\study\\codes\\MaximumProfit.txt", "r", stdin);
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> temp;
        if(maxP < (temp-minC)){
            maxP = temp-minC;
        }
        if(minC > temp) {
            minC = temp;
        }
    }
    cout << maxP << endl;
}


Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int test(int n, int s, int i){//n個でsを作る
	//cout << n <<" "<<s<<" "<<i<<endl;
	if(n==0){
		if(s==0){
			return 1;//作れた
		}else{
			return 0;
		}
	}
	if(i>=10 || s-i<0){
		return 0;
	}

	return test(n, s, i+1) + test(n-1, s-i, i+1);
}

int main(){
	int n;
	string omori[]={"1", "2", "4", "8", "16", "32", "64", "128", "256", "512"};
	int t[10];
	while(cin >> n ){
		for(int i=0;i<10;i++){
			t[i]=(n%2);
			n/=2;
		}
		string str="";
		for(int i=0;i<10;i++){
			//cout << t[i] << endl;
			if(t[i])str+=omori[i]+" ";
		}
		str.erase(str.end()-1);
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(
        n: usize,
        m: usize,
        c: isize,
        b: [isize; m],
        a: [[isize; m]; n]
    );

    let mut count = 0;
    for i in 0..n {
        let mut buff = c;
        for j in 0..m {
            buff += b[j] * a[i][j];
        }
        if buff > 0 {
            count += 1;
        }
    }

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


Measured memory_bytes: 2204
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
using namespace std;

int main(){

    int K, N;
    cin >> K >> N;

    vector<int> A(N);
    vector<int> bet(N);
    int res;

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

    for(int i=0;i<N;i++){
        if(i != N-1){
            bet[i] = A[i+1] - A[i];
        } else{
            bet[i] = K - (A[N-1] - A[0]);
        }
    }

    res =  K - *max_element(bet.begin(), bet.end());
    cout << res;

}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<cstdio>
#include<unordered_set>
using namespace std;

int main()
{
	int k, t, i, j, res;
	int a[110];
	cin >> k >> t;
	res = 0;
	for (i = 0; i < t; i++) {
		cin >> a[i];
		if (a[i] > (k + 1) / 2) {
			res = a[i] * 2 - k - 1;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

int q, w, e;
String str, ing;
Vi vi;

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int a, b;
        read a >> b     ;
        if ( b % a ) {
            echo b - a fin;
        }
else 
        echo  a+b  fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

vector<int> vec;

int main()
{
	rep(i,10)
	{
		int a;
		cin>>a;
		vec.pb(a);
	}
	sort(all(vec));

	cout<<vec[9]<<endl;
	
	cout<<vec[8]<<endl;

	cout<<vec[7]<<endl;

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
long long int GCD(long long int a,long long int b){long long int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
using namespace std;
typedef long long ll;
int main() {
  ll a,b,n;
  cin >> n >> a >> b;
  if(a>b){
    cout << 0 << endl;
  }
  else if(n==1&&a!=b){
    cout << 0 << endl;
  }
  else{
    cout << (a+(b*(n-1)))-(b+(a*(n-1)))+1 << endl;
  }
}

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

int n, k, t[202][2];
long long fp, fd;
string s;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> s >> k;
	n = s.size();
	s = 'N' + s;
	t[1][0] = t[n][1] = 1;
	for(int i = 2; i <= n; ++i) {
		if(s[i] == s[i - 1]) {
			t[i][0] = t[i - 1][0] + 1;
		} else {
			t[i][0] = 1;
		}
	}
	for(int i = n - 1; i >= 1; --i) {
		if(s[i] == s[i + 1]) {
			t[i][1] = t[i + 1][1] + 1;
		} else {
			t[i][1] = 1;
		}
	}
	if(t[1][1] == n) {
		cout << (long long)n * k / 2 << endl;
		return 0;
	}
	if(s[1] == s[n]) {
		fp = (long long)((t[1][1] + t[n][0]) / 2) * (k - 1);
		fp += t[1][1] / 2;
		fp += t[n][0] / 2;
		for(int i = 1; i < n; ++i) {
			if(t[i + 1][0] == 1) {
				fd += t[i][0] / 2;
			}
		}
		fd -= t[1][1] / 2;
		fd *= k;
		fp += fd;
		cout << fp << endl;
		return 0;
	} else {
		for(int i = 1; i <= n; ++i) {
			if(i == n || t[i + 1][0] == 1) {
				fp += t[i][0] / 2;
			}
		}
		fp *= k;
		cout << fp << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {

		List <int> mountainList = new List<int> ();
		for (int i = 0; i < 10; i++) {
			var mountain = int.Parse( Console.ReadLine ());
			mountainList.Add (mountain);
		}

		mountainList.Sort();

		Console.WriteLine (mountainList[9]);
		Console.WriteLine (mountainList[8]);
		Console.WriteLine (mountainList[7]);


        
        
    }
}

Measured memory_bytes: 5752
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ld kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n;
    fo(i,n)cin>>x,h+=x,p=max(p,x);
    if(p<h-p)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b,c,k,m;
    cin >> a >> b >> c >> k;
    m=max(max(a,b),c);
    if (a==m){
        for (int i=0;i<k;i++){
            a*=2;
        }
    }else if (m==b){
        for (int i=0;i<k;i++){
            b*=2;
        }

    }else{
        for (int i=0;i<k;i++){
            c*=2;
        }

    }
    cout << a+b+c << endl;    
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
typedef long long ll;

int main()
{
	int N;
	string S;
	int x = 0;
	int ans = 0;

	cin >> N >> S;

	rep(i, N) {
		if (S[i] == 'I') x++;
		else x--;
		ans = max(x, ans);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
	int n, a,b, c, d;
  	cin >>n ;
  
  	a = n/1000;
 	b = n%1000/100;
  	c = n%100/10;
  	d = n%10;
  
  	if(a==b && a==c){
      		cout << "Yes"<< endl;
    }else if(c==d && b==c){
        	cout << "Yes" << endl;
    }else{
      	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                
using namespace std;
typedef long long lint;
#define FOR(i,o,n) for(auto i = (o); (i) < (n); ++(i))
#define REP(i,n) FOR(i,0,n) 
#define REPR(i,n) for(auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr,v) for(auto itr=v.begin(); itr != v.end(); ++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define Vi2(name,h,w)  vector< vector<int> > name((h), vector<int>(w));

int main(void){
	lint N, M; cin >> N >> M;
	vector<lint> inpV(M); REP(i,M) cin >> inpV[i];
	sort(inpV.begin(), inpV.end());

	vector<lint> disV(M-1); 
	for(int i = 1; i < M; i++){
		disV[i-1] = inpV[i] - inpV[i-1];
	} 
	sort(disV.begin(), disV.end());

	lint sum = 0; 
	REP(i, M-1-(N-1)) sum += disV[i];
	cout << sum << endl;
	return 0;
}



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

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

    int n = s.length();

    bool doubling = false;
    map<char,char> ma, mb;

    for(int i = 0; i < n; i++){
        if(ma.count(s[i]) && ma[s[i]] != t[i]){
            doubling = true;
            break;
        }else{
            ma[s[i]] = t[i];
        }
        if(mb.count(t[i]) && mb[t[i]] != s[i]){
            doubling = true;
            break;
        }else{
            mb[t[i]] = s[i];
        }
    }

    if(doubling){
        cout << "No" << endl;
        return 0;
    }

    bool loop = true;
    for(char c = 'a'; c <= 'z'; c++){
        if(ma.count(c)){
            char tmp = ma[c];
            while(ma.count(tmp) && tmp != c){
                tmp = ma[tmp];
            }
            if(ma.count(tmp) == 0)   continue;
            if(tmp != c)    loop = false;
        }
    }

    if(loop)    cout << "Yes" << endl;
    else        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 776
#include<stdio.h>
int main()
{
    int S,h,m,s;
    scanf("%d",&S);
    h = S/3600;
    S = S%3600;
    m=S/60;
    s=S%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2100