akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

class Main
{
    static class Len
    {	
	int[] a;
	int[] b;
	
	Len(int n)
	{
	    a = new int[n+1];
	    b = new int[n+1];
	}
	

    }

    public static void main(String args[])
    {
	int n;
	int i, j, k;

	String line = new String();
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));

	//Read ----------------
	//Read n
	try{
	    line=line=bin.readLine();
	}	
	catch(IOException e){
	    System.out.println("Error");
	}

	n=Integer.parseInt(line);
	Len len = new Len(n);
	j=0;
	//Read A[]
	try{
	    line=bin.readLine();
	    //System.out.println(line);
	    StringTokenizer str = new StringTokenizer(line);   
	    for(i=0; i<n; i++)
		{
		    len.a[i]=Integer.parseInt(str.nextToken());
		    if(j<len.a[i])j=len.a[i];
		}
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	//bin=null;

	//Read end------------


	//sort
	countingSort(len, j, n);

	//print
	StringBuffer s = new StringBuffer(80000);
	for(i=1; i<=n; i++)
	    {
		s.append(len.b[i]);
		if(i!=n)s.append(" ");
	    }
	System.out.println(s);

    }

    static void countingSort(Len len, int max, int n)
    {
	int i, j, k;
	int[] c = new int[max+1];

	for(i=0; i<n; i++)c[len.a[i]]++;

	for(i=0; i<=max; i++)
	    {
		if(i!=0)c[i]+=c[i-1];
	    }

	for(i=n-1; i>=0; i--)
	    {
		len.b[c[len.a[i]]]=len.a[i];
		c[len.a[i]]--;
	    }
    }
}

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

struct Card {
  char suit, value;
};

void bubbleSort(Card A[], int N) {
  bool flag = true;
  for (int i = 0; flag; i++) {
    flag = false;
    for (int j = N-1; j >= i+1; j--) {
      if (A[j].value < A[j-1].value) {
        swap(A[j].value, A[j-1].value);
        swap(A[j].suit, A[j-1].suit);
        flag = true;
      }
    }
  }
}

void selectionSort(Card A[], int N) {
  for (int i = 0; i < N; i++) {
    int min_j = i;
    for (int j = i; j < N; j++) {
      if (A[j].value < A[min_j].value) {
        min_j = j;
      }
    }
    if (i != min_j) {
      swap(A[i].value, A[min_j].value);
      swap(A[i].suit, A[min_j].suit);
    }
  }
}

bool isStable(Card in[], Card out[], int N) {
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int a = 0; a < N; a++) {
        for (int b = a+1; b < N; b++) {
          if (in[i].value == in[j].value &&
              out[a].value == out[b].value &&
              in[i].value == out[a].value &&
              in[i].suit == out[b].suit &&
              in[j].suit == out[a].suit) {
            return false;}
        }
      }
    }
  }
  return true;
}

int main() {
  Card in[100], out[100];
  int N, sw;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> in[i].suit >> in[i].value;
    out[i] = in[i];
  }
  bubbleSort(out, N);
  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << out[i].suit << out[i].value;
  }
  cout << endl;
  if(isStable(in, out, N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  for (int i = 0; i < N; i++) {
    out[i] = in[i];
  }
  selectionSort(out, N);
  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << out[i].suit << out[i].value;
  }
  cout << endl;
  if(isStable(in, out, N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N;
  cin >> N;
  int a[N]={},ans=1;
  rep(i,N) cin >> a[i];
  int maxi=a[0];
  for(int i=0;i<N-1;i++){
    chmax(maxi,a[i]);
    if(maxi<=a[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ar array
#define db long double
#define pow pw
const db pi = 3.14159265358979323846;
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
const int mxn=1e5+7;
int n,S;
int h[mxn],w[mxn];
int dp[mxn];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>S;
    for (int i=0;i<n;i++) cin>>w[i]>>h[i];
    for (int i=0;i<n;i++)
    for (int j=S;j>=0;j--)
    {
        if (j<w[i]) break;
        dp[j]=max(dp[j],dp[j-w[i]]+h[i]);
    }
    cout<<dp[S];
    return 0;
}

Measured memory_bytes: 4372
m=10**9+7
def power(a,b):
    res=1
    while(b>0):
        if(b&1):
            res=(res*a)%m
        b//=2
        a=(a*a)%m
    return res
n=int(input())
s=(power(10,n)+power(8,n))%(10**9+7)
s=(s-(2*power(9,n)))%(10**9+7)
print((s))


Measured memory_bytes: 61884
fun main(args: Array<String>) {
    abc064d()
}

fun abc064d() {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    val answer = StringBuilder(s)
    var unpairedLeft = 0
    s.map { it == '(' }.forEach { isLeft ->
        if (isLeft) {
            unpairedLeft++
        } else {
            if (unpairedLeft > 0) {
                unpairedLeft--
            } else {
                answer.insert(0, '(')
            }
        }
    }

    answer.append(")".repeat(unpairedLeft))

    println(answer)
}


Measured memory_bytes: 31748
import collections
l=[]
for i in range(3):
    a,b=map(int,input().split())
    l.append(a)
    l.append(b)
c=collections.Counter(l)
n=[]
for i in range(1,5):
    n.append(c[i])
n.sort()
if n==[1,1,2,2]:
    print('YES')
else:
    print('NO')

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

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define deb(x)     cout << #x << " = "<<x<<endl

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)

int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;


ll gcd(ll  a , ll b) {
	return (b == 0) ? a : gcd(b, a % b);
}
ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}
ll powmod(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinv(ll n, ll p)
{
	return powmod(n, MOD - 2, MOD);
}
void max_self(ll &a, ll b) {
	a = max(a, b);
}
bool is_ap(vl v, int n) {
	ll d = v[1] - v[0];
	F0R(i, n) {
		if (v[i] != v[0] + i * d)
			return false;
	}
	return true;
}


int main(int argc, char const *argv[])
{
	// two magical lines to speed up IO
	cin.tie(0);
	ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int  k , n;
	cin >> k >> n;
	// vi al, ar;
	// int ln, rn;
	// int hlf = k / 2;
	// F0R(i, n) {
	// 	int x;
	// 	cin >> x;
	// 	if (x <= hlf) {
	// 		ar.pb(x);
	// 	}
	// 	else if (x > hlf) {
	// 		al.pb(k - x);

	// 	}


	// }
	// sort(all(al));
	// sort(all(ar));
	// ln = al.size();
	// rn = ar.size();
	// int ans;
	// if (ln > 0 && rn > 0) {
	// 	ans = min(k - al[0] - ar[0], al[ln - 1] + ar[rn - 1]);
	// }
	// else if (ln == 0) {
	// 	ans = ar[rn - 1] - ar[0];
	// }
	// else if (rn == 0) {
	// 	ans = al[rn - 1] - al[0];
	// }

	// cout << ans << endl;
	int a[n];
	int mx = 0;
	F0R(i, n) {
		cin >> a[i];

	}
	sort(a, a + n);
	F0R(i, n) {
		if (i > 0) {
			mx = max(a[i] - a[i - 1], mx);
		}
		mx = max(k - a[n - 1] + a[0], mx);
	}
	cout << (k - mx) << endl;



}




Measured memory_bytes: 4424
N, K = list(map(int, input().split()))
cnt = {}
for i in range(1, N+1):
    cnt[i] = 0
for _ in range(K):
    d = int(input())
    arr = list(map(int, input().split()))
    for a in arr:
        cnt[a] += 1
ans = 0
for k in cnt:
    if cnt[k] == 0:
        ans+=1
print(ans)

Measured memory_bytes: 67632
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double ans;
  double pi = 3.141592653589793238;
  double angle;
  double angle_h, angle_m;

  angle_m =  m/60;
  angle_h =  (h/12 + m/720);


  // cout << angle_h << endl;
  // cout << angle_m << endl;


  angle = abs(angle_m-angle_h) * 360;
  // cout << angle << endl;
  // cout << cos(90/180*pi) << endl;

  double tmp = a*a + b*b - 2*a*b * cos(angle / 180 * pi);

  ans = sqrt(tmp);
  printf("%.12lf\n", ans);


  return 0;

}


Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace::std;
int main(){
  int n,x;
  cin>>n>>x;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<n;i++)x-=v[i];
  cout<<x/(*min_element(v.begin(),v.end()))+n;
}


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

int main() {

  int A,B,K;
  cin >> A >> B >> K; 

  int i;
  int count = K;
  int ans;
  for(i=100;i>0;i--){
    if(A%i == 0 && B%i == 0){
       count -= 1;
       if(count==0){
         ans = i;
         break;
       }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define INF 2147483647
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
	
	int n;
	vector<int> a,b,c;
	cin>>n;
	int x;
	for(int i=0;i<n;i++){
		cin>>x;
		a.push_back(x);
	}
	for(int i=0;i<n;i++){
		cin>>x;
		b.push_back(x);
	}
	for(int i=0;i<n;i++){
		cin>>x;
		c.push_back(x);
	}
	sort(a.begin(),a.end());
	//sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll ans=0;
	for(auto v:b){
		auto itra=lower_bound(a.begin(),a.end(),v);
		auto itrc=upper_bound(c.begin(),c.end(),v);
		ans+=(itra-a.begin())*(c.end()-itrc);
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
ll n,m;
int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	vector<int>v[n+1];
	vector<pii>a;
	ll value[n+1];
	rep(i,1,n+1)
	{
		ll x;
		cin>>x;
		value[i]=x;
		a.pb({x,i});
	}
	sort(a.rbegin(),a.rend());
	rep(i,0,m)
	{
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	bool vis[n+1];
	memset(vis,false,sizeof(vis));
	ll ans=0;
	for(int i=0;i<a.size();i++)
	{
		if(!vis[a[i].ss])
		{
			ll val=a[i].ff,c=1;
			vis[a[i].ss]=1;
//			tell(a[i].ss);
			for(int j=0;j<v[a[i].ss].size();j++)
			{
//				tell(v[a[i].ss][j]);
				if(val<=value[v[a[i].ss][j]])
				{
					c=0;
				}
				else
				vis[v[a[i].ss][j]]=true;
			}
//			el;
			if(c)
			ans++;
		}
	}
	cout<<ans;
}



Measured memory_bytes: 10796
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
#define LL long long
int main()
{
    int i,j,k;
    LL n,m,d,r;
    double t;
    scanf("%lld%lld%lld",&n,&m,&d);
    if(d==0)
        t=(m-1)*1.0/n;
    else
        t=((m-1)*1.0/n)*((n-d)*2.0/n);
    printf("%.10lf\n",t);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		for(int i=111; i<=999; i+=111){
			if(n<=i){
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		//入力
		long X = scanner.nextLong();
		long Y = scanner.nextLong();
		long answer = -1;

		if(X < Y){
			answer = X;
		}else if( X % Y != 0){
			long temp;
				temp = X; 
            long  i = temp / X;
			long r = 1000000000000000000L;
			while(temp <= r){
				if(temp % Y != 0){
					answer = temp;
					break;
				}
				temp = X * i;
				i++;
			}
		}

		System.out.println(answer);
		scanner.close();
	}
}

Measured memory_bytes: 22612
s=input()
c,d,e,f=0,0,0,0
for i in s:
    if i=="<":
        if e==0:
            c+=1
        else:
            e=0
            c,d=max(c,d),min(c,d)
            f+=(c*(c+1))//2+(d*(d-1))//2
            c,d=1,0
    else:
        e=1
        d+=1
c,d=max(c,d),min(c,d)
print(f+(c*(c+1))//2+(d*(d-1))//2)

Measured memory_bytes: 4116
#include <iostream>
#include <stdio.h>
using namespace std;
long long a[100005];
int main(){
    int n,ans=1,m=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n;i++){
        if(a[i]!=a[i-1]) a[m++] = a[i];
    }
    for(int i = 3;i<m;i++){
        if((a[i]-a[i-1]) * (a[i-1]-a[i-2])<0){   
            ans ++;
            i ++;
        }
        
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn=200005;
int n,a[maxn],b[maxn];
int main()
{
	scanf("%d",&n);
	for (int i=1,x,y;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		a[i]=x+y;
		b[i]=x-y;
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	printf("%d\n",max(a[n]-a[1],b[n]-b[1]));
	return 0;
}


Measured memory_bytes: 5320
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line2, int.Parse);
        Array.Sort(a);
        var dp = new int[n + a[a.Length-1]  +1];
        for (int i = 0; i < dp.Length; i++) dp[i] = 99999999;
        for (int i = 0; i < m; i++) dp[a[i]] = 1;
        for (int i = 1; i < n; i++)
        {
            if (dp[i] != 99999999)
                for (int j = 0; j < m; j++)
                    dp[i + a[j]] = Math.Min(dp[i + a[j]], dp[i] + 1);
        }
        Console.WriteLine(dp[n]);
    }
}

Measured memory_bytes: 9604
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (a, b) = input!(i32, i32);

    println!("{}", std::cmp::max(a - 2 * b, 0));
}

fn main() {
    solve();
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	int N;
	ll x;
	cin >> N >> x;
	ll a[100];
	for(int i=0;i<N;i++) cin >> a[i];

	sort(a,a+N);
	int ans = 0;
	for(int i=0;i<N;i++){
		if(x >= a[i]){
			ans++;
			x -= a[i];
		}
	}
	if(x>0 && ans==N) ans--;
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  double ave = (double)accumulate(all(A), 0)/n;
  double mn = inf;
  int ans = 0;
  rep(i, n) {
    if(abs(A[i]-ave) < mn) {
      ans = i;
      mn = abs(A[i]-ave);
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3624
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = INT()
print(N * N - A)

Measured memory_bytes: 27284
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a[] = new int[n];Arrays.fill(a,-1);
		boolean f = false;
		for(int i=0;i<m;i++){
			int s = sc.nextInt()-1;
			int c = sc.nextInt();
			if(a[s]==-1||a[s]==c){
				a[s]=c;
			}else{
				f=true;
			}
		}


		if(m==0){
			if(n==1){
				a[0]=0;
			}else{
				a[0]=1;
			}
		}

		if(a[0]==0&&n>1)f=true;

		if(a[0]==-1){
			if(n>1){
				a[0]=1;
			}else{
				a[0]=0;
			}
		}


		if(!f){
			for(int i:a){
				int an = i == -1 ? 0 : i;
				System.out.print(an);
			}
			System.out.println();
		}else{
			System.out.println(-1);
		}
	}
}


Measured memory_bytes: 23764
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

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

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	while(true){
		bool flag =true;
		map<int,int> data;
		data.clear();
		bool draw =false;
		bool goo,tyoki,pa;
		goo=tyoki=pa=false;
		int a[5]={0};
		for(int i =0;i <5;i++){
			int x;
			cin>>x;
			if(x==0){
				flag =false;
				break;
			}
			data[x]++;
			a[i]=x;
		}
		if((data[1]&&data[2]&&data[3])||(data[1]&&data[2]==0&&data[3]==0)||(
		   data[1]==0&&data[2]&&data[3]==0)||(data[1]==0&&data[2]==0&&data[3])){
			draw =true;
		}else if((data[1]&&data[2]&&data[3]==0)){
			goo =true;
		}else if((data[1]==0&&data[2]&&data[3])){
			tyoki =true;
		}else if((data[1]&&data[2]==0&&data[3])){
			pa =true;
		}
		if(draw){
			for(int i =0;i <5;i++){
				cout <<3<<endl;
			}
			continue;
		}else if(goo){
			for(int i =0;i <5;i++){
				if(a[i]==1){
					cout <<1<<endl;
				}else{
					cout <<2<<endl;
				}
			}
		}else if(tyoki){
			for(int i =0;i <5;i++){
				if(a[i]==2){
					cout <<1<<endl;
				}else{
					cout <<2<<endl;
				}
			}
		}else if(pa){
			for(int i =0;i <5;i++){
				if(a[i]==3){
					cout <<1<<endl;
				}else{
					cout <<2<<endl;
				}
			}
		}
		if(!flag)break;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin>>p[i];
  }
  int ans=0;
  vector<int> tmp;
  for(int i=2; i<p.size(); i++){
    tmp.push_back(p[i]);
    tmp.push_back(p[i-1]);
    tmp.push_back(p[i-2]);
    sort(tmp.begin(),tmp.end());
    if(tmp[1]==p[i-1]) ans++;
    tmp.clear();
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
from collections import Counter
def main():
    N, X, Y = map(int, input().split())
    graph = {}
    for i in range(N):
        graph[i] = set()
    for i in range(N-1):
        graph[i].add(i+1)
        graph[i+1].add(i)
    graph[X-1].add(Y-1)
    graph[Y-1].add(X-1)

    ans = []
    for i in range(N):
        dist = [-1] * N
        dist[i] = 0
        que = deque([])
        que.append(i)
        while len(que) != 0:
            v = que.popleft()
            for nv in graph[v]:
                if dist[nv] != -1:continue
                dist[nv] = dist[v] + 1
                que.append(nv)
        ans += dist
    ans = Counter(ans)
    for i in range(1, N):
        print(ans[i]//2)
if __name__ == "__main__":
    main()

Measured memory_bytes: 126760
#include <iostream>
using namespace std;
int main() {
    int h,w;
    string String[30][30];
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
               cin >> String[i][j];
        }
    }

    for (int k = 0; k < h; ++k) {
        for (int a = 0; a <w ; ++a) {
            if (String[k][a] == "snuke"){
                cout << (char)('A'+a)<< k+1 << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        v[i] = x;
    }
    ll s1 = 0;
    for (int i = 0; i < n; i++) {
        if (i & 1) {
            s1 += -v[i];
        }
        else {
            s1 += v[i];
        }
    }

    for (int i = 0; i < n; i++) {
        if (i == 0) {
            cout << s1 << " ";
        }
        else {
            s1 -= v[i - 1];
            s1 = v[i - 1] - s1;
            cout << s1 << " ";
        }
    }
}

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

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T> T iabs(const T& x) { return max(x, -x); }

int main() {
    i64 q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    h = min(h, 2 * q);
    s = min(s, 2 * h);
    d = min(d, 2 * s);
    i64 ans = d * (n / 2) + s * (n % 2);
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll ans = 1;
    rep(i,n-1){
        if(a[i]<a[i+1]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
d = {}
n = int(input())
c = 0
for _ in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
    c = max(c, d[s])
lis = sorted(d.items(), key=lambda x: x[1], reverse=True)
ans = []
for a in lis:
    if a[1] == c:
        ans.append(a[0])
ans = sorted(ans)
for v in ans:
    print(v)



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t a,b,x;
	cin>>a>>b>>x;
	if(a==b){
		if(a%x==0)cout<<1<<"\n"s;
		else cout<<0<<"\n"s;
	}else{
		if(a%x==0)cout<<b/x-a/x+1<<"\n"s;
		else cout<<b/x-a/x<<"\n"s;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1e9+9;
const int INF = 1e9;


bool seen[100010];
vvi G(100010);
void dfs(int v){
    seen[v] = true;
    for (auto nv : G[v]){
        if (seen[nv]) continue;
        dfs(nv);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    memset(seen, 0, sizeof(seen));
    int cnt = 0;
    rep(i,n){
        if (seen[i]) continue;
        dfs(i);
        cnt++;
    }
    int ans = cnt - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9244
#include<bits/stdc++.h>
using namespace std;//万能库
int main()
{
    int n,t;
    cin>>n;
    while(n>0){
    	t=n%10;
		if(t==9){
			cout<<"Yes"<<endl;
			return 0;
		} 
		n/=10;
	} 
	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  ll n; cin >> n; ll sum = 0; ll na = n;
  while(n != 0){
    sum += n % 10; n /= 10;
  }
  
  if(na % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
n_list1 = list(map(int, input().split()))

n_list2 = list(n_list1)
n_list_test = list(n_list1)


n_list_max = np.max(n_list1)
n_list_min = np.min(n_list2)

n_list1.remove(n_list_max)
n_list2.remove(n_list_min)

# print(np.max(n_list))
# np.median(n_list - )
n_list1_median = int(np.median(n_list1))
n_list2_median = int(np.median(n_list2))

for x in n_list_test:
  if n_list1_median >= x:
    print(n_list2_median)
  else:
    print(n_list1_median)
 
    



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using DoP = pair<double, double>;
using edge = struct { int to; double cost;}; // edge x = {to, cost}

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1<<29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  a.insert(a.begin(), 0);
  vector<ll> b(n+1);
  for(int i = 1; i <= n; ++i) {
    b[i] = i-a[i];
  }
  map<ll, vector<int>> m;
  for(int i = 1; i <= n; ++i) {
    ll c = a[i]+i;
    m[c].push_back(i);
  }
  ll ans = 0;


  for(int i = n; i >= 1; --i) {
    //cout << "i is " << i  << "b is " << b[i] << endl;
    auto it = lower_bound(ALL(m[b[i]]), i);
    if(it == m[b[i]].begin()) continue;
    ans += distance(m[b[i]].begin(), it);
  }
  cout << ans << endl;
}

Measured memory_bytes: 40604
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

 */

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005


signed main(){
	fast
	int a, b;
	float t;
	cin>>a>>b>>t;
	t+=0.5;
	int n= t/a;
	int ans = b*n;
	cout<<ans<<endl;
    return 0;
}
    



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

int main () {
  long long A,B,C;
  cin >> A >> B >> C;
  long long cnt = 0;
  
  if (A%2==1 || B%2==1 || C%2==1) {   
    cout << 0 << endl;
    return 0;
  }
  
  if (A==B && B==C) {
    cout << -1 << endl;
    return 0;
  }
  
  while (true) {
    if (A%2==0 && B%2==0 && C%2==0) {   
      cnt++;
      long long a = B/2 + C/2;
      long long b = A/2 + C/2;
      long long c = A/2 + B/2;
      A = a;
      B = b;
      C = c;
    }
    else {
      cout << cnt << endl;
      break;
    }
  }
  
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int n, m;
int g[8][8];

int main() {
    std::ios::sync_with_stdio(false);
    cin >> n >> m;
    memset(g, 0, sizeof(g));
    for(int i=0;i<m;i++){
        int a, b;cin >> a >> b;a--;b--;
        g[a][b] = g[b][a] = 1;
    }
    vector<int> v;
    for(int i=0;i<n;i++) v.push_back(i);

    int ans = 0;
    do{
        if(v[0] != 0) continue;
        ans++;
        for(int i=0;i<n-1;i++){
            if(!g[v[i]][v[i+1]]){
                ans--;
                break;
            }
        }
    }while(next_permutation(v.begin(), v.end()));

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

//10^9 + 7
const ll MOD = 1000000007;

int main() {
	ll N;
	cin >> N;

	int x[100];
	rep(i, N) {
		cin >> x[i];
	}

	ll minDistance, sum;
	minDistance = 10000000000007;
	rep(i, 100) {
		sum = 0;
		rep(j, N) {
			sum += (x[j] - (i + 1)) * (x[j] - (i + 1));
		}
		minDistance = min(minDistance, sum);
	}


	cout << minDistance << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int h, w, i;
    scanf("%d%d", &h, &w);

    char a[101][101];

    for(i=0; i<h; i++){
        scanf("%s", a[i]);
    }
    for(i=0; i<w+2; i++)
        putchar('#');
    putchar('\n');

    for(i=0; i<h; i++)
        printf("#%s#\n", a[i]);

    for(i=0; i<w+2; i++)
        putchar('#');
    putchar('\n');
    return 0;
}


Measured memory_bytes: 128
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("in.txt", "r", stdin); 
    freopen("out.txt", "w", stdout); 
#endif 
}

int N,W;
int w[100],v[100];
int memo[100][100001];


int solve(int i, int x){
	if(i==N && x==0) return 0;
	if(i==N || x<0) return INF;
	if(memo[i][x]!=-1) return memo[i][x]; 
	return memo[i][x]=min(solve(i+1,x-v[i])+w[i],solve(i+1,x));
}

int32_t main(){
   boost;
   IO();
   memset(memo,-1,sizeof(memo));
   cin>>N>>W;
   for(int i=0; i<N; i++) cin>>w[i]>>v[i];
   for(int i=100000; i>=1; i--) if(solve(0,i)<=W){
   	cout << i << endl;
   	return 0;
   }

   return 0;
}



Measured memory_bytes: 81732
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define NDEBUG
#include <assert.h>
using namespace std;
const int INF=INT_MAX/4;
/*
Status:Writing
Type:Problemset/HB
Problem ID:Atcoder ARC B
Author:XIZCM
*/
int n;
vector<int> nei[100005];
int dis[100005],rdis[100005];
void bfs(int start,int d[]){
	fill(d,d+100005,INF);
	d[start]=0;
	queue<int> q;
	q.push(start);
	while(!q.empty()){
		int t=q.front();
		q.pop();
		for(int i=0;i<nei[t].size();i++){
			int u=nei[t][i];
			if(d[u]>d[t]+1){
				d[u]=d[t]+1;
				q.push(u);
			}
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	bfs(0,dis);
	bfs(n-1,rdis);
	int s=0,f=0;
	for(int i=0;i<n;i++){
		if(dis[i]>rdis[i]){
			s++;
		}
		else{
			f++;
		}
	}
	puts(f>s?"Fennec":"Snuke");
	return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
     cin>>n;

      long int arr[n];
      for(int i=0;i<n;i++)
        cin>>arr[i];

    int count=0,max=0;
      for(int i=0;i<n-1;i++)
      {
            if(arr[i] >= arr[i+1])
             count++;

            else
            {
               if(max < count)
               max=count;
               count=0;
            }
      }
        if(max < count)
         max=count;
      cout<<max;
}


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

using namespace std;

int main(){
	short b;cin>>b;
	
	short k;cin>>k;
	
	string a;cin>>a;
	if(a.at(k-1) == 'A'){
		a.at(k-1) = 'a';
	}
	if(a.at(k-1) == 'B'){
		a.at(k-1) = 'b';
	}
	if(a.at(k-1) == 'C'){
		a.at(k-1) = 'c';
	}
	
	cout<<a;
	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 PI 3.14159265
typedef long long ll;

int main( void ) {

    string s, p;
    cin >> s >> p;

    s += s;

    int ans = s.find( p );
    puts( ans != string::npos ? "Yes" : "No" );

    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
int n,m,i,j,t,qx[100005],ql,qr,len[100005];
double dp[100005],p[100005]; 
int main()
{
	while (scanf("%d",&n)&&n)
	{
		m=0;
		fz1(i,n)
		{
			scanf("%lf",&p[++m]);len[m]=1;
			if (m>1&&p[m]>0.995&&p[m-1]>0.995){
				m--;len[m]++;
			}
		}
		fz1(i,m)
		{
			double pro=1,tim=0;
			dp[i]=1e18;
			for (j=i;j>=i-100&&j>=0;j--){
				dp[i]=min(dp[i],dp[j]+tim+1);
				pro/=p[j];
				tim+=pro*len[j];
			}
		}
		printf("%.23lf\n",dp[m]-1);
	}
	return 0;
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>  // ver2.1.4
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

int mypow(int x, int n, int m){  //  高速累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  
  int n,m,memo;
  cin >> n;
  double ans;
  if(n==1) ans = 1.0;
  else if(n%2==0) ans = 0.5;
  else ans = ((n/2)+1.0)/n;
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
"""
Cを2k枚買う
"""

ans = 10 ** 10
k = 0
while True:
    money = C * k
    money += A * max(0, X - k // 2) + B * max(0, Y - k // 2)
    # print(max(0, X - k // 2), max(0, Y - k // 2), k, money)
    ans = min(ans, money)
    if k // 2 >= max(X, Y):
        break
    k += 2
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, X, T;
  cin>>N>>X>>T;
  if(N%X==0) cout<<N/X*T<<endl;
  else cout<<(N/X+1)*T<<endl;
}



Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long[] A;


        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            A = new long[N];
            for (int i = 0; i < A.length; i++) {
                A[i] = sc.nextLong();
            }
        }
        double AD = 0;
        for (int i = 0; i < A.length; i++) {
            AD += (double)1/(double)A[i];
        }
        System.out.println((double)1/AD);

    }

}


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

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

    int ans = 0;

    vector<int> num;
    int count = 0;
    for (int i = 0; i < N - 1; i++){
        if(H[i] >= H[i+1]){
            count ++;
        } 
        else{
            num.push_back(count);
            count = 0;
        }
    }
    num.push_back(count);

    sort(num.begin(), num.end(), greater<int>());
        
    cout << num.at(0) << endl;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;
vector<string> ret;
int main() {
    ll n, m, i, j, k;
    ll x;
    cin >> n;
    vector<ll> L(n);
    for(auto &x:L){
        cin >> x;
    }
    sort(L.begin(),L.end());
    ll cnt=0;
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            int ok = j,ng=n;
            while(abs(ok-ng)>1){
                int mid = (ok+ng)/2;
                if(L[i]+L[j]>L[mid]){
                    ok = mid;
                }else {
                    ng = mid;
                }
            }
            cnt += ok-j;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
A = list(input())
B = list(input())
C = list(input())

turn = A[0]

while True:
    if turn == 'a':
        if len(A) == 0:
            print('A')
            exit()
        turn = A[0]
        A.pop(0)

    if turn == 'b':
        if len(B) == 0:
            print('B')
            exit()
        turn = B[0]
        B.pop(0)

    if turn == 'c':
        if len(C) == 0:
            print('C')
            exit()
        turn = C[0]
        C.pop(0)

Measured memory_bytes: 3064
import java.util.*

val MAX_N = 100002
var par = Array(MAX_N){0}
var rank = Array(MAX_N){0}

fun init() {
    for (i in 0 until MAX_N) {
        par[i] = i
        rank[i] = 0
    }
}

fun find(a: Int): Int{
    if (par[a] == a){
        return a
    } else {
        par[a] = find(par[a])
        return par[a]
    }
}

fun unite(a: Int, b: Int) {
    val ta = find(a)
    val tb = find(b)
    if(ta == tb) return

    if(rank[ta] < rank[tb]){
        par[ta] = tb
    }else{
        par[tb] = ta
        if(rank[ta] == rank[tb]) rank[ta]++
    }
}

fun same(a: Int, b: Int): Boolean {
    return find(a) == find(b)
}

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val M = sc.nextInt()
    val rem = (1..N).toMutableSet()

    init()

    repeat(M) {
        val x = sc.nextInt()
        val y = sc.nextInt()
        val z = sc.nextInt()
        unite(x, y)
        rem.remove(x)
        rem.remove(y)
    }

    val set = mutableSetOf<Int>()
    for (i in 1..N) {
        set.add(find(i))
    }
    println(set.size)
}

Measured memory_bytes: 74116
N=int(input())
F=[list(map(int,input().split())) for _ in range(N)] #0-9
P=[list(map(int,input().split())) for _ in range(N)] #0-10

INF=10**9
ans=-INF

for i in range(1,2**10):
    tmpans=0
    for n in range(N):
        c=0
        for j in range(10):
            if (i>>j&1)&F[n][j]:
                c+=1
        tmpans+=P[n][c]

    ans=max(ans,tmpans)

print(ans)

Measured memory_bytes: 3064
#D

def main():
  N, X, Y = map(int, input().split())

  cnt = {i:0 for i in range(1,N)}

  for s in range(1, N+1):
    for e in range(s+1, N+1):
      if s<X and e<X:
        d = e-s
      elif s<X and X<=e<Y:
        d = min(e-s, (X-s)+1+(Y-e))
      elif s<X and Y<=e:
        d = (X-s)+1+(e-Y)
      elif X<=s<Y and X<=e<Y:
        d = min(e-s, (s-X)+1+(Y-e))
      elif X<=s<Y and Y<=e:
        d = min(e-s, (s-X)+1+(e-Y))
      else:
        d = e-s

      cnt[d]+=1

  for c in cnt.values():
    print(c)
main()

Measured memory_bytes: 3572