akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <vector>

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
const double EPS = 1e-5;
double cross(P a, P b) { return imag(conj(a)*b); }

bool lineCross(L l, L m){
	return abs(imag((l.first-l.second)/(m.first-m.second)))<EPS;
}

P ssCrosspoint(L a, L b){
	double A = cross(a.second-a.first, b.second-b.first);
	double B = cross(a.second-a.first, a.second-b.first);
	return b.first + B/A*(b.second-b.first);
}

vector<L> distLine(L l, L m){
	vector<L> res;
	if(lineCross(l,m)){
		P a = (l.first+m.first)/2.0;
		P b = a+(l.second-l.first)/abs(l.second-l.first);
		res.push_back(make_pair(a,b));
	} else {
		P a = ssCrosspoint(l, m);
		if(abs(l.first-a)<EPS) swap(l.first, l.second);
        P dirA = (l.first-a)/abs(l.first-a);
		if(abs(m.first-a)<EPS) swap(m.first, m.second);
		P dirB = (m.first-a)/abs(m.first-a);
		P b = a + (dirA+dirB)/abs(dirA+dirB);
		res.push_back(make_pair(a,b));
		res.push_back(make_pair(a,(b-a)*P(0,1)+a));
	}
	return res;
}

bool onLine(L a, P p){
	return abs(imag((p-a.first)/(a.second-a.first)))<EPS;
}

int main(){
	int n;
	while(cin >> n, n){
		vector< pair<P, P> > vp;
		for(int i=0;i<n;i++){
			double a, b, c, d; cin >> a >> b >> c >> d;{
				vp.push_back(make_pair(P(a,b),P(c,d)));
			}
		}
		
		if(n<3){ puts("Many"); continue; }

		vector<P> vpt;
		vector<L> vlA = distLine(vp[0],vp[1]), vlB = distLine(vp[0], vp[2]);
		for(int i=0;i<vlA.size();i++){
			for(int j=0;j<vlB.size();j++){
				if(lineCross(vlA[i],vlB[j])) continue;
				vpt.push_back(ssCrosspoint(vlA[i],vlB[j]));
			}
		}
		if(!vpt.empty()){
			vector<P> tmp;
			tmp.push_back(vpt[0]);
			for(int i=1;i<vpt.size();i++){
				bool flag = false;
				for(int j=0;j<tmp.size();j++)
					if(abs(tmp[j]-vpt[i])<EPS) flag = true;
				if(!flag) tmp.push_back(vpt[i]);
			}
			vpt = tmp;
		}
		for(int i=0;i<1;i++){
			for(int j=3;j<n;j++){
				vector<P> nvp;
				for(int k=0;k<vpt.size();k++){
					vector<L> vL = distLine(vp[i],vp[j]);
					bool flag = false;
					for(int l=0;l<vL.size();l++){
						if(onLine(vL[l],vpt[k])){
							flag = true;
						}
					}
					if(flag) nvp.push_back(vpt[k]);
				}
				vpt = nvp;
			}
		}
		if(vpt.empty()) { puts("None"); }
		else if(vpt.size()>1) { puts("Many"); }
		else {
			printf("%.5lf %.5lf\n", real(vpt[0]), imag(vpt[0]));
		}
	}
	return 0;
}

Measured memory_bytes: 0
// Your code here!
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    let prm:Vec<usize> = read_vec();
    let mut hs:Vec<i64> = read_vec();
    
    hs.sort_by(|a,b| b.cmp(a));
    
    let mut ans:i64 = 0;
    
    for i in prm[1]..prm[0]{
        ans+=hs[i];
    }
    println!("{:?}",ans);
}




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

int dp[1000001];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	dp[1] = 0;
	dp[2] = 1;
	dp[3] = 3;
	for (int i = 3; i < n; i++) {
		int cnt = 0;
		int j = 1;
		for (; j * j < i; j++) {
			if (i % j == 0) cnt += 2;
		}
		if (i == j * j) cnt++;
		dp[i + 1] = dp[i] + cnt;
	}
	cout << dp[n] << '\n';
	return 0;
}


Measured memory_bytes: 7428
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
template<class T=ll> 
T in(){T x;cin>>x;return (x);}
template<class T> 
void print(T &x){cout<<x<<"\n";}
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x"="<< (x) << "\n"
#define dbgv(x) cerr<<#x<<"\n";reps(y,x){cerr<<y<<" ";}cerr<<"\n"

int main(){
  ll n=in(),a;    
  deque<ll> b;
  rep(i,n){
    scanf("%lld",&a);
    if(i%2){
      b.push_back(a);
    }else{
      b.push_front(a);
    }
  }
  if(n%2){
    rep(i,n){
      printf("%lld ",b[i]);
    }
  }else{
    rep(i,n){
      printf("%lld ",b[n-1-i]);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3840
import sys
input = sys.stdin.readline
from collections import *

def calc(i):
    d = 0
    
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            d += 1
    
    return d
    
S = input()[:-1]
T = input()[:-1]
ans = 10**18

for i in range(len(S)-len(T)+1):
    ans = min(ans, calc(i))

print(ans)

Measured memory_bytes: 67928
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T> void dbg(T x) { cout << x << "\n"; }
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

int n;
vector<vector<int>> G;

int dp[114514];
int memo[114514];
void dfs(int v, int p, int d, int turn) {
    if (dp[v] > d) {
        dp[v] = d;
        memo[v] = turn;
    }
    for (int to : G[v]) if (to != p) dfs(to, v, d + 1, turn);
}

int main() {
    int n; cin >> n;
    memset(memo, 0, sizeof(memo));
    fill(dp, dp + n, INF);
    G.resize(n);
    rep(i, n - 1) {
        int a, b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0, -1, 0, 0);
    dfs(n - 1, -1, 0, 1);
    int one = 0;
    rep(i, n) one += (memo[i] == 1);
    int zero = n - one;
    cout << (zero > one ? "Fennec" : "Snuke") << endl;

    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size())cout<<"GREATER"<<endl;
    else if(a.size()<b.size())cout<<"LESS"<<endl;
    else if(a>b)cout<<"GREATER"<<endl;
    else if(a<b)cout<<"LESS"<<endl;
    else cout<<"EQUAL"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vp in(n);
	rep(i,n)cin>>in[i].first;
	rep(i,n)in[i].first*=-1;
	rep(i,n)cin>>in[i].second;
	sort(all(in));
	int N=1<<n,ans=0;
	rep(i,N){
		int co=0;
		rep(j,n)if(i&1<<j)co++;
		if(co==k){
			int out=0;
			int sum=0;
			rep(j,n)if(i&1<<j){
				if(out<m){
					int t=min(in[j].second,m-out);
					out+=t;
					sum+=in[j].first*t;
				}
			}
			ans=max(ans,-sum+m-out);
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

int N, M, tS, tC;
vector<int> s, c;

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

    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        cin >> tS >> tC;
        s.push_back(tS);
        c.push_back(tC);

        if (N != 1 and tS == 1 and tC == 0) {
            cout << -1;
            return 0;
        }
    }

    bool found = false;
    int number;

    for (number = 0; number < 1000; number++) {
        string str = to_string(number);
        bool accepted = true;

        if (str.size() == N) {
            for (int j = 0; j < M; j++) {
                if (str[s[j] - 1] != c[j] + '0') accepted = false;
            }
        } else {
            accepted = false;
        }

        if (accepted) {
            found = true;
            break;
        }
    }

    if (found) cout << number << "\n";
    else cout << "-1\n";

    // --------------------
    return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
ll x;

int main() {
    scanf("%lld", &x);
    ll n, m;
    int flag = 0;
    for (ll i = -1000; i <= 1000; i++) {
        for (ll j = -1000; j <= 1000; j++) {
            if (i * i * i * i * i - j * j * j * j * j == x) {
                n = i, m = j;
                flag = 1;
                break;
            }
        }
        if (flag)break;
    }
    printf("%lld %lld\n", n, m);
    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define pb push_back
#define inf 10000000000
#define ll long long
#define um unordered_map
#define mp make_pair
using namespace std;
struct act{
    ll val,w;
};
ll solve(vector<act> arr,int n,int weight)
{        
    ll maxval=n*1000;
    ll dp[n+1][maxval+1];
    for(int val=0;val<=maxval;val++)
        dp[1][val]=inf;

    dp[1][0]=0;
    dp[1][arr[1].val]=arr[1].w;
    for(int i=2;i<=n;i++)
    {
        for(int v=0;v<=maxval;v++)
        {
            dp[i][v]=dp[i-1][v];
            if(arr[i].val>v)
            continue;
            dp[i][v]=min(dp[i][v],(arr[i].w+dp[i-1][v-arr[i].val]));

        }
    }
    ll ans=0;
    for(int v=0;v<=maxval;v++)
    {
        if(dp[n][v]<=weight)
        ans=v;
    }
	return ans;
}
int main() {
    int n,weight;
    cin>>n>>weight;
    vector<act> arr(n+1);
    for(int i=1;i<=n;i++)
    {
        ll x,y;
        cin>>x>>y;
        
        arr[i].w=x;
        arr[i].val=y;

    }
    cout<<solve(arr,n,weight);
}


Measured memory_bytes: 81696
/*..................................
manojeet24
....................................*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fl(i,a,b) for(int i=a;i<b;i++)
#define flr(i,a,b) for(int i=a;i>b;i--)
#define INF INT_MAX
ll dp[100005][3],h[100005][3],k;
int n;
ll solve(int i,int e)
{
    if(dp[i][e]!=0)
        return dp[i][e];
    if(i==n-1)
    {
       return dp[n-1][e];
    }
    fl(j,0,3)
    {
        if(j!=e)
            dp[i][e]=max(solve(i+1,j)+h[i][e],dp[i][e]);
    }
    return dp[i][e];
}
int main()
{
    cin>>n;
    fl(i,0,n)
    {
        fl(j,0,3)
            cin>>h[i][j];
    }
    fl(i,0,n)
    {
        fl(j,0,3)
            dp[i][j]=0;
    }
    dp[n-1][0]=h[n-1][0];
    dp[n-1][1]=h[n-1][1];
    dp[n-1][2]=h[n-1][2];
    solve(0,0);
    solve(0,1);
    solve(0,2);
    cout<<*max_element(dp[0],dp[0]+3);
}




Measured memory_bytes: 11136
#include <stdio.h>

int main()
{
int a, b, c, d;
int t;

scanf("%d%d%d%d",&a,&b, &c, &d);

if(b <= c || d <=a ){
  t = 0;
}
else {
  if(a <=c){
    if(b <=d){
      t = b - c;
    }
    else{
      t = d-c;
    }
  }
  else{
    if(b <=d){
      t = b - a;
    }
    else{
      t = d-a;
    }
  }
}


  printf("%d\n", t);

return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};




int main(){
    int N,M; cin>>N>>M;
    UnionFind tree(N);
    for(int i=0;i<M;i++){
        int x,y,z; cin>>x>>y>>z;
        tree.unite(x-1,y-1);
    }
    int ans =0;

    for(int i=0;i<N;i++){
        if(tree.par[i] == i) ans++;
    }

cout<<ans<<endl;
return 0;

}

Measured memory_bytes: 640
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toLong

  def fact(before: Long, k: Long): Long = {
    if(k == n) before + n
    else {
      fact(before + k, k + 1)
    }
  }
  
  println(fact(0, 0))

}


Measured memory_bytes: 25296
#include<stdio.h>

int main(){
  int i=1,j,k;
  
  int f;
  int s;
  int tmp;
  int L[1000000];
  scanf("%d",&s);
  L[0]=s;
  while(1){
    tmp = L[i-1];
    if((tmp%2)==0)
      s = tmp/2;
    else
      s = (3 * tmp) + 1;
    L[i] = s;
    i++;
    k=i;
    for(j = 0;j<k-1;j++){
      if(L[j]== L[i-1]){
        printf("%d\n",i);
        return 0;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if (a - b >= 0) {
            System.out.println("delicious");
        } else if (b - a <= x){
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<math.h>
#include<cstdio>
#include<cstring>
#include<string>
#include<string.h>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
	double a,b;
	cin>>a>>b;
	cout<<b*2-a;
    return 0;
}

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

using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)


int main() {

	
	string str;
	int cnt = 0;

	vector<bool>word(26, false);

	cin >> str;

	rep(i, 0, str.length()) {

		if (word[str[i] - 'a'] == false) {
			word[str[i] - 'a'] = true;
			cnt++;
		}

	}

	if (cnt == 26)cout << "None" << endl;
	else {
		rep(i, 0, word.size()) {
			if (word[i] == false) {
				cout << (char)('a' + i) << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define prique priority_queue
#define Fi first
#define Se second
signed main(){
    string s;
    bool b=true;
    cin>>s;
    int l=s.size();
    int ans=(l-1)*9;
    if(s[0]==9)ans+=s[0];
    else ans+=(s[0]-'0')-1;
    for(int i=1;i<l;i++){
        if(s[i]!='9')b=false;
    }
    if(b)ans++;
    if(l==1)ans=s[0]-'0';
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
    char a[51];
    int n,k=0,i;
    cin >> n >> a;
    for(i=0;i<=n-3;i++)
    {
        if(a[i]=='A' && a[i+1]=='B' && a[i+2]=='C')
        {
            k++;
        }
    }
    cout << k;
    return 0;
}

Measured memory_bytes: 256
s = int(input())

ss = []

ss.append(s)
i = 1

def has_dup(list):
    return len(list) != len(set(list))

while(has_dup(ss) == False):
    if(ss[-1] % 2 == 0):
        ss.append(ss[-1]/2)
    else:
        ss.append(3*ss[-1]+1)
    i += 1

print(i)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
#pragma optimize("unroll-loops");
#pragma optimize("Ofast");
//#include "pch.h"    
using namespace std;

#ifdef DEBUG_BUILD
#  define DEBUG(x) cerr << x
#else
#  define DEBUG(x) do {} while (1)
#endif

#define imie(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)

using ll = long long;
const int nax = 1e6 + 10;

vector<int> primes;
ll lcm(ll a, ll b) {
    return (a*b)/__gcd(a, b);
}

vector<bool> prime(nax, true);

ll abs(ll a, ll b) {
    if(a > b) {
        return a - b;
    }
    return b - a;
}

ll min(ll a, ll b) {
    if(a < b) {
        return a;
    }
    return b;
}
int main() {
    
    ll n, k;
    scanf("%lld%lld", &n, &k);
    
    n %= k;
    
    cout << min(n, abs(n, k)) << "\n";
}
    
    


Measured memory_bytes: 3804
n, a, b = map(int, input().split())
s = list(input())

total = 0
bcnt = 0
for i in range(n):
    if s[i] == "c":
        print("No")
    elif s[i] == "a":
        if total < a + b:
            total += 1
            print("Yes")
        else:
            print("No")
    elif s[i] == "b":
        if total < a + b and bcnt < b:
            total += 1
            bcnt += 1
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 4712
N = gets.to_i
As = gets.split.map(&:to_i)

mx = ->(a, b){a > b ? a : b}
ab = ->(a, b){(a - b).abs}
as = As.map.with_index.sort_by(&:first).reverse
dp = Array.new(N + 1){Array.new(N + 1, 0)}
(0 ... N).each do |n|
  a, p = as[n]
  (0 .. n).each do |x|
    y = n - x
    dp[x + 1][y] = mx[dp[x + 1][y], dp[x][y] + ab[x, p]*a]
    dp[x][y + 1] = mx[dp[x][y + 1], dp[x][y] + ab[N - 1 - y, p]*a]
  end
end
puts (0 ... N).map{dp[_1][N - _1]}.max

Measured memory_bytes: 45728
from collections import Counter
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
AA = list(accumulate(A))

def comb(n):
  return n*(n-1)//2

AC = dict(Counter(AA))
answer = 0
if 0 in AC:
  answer = AC[0]

for v in AC.values():
  answer += comb(v)
print(answer)

Measured memory_bytes: 148144
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	fmt.Println(n*800 - n/15*200)
}


Measured memory_bytes: 1772
n,m = list(map(int, input().split()))
parent = list(range(n))

def root(x):
    if parent[x] == x: return x
    rt = root(parent[x])
    parent[x] = rt
    return rt

def unite(x,y):
    x = root(x)
    y = root(y)
    if x == y: return
    parent[y] = x

for _ in range(m):
    a,b = list(map(lambda x: int(x)-1, input().split()))
    unite(a,b)

for i in range(n):
    root(i)

cnt = len(set(parent)) - 1
print(cnt)

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

int main() {
    ll n; cin >> n;
    vl b(n-1);
    rep(i,n-1) cin >> b[i];

    ll ans = b[0] + b[n - 2];
    rep(i,n-2){
        ans += min(b[i],b[i + 1]);
    }
    cout << ans << endl;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int L, R;
	cin >> L >> R;
	if (L - R >= 2018) {
		cout << 0;
	}
	else {
		for (long long int i = L; i <= R; i++) {
			if (i % 2019 == 0) {
				cout << 0;
				return 0;
			}
		}

			R = R % 2019;
			L = L % 2019;
			long long int ans = 1000000;
			for (long long int i = L; i < R; i++) {
				for (long long int j = i+1; j <= R; j++) {
					long long int c = i * j % 2019;
					ans = min(ans, c);
				}
			}
			cout << ans;
			return 0;
	}
}


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

class unionfind {
  vector<pair<int, int>> root;
  
public:
  unionfind(int n) {
    for (int i = 0; i < n; i++) {
      root.emplace_back(i, 1);
    }
  }
  
  int find(int n) {
    if (root.at(n).first == n) return n;
    return find(root.at(n).first);
  }
  
  void merge(int m, int n) {
    m = find(m); n = find(n);
    if (m == n) return;
    if (root.at(m).second < root.at(n).second) {
      root.at(m).first = n;
      root.at(n).second += root.at(m).second;
    } else {
      root.at(n).first = m;
      root.at(m).second += root.at(n).second;
    }
  }
  
  int get_size(int n) {
    return root.at(find(n)).second;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  unionfind t(n);
  vector<int64_t> ans(m + 1), a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int i = 0; i < m; i++) {
    if (t.find(a.at(i)) != t.find(b.at(i))) {
      ans.at(i + 1) = ans.at(i) + (int64_t) t.get_size(a.at(i)) * t.get_size(b.at(i));
      t.merge(a.at(i), b.at(i));
    } else {
      ans.at(i + 1) = ans.at(i);
    }
  }
  for (int i = m - 1; i >= 0; i--) {
    cout << (int64_t) n * (n - 1) / 2 - ans.at(i) << endl;
  }
}


Measured memory_bytes: 4596
#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 <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

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

i64 memo[51][51];
i64 conb(i64 x, i64 y) {
  if (memo[x][y] > 0) return memo[x][y];
  i64 z = 0;
  if (y == 0 || y == x) z = 1;
  else z = conb(x - 1, y) + conb(x - 1, y - 1);
  return memo[x][y] = z;
}

i64 n, a, b;
vector<i64> v;
int main() {
  cin >> n >> a >> b;
  read_n(v, n);
  sort(begin(v), end(v));
  i64 vm = v.back();
  i64 mcnt = 0;
  for (i64 x : v) if (x == vm) ++mcnt;

  i64 ans = 0;
  if (mcnt >= a) {
    for (i64 x = a; x <= min(mcnt, b); ++x) {
      ans += conb(mcnt, x);
    }
    cout << vm << '\n' << ans << '\n';
  } else {
    i64 vb = v[n - a];
    i64 bcnt = 0, ocnt = 0;
    for (i64 x : v) if (x == vb) ++bcnt;
    for (i64 i = n - 1; v[i] != vb; --i) ++ocnt;
    double sum = 0;
    for (i64 i = n - 1; i >= n - a; --i) sum += v[i];
    ans = conb(bcnt, a - ocnt);
    printf("%.10lf\n%lld\n", sum / a, ans);
  }
  return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,x,d = list(map(int, input().split()))
if d==0:
    if x==0:
        ans = 1
    else:
        ans = n+1
else:
    if d<0:
        x *= -1
        d *= -1
#         x = x + d*(n-1)
#         d *= -1
    D = {} # (要素数, 最大値)
    for i in range(n+1):
        # iX+sD
        if x!=0:
            ii = i*x % d
            jj = (i*x-ii)//d
        else:
            ii = 0
            jj = 0
#         print(ii,jj)
        if ii not in D:
            D[ii] = []
        D[ii].append((i*(i-1)//2 + jj, (2*n-1-i)*i//2 + jj))
    ans = 0
    for k,v in D.items():
        v.sort()
        m = -float("inf")
        val = 0
        for l,r in v:
#             val += (r - (max(l-1, m)))
            val += max(r - (max(l-1, m)), 0)
            m = max(m, r)
        ans += val
                    
#         num = ((2*n-1-i)*i//2 + jj) - max(i*(i-1)//2 + jj - 1, m if m is not None else -float("inf"))
#         D[ii] = [D[ii][0]+num, (2*n-1-i)*i//2 + jj]
#         print(D)
#         if ii==0 and (2*n-1-i)*i//2 + jj >= 0 >= i*(i-1)//2 + jj:
#             zz = True
#     ans = sum(v[0] for k,v in D.items() if v[1] is not None) + (not zz)
# print(ans)
print(ans)

Measured memory_bytes: 123844
#include<bits/stdc++.h>
using namespace std;
int n,a,b,last;
void work(int len){
    int l=last+1,r=last+len;
    for (int i=r;i>=l;i--)
        cout<<i<<' ';
    last+=len;
}
int main(){ 
    ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    if (a+b>n+1||(long long)a*b<n){
        cout<<-1;
        return 0;
    }
    int len=0,c=0;
    if (a>1)len=(n-b)/(a-1),c=(n-b)%(a-1);
    for (int i=1;i<=c;i++)
        work(len+1);
    for (int i=c+1;i<a;i++)
        work(len);
    work(b);
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	int n, ans=1;
	cin >> n;
	bool num[1001] = {false};
	for(int i = 2; i <= 1000; i++){
		int j = i;
		while(j*i <= 1000)num[j*i] = true, j *= i;
	}
	for(int i = 1; i <= n; i++)if(num[i])ans = i;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String,Integer> blueMap = new HashMap<String,Integer>();
		Map<String,Integer> redMap = new HashMap<String,Integer>();
		for (int i=0;i<N;i++) {
			String s = sc.next();
			if (blueMap.containsKey(s)==false) {
				blueMap.put(s, 1);
				redMap.put(s, 0);
			} else {
				Integer in = blueMap.get(s);
				in ++;
				blueMap.put(s, in);
			}
		}
		int M = sc.nextInt();
		for (int i=0;i<M;i++) {
			String s = sc.next();
			if (redMap.containsKey(s)==false) {
				redMap.put(s, 1);
			} else {
				Integer in = redMap.get(s);
				in ++;
				redMap.put(s, in);
			}
		}
		int max =0;
		Set<String>  set = blueMap.keySet();
		for (String s : set) {
			Integer blue =blueMap.get(s);
			Integer red =redMap.get(s);
			if (blue-red>max) {
				max = blue-red;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
int isSameString(char a[],char b[]);
char getLastChar(char a[]);

int main(void){
    int n,i,j;
    char tmp,siri[110][15];
    scanf("%d\n",&n);
    gets(siri[0]);
    for(i=1;i<n;i++){
        gets(siri[i]);
        tmp=getLastChar(siri[i-1]);
        if(siri[i][0]!=tmp){
            puts("No");
            return 0;
        }
    }
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            if(isSameString(siri[i],siri[j])){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}

int isSameString(char a[],char b[]){
    int i=0;
    while(a[i]&&b[i]){
        if(a[i]!=b[i]){
            return 0;
        }
        i++;
    }
    if(a[i]||b[i]){
        return 0;
    }else{
        return 1;
    }
}

char getLastChar(char a[]){
    int i=0;
    while(a[i]){
        i++;
    }
    return a[i-1];
}

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

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

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

int main() {
  int n;
  cin >> n;
  long long res = 1;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    res = lcm(res, x);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int N=S.size();
	int flag=1;
	rep(i,N){
		if(i%2==0&&S[i]=='L') flag=0;
		if(i%2==1&&S[i]=='R') flag=0;
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;

fn main() {
    let _n = read_one::<usize>();
    let xn = read::<isize>();
    let min = *xn.iter().min().unwrap();
    let max = *xn.iter().max().unwrap();

    let mut ans = std::isize::MAX;
    for i in min..=max {
        let mut cost = 0;
        for x in xn.iter() {
            cost += (x - i as isize).pow(2);
        }
        ans = cmp::min(ans, cost);
    }

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

#[allow(unused)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 2128
N, X = (int(i) for i in input().split())

import math

def Pn(n):
    x = 0
    for i in range(n):
        x = x + 2**i
        yield x

Paty = list(Pn(N+1))
Bager = [2*i -1 for i in Paty]

def Ln(n, x):
    if x == 0:
        return 0
    if n == 0:
        return 1

    harf = (Bager[n] + 1) // 2

    if x == harf:
        return 1 + Paty[n-1]

    if x > harf:
        return Ln(n-1, x - 2 - Bager[n-1]) + Paty[n-1] + 1
    else:
        return Ln(n-1, x-1)

print(Ln(N, X))


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>
using namespace std;

//#include<bits/stdc++.h>
vector<int>d(999999, 999999);
int main() {
	
	vector<int>p;
	int b = 6, c = 9;
	while (b <= 100000) {
		p.push_back(b);
		b *= 6;
	}
	while (c <= 100000) {
		p.push_back(c);
		c *= 9;
	}
	p.push_back(1);
	for (int i = 0; i < p.size(); i++) {
		d[p[i]] = 1;
	}
	sort(p.begin(), p.end());

	int n;
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		
		for (int j = 0; j < p.size(); j++) {
	
			int y = i - p[j];
			if (y < 0)break;
			d[i] = min(d[i], d[y] + 1);
		}
	}
	cout << d[n] << endl;

	return 0;
}

Measured memory_bytes: 4096
#include <cstdio>

int main() {
    int a, b, c, t;
    scanf("%d %d %d", &a, &b, &c);

    if (a > b) {
        t = a;
        a = b;
        b = t;
    }
    if (b > c) {
        t = b;
        b = c;
        c = t;
    }
    if (a > b) {
        t = a;
        a = b;
        b = t;
    }

    printf ("%d %d %d\n", a, b, c);
    return 0;
}

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

int main() {

  int N;
  cin >> N;

  vector<vector<int>> A(2, vector<int>(N));

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

  int maxCount = 0;
  int count = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= i; j++) {
      count += A[0][j];
    }
    for (int j = i; j < N; j++) {
      count += A[1][j];
    }
    maxCount = max(maxCount, count);
    count = 0;
  }

  cout << maxCount << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	ll int x;
	cin>>x;
	ll int p=100,c=0;
	while(p<x)
	{
		p+=p/100;
		c++;
	}
	cout<<c;
}




Measured memory_bytes: 3652
//https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_c
//C - When I hit my pocket...
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll K,A,B; cin>>K>>A>>B;
    ll ad=B-A;
    ll ans=1;
    if(ad>2 && K-(A-1)>0){
        ans+=(A-1);
        K-=(A-1);
        ll r0=K/2;
        ll r1=K-r0*2;
        ans+=r0*(B-A);
        ans+=r1;
    }else{
        ans+=K;
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

int N;
vi W, S, V;
vector<pi> P;
vector<ll> dp;

void input_init(void) {
	cin >> N;
	W.resize(N);
	S.resize(N);
	V.resize(N);
	P.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> W[i] >> S[i] >> V[i];
		P[i] = make_pair(W[i] + S[i], i);
	}
}

ll solve(void) {
	ll ret = (ll)0;
	int sz = P[N - 1].first + 1;
	dp.resize(sz, (ll)0);
	for (int i = 0; i < N; ++i) {
		int id = P[i].second;
		for (int j = S[id]; j >= 0; --j) {
			ll val = dp[j] + V[id];
			ret = max(ret, val);
			if (j + W[id] <= sz)
				dp[j + W[id]] = max(dp[j + W[id]], val);
		}
	}
	return ret;
}

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

	input_init();
	sort(P.begin(), P.end());
	ll ans = solve();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	
	long long int total = 0;
	for(int i = 1; i <= n; i++) {
		if(i % 3 == 0 || i % 5 == 0) {
			continue;
		}
		else {
			total += i;
		}
	}
	printf("%lld\n", total);
	return 0;
}

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

struct TCoordinate
{
	double X;
	double Y;
};

TCoordinate FindSplitMiddle(TCoordinate A, TCoordinate B)
{
	TCoordinate C = {(A.X + B.X) / 2, (A.Y + B.Y) / 2};
	C.X += (sqrt(3) / 6) * (A.Y - B.Y);
	C.Y += (sqrt(3) / 6) * (B.X - A.X);
	return C;
}

void Koch(int n, const TCoordinate &Start, const TCoordinate &End)
{
	if(n == 0){
		return;
	}
	n--;
	
	TCoordinate SplitStart  = { (2 * Start.X + End.X) / 3, (2 * Start.Y + End.Y) / 3};
	TCoordinate SplitMiddle = FindSplitMiddle(Start, End);
	TCoordinate SplitEnd    = { (Start.X + 2 * End.X) / 3, (Start.Y + 2 * End.Y) / 3};
	
	Koch(n, Start,       SplitStart );
	cout << SplitStart.X  << ' ' << SplitStart.Y  << endl;
	
	Koch(n, SplitStart,  SplitMiddle);
	cout << SplitMiddle.X << ' ' << SplitMiddle.Y << endl;
	
	Koch(n, SplitMiddle, SplitEnd   );
	cout << SplitEnd.X    << ' ' << SplitEnd.Y    << endl;
	
	Koch(n, SplitEnd,    End        );
}

int main()
{
	//??????2?????¨??°???????????°??????????????\???????????????????????????????§?????????????????????¨???
	int n;
	cin >> n;
	cout <<   0 << ' ' << 0 << endl;
	Koch(n, {0, 0}, {100, 0});
	cout << 100 << ' ' << 0 << endl;
	return 0;
}

Measured memory_bytes: 3232
def f1():
    if y1 == y2 and m1 == m2:
        return d2- d1
    
    a = 0
    if y1 % 400 == 0 or (y1 % 4 == 0 and y1 % 100 != 0):
        a = 29
    else:
        a = 28
    
    t = 0
    if m1 in [4,6,9,11]:
        t += (30 - d1 + 1)
    elif m1 in [1,3,5,7,8,10,12]:
        t += (31 - d1 + 1)
    else:
        t += (a - d1 + 1)
        
        
    if y1 == y2:
        return f3(t, m1+1)
    else:
        for m in range(m1+1, 13):
            if m in [4,6,9,11]:
                t += 30
            elif m in [1,3,5,7,8,10,12]:
                t += 31
            else:
                t += a
            
        return f2(t)
    
def f2(t):
    for y in range(y1+1, y2):
        if y % 400 == 0 or (y % 4 == 0 and y % 100 != 0):
            t += 366
        else:
            t += 365
    
    return f3(t, 1)
    
def f3(t, s):
    a = 0
    if y2 % 400 == 0 or (y2 % 4 == 0 and y2 % 100 != 0):
        a = 29
    else:
        a = 28
        
    for m in range(s, m2):
        if m in [4,6,9,11]:
            t += 30
        elif m in [1,3,5,7,8,10,12]:
            t += 31
        else:
            t += a
            
    t += (d2 - 1)
            
    return t
            
while True:
    y1, m1, d1, y2, m2, d2 = map(int, raw_input().split())
    if y1 < 0 or m1 < 0 or d1 < 0 or y2 < 0 or m2 < 0 or d2 < 0:
        break
    print f1()

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
#define REVS(v) reverse(v.begin(),v.end())
#define PI 3.14159265359
using namespace std;
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  int n,count,maxx,maxx2;
  IN1(n);

  vector<int>aarray(n);
  vector<int>acoparray(n);
  FOR(i,n){
    cin >> count;
    aarray.at(i) = count;
    acoparray[i] = count;
  }
  SORT(acoparray);
  REVS(acoparray);
  maxx = acoparray[0],maxx2 = acoparray[1];
  if (maxx == maxx2){
    FOR(i,n){
      OUT(maxx);
    }
  }
  else
  {
    FOR(i,n){
      if (aarray[i] == maxx){
        OUT(maxx2);
      }
      else
      {
        OUT(maxx);
      }
      
    }
  }
  

}

Measured memory_bytes: 3200
using System;
using System.Linq;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        string[] values = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
        Console.WriteLine(int.Parse(values[0])* int.Parse(values[1]));
    }


}

Measured memory_bytes: 27564
import bisect

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort()
B.sort()
C.sort()
ans=0

for b in B: #O(N)
    s = bisect.bisect_left(A,b) #O(logN)
    t = bisect.bisect_right(C,b) #O(logN)
    #print(s,N-t,s*(N-t))
    ans += s*(N-t)
   
print(ans)


Measured memory_bytes: 22516
import bisect as bi
a, b, q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
for i in range(q):
    c = []
    d = []
    x = int(input())
    tmp = bi.bisect_left(s, x)
    if tmp != a : c.append(s[tmp])
    if tmp != 0 : c.append(s[tmp-1])
    tmp = bi.bisect_left(t, x)
    if tmp != b : d.append(t[tmp])
    if tmp != 0 : d.append(t[tmp-1])
    ans = 2**64
    for e in c:
        for f in d:
            g = abs(x-e)
            h = abs(x-f)
            if (x-e)*(x-f) > 0:
                ans = min(ans, max(g, h))
            else:
                if g > h : g,h = h,g
                ans = min(ans, 2*g+h)
    print(ans)

Measured memory_bytes: 12080
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    ll tmp = min(a,k);
    a -= tmp;
    if(k-tmp > 0)   b = max(0ll, b-(k-tmp));
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int digs(int n, int k) {
	int d = 1;
  	while (n >= k) {
    	n = n / k;
      	d++;
    }
  	return d;
}

int main() {FIN
	
  int n, k;
    cin >> n >> k;
    cout << digs(n, k) << "\n";
	return 0;
}

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

int main(){
    ll x; cin >> x;
    ll y=x%11;
    ll ans=0;
    ans+=(x/11)*2;
    if(y>6){
        ans+=2;
    }else if(y>0){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int k;
    cin >> k;
    string s;
    cin >> s;
    string ans = "";
    if(s.size() <= k) cout << s << endl;
    else{
        for(int i=0;i<k;i++) ans += s[i];
        ans += "...";
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3644
N, M, X = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

r_count = 0
l_count = 0

tmp_1 = X
tmp_2 = X


while tmp_1 != N:
    tmp_1 += 1
    if tmp_1 in A:
        r_count += 1

while tmp_2 != 0:
    tmp_2 -= 1
    if tmp_2 in A:
        l_count += 1


res = min(l_count, r_count)
print(res)


Measured memory_bytes: 9060
#include<iostream>
#include<cstring>
using namespace std;
void dfs(char a[100][100], char ch, int x, int y);
int find(char a[100][100], char ch);
int sum; //总数
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int sx, sy;//初始位置
char farm[100][100]; //范围
int  judge[100][100];
int n, m;   //n*m
int main()
{
	while (1)
	{
		cin >> n >> m;
		if (n == 0 && m == 0)
			break;
		char a = '@';
		char b = '#';
		char c = '*';
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				cin >> farm[i][j];
		memset(judge, 0,sizeof(judge));
		sum = 0;
		sx = 0;
		sy = 0;
		while (find(farm,a)!=0)
		{
			/*cout << "**********************************************" << endl;
			cout << endl;
			cout << endl;*/
			sum++;
			dfs(farm, a, sx,sy);
			/*for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < m; j++)
					cout << farm[i][j];
				cout << endl;
			}
			cout << sum << endl;*/

			
		}
		while (find(farm, b) != 0)
		{
			sum++;
			dfs(farm, b,sx,sy);
		}
		while (find(farm, c) != 0)
		{
			sum++;
			dfs(farm, c,sx, sy);
		}
		cout << sum << endl;
	}
	return 0;
}
void dfs(char a[100][100], char ch, int x, int y)
{
	int nx = x;
	int ny = y;
	judge[nx][ny]=1;//此时的点已经是符合条件的点
	for (int t = 0; t < 4; t++)
	{
		if (a[nx + dx[t]][ny + dy[t]] == ch && nx + dx[t] >= 0 && nx + dx[t] < n&&ny + dy[t] >= 0 && ny + dy[t] < m&&judge[nx + dx[t]][ny + dy[t]] ==0)
		{
			//nx+=dx[t]
			//ny += dy[t];//此处值改变了 无法回溯，
			dfs(a, ch, nx + dx[t], ny + dy[t]);
		}
	}
}

int find(char a[100][100],char ch)   //找符号
{
	int flag = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (a[i][j] == ch&&judge[i][j]==0)     //得到 准确位置
			{
				flag = 1;
				sx = i;
				sy = j;
				break;
			}
		}
		if (flag == 1)
			break;
	}
	if (flag == 1)
		return 1;  //定位，改变x,y
	else
		return 0;  //余下矩阵没有特定符号
}


Measured memory_bytes: 3656
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,n,k,a[50],ans=0;
	cin>>n>>k;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for (i=0;i<k;i++){
		ans+=a[n-1-i];
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  map<string, int> s_map;
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> s[i];
    s_map[s[i]]++;
  }
  int m;
  cin >> m;
  vector<string> t(m);
  map<string, int> t_map;
  for (i = 0; i < m; i++) {
    cin >> t[i];
    t_map[t[i]]++;
  }
  vector<string> cp_s = s, cp_t = t;
  sort(cp_s.begin(), cp_s.end());
  sort(cp_t.begin(), cp_t.end());
  cp_s.erase(unique(cp_s.begin(), cp_s.end()), cp_s.end());
  cp_t.erase(unique(cp_t.begin(), cp_t.end()), cp_t.end());
  vector<string> list;
  for (i = 0; i < cp_s.size(); i++) {
    for (j = 0; j < cp_t.size(); j++) {
      if (cp_s[i] == cp_t[j]) {
        list.push_back(cp_s[i]);
        break;
      }
    }
  }
  sort(list.begin(), list.end());
  list.erase(unique(list.begin(), list.end()), list.end());
  for (i = 0; i < list.size(); i++) {
    s_map[list[i]] = max(s_map[list[i]] - t_map[list[i]], 0);
  }
  int result = 0;
  for (i = 0; i < cp_s.size(); i++) {
    result = max(result, s_map[cp_s[i]]);
  }
  cout << max(result, 0) << endl;
  return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  string a, b;
  cin >> a >> b;
  if (a.size() == b.size()) {
    if (a < b) {
      cout << "LESS" << '\n';
    } else if (a > b) {
      cout << "GREATER" << '\n';
    } else {
      cout << "EQUAL" << '\n';
    }
  } else {
    int s1 = a.size(), s2 = b.size();
    if (s1 < s2) {
      cout << "LESS" << '\n';
    } else if (s1 > s2) {
      cout << "GREATER" << '\n';
    } else {
      cout << "EQUAL" << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 3632