akhauriyash/Code-Regression huggingface dataset:
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: i32 = it.next().unwrap().parse().unwrap();
    let r: i32 = it.next().unwrap().parse().unwrap();
    let ans = r + 100 * std::cmp::max(10 - n, 0);
    println!("{}", ans);
}

fn main() {
    run();
}

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

int main(){
	while(1){
		int maxnum = -1, maxidx = 0;
		int s1, s2;
		cin >> s1 >> s2;
		if(s1 == 0 && s2 == 0) break;
		maxnum = s1 + s2;
		for(int i = 1;i <= 4;i++){
			cin >> s1 >> s2;
			if(s1 + s2 > maxnum){
				maxnum = s1 + s2;
				maxidx = i;
			}
		}
		cout << "ABCDE"[maxidx] << ' ' << maxnum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define max 1000
#define inf 100000
#define w 0
#define g 1
#define b 2
int vertex_num,admat[max][max];
/*
int Prims(){
  int i,j,u,v,cost[max][max],min_distance;
  int visit[max],no_edges,min_cost,distance[max],from[max];
  
  for(i=0;i<vertex_num;i++){
    for(j=0;j<vertex_num;j++){
      if(admat[i][j]==0){
          cost[i][j]=inf;
      }else{
	cost[i][j]=admat[i][j];
	}
    }
  }
  
  distance[0]=0;
  visit[0]=1;

  for(i=1;i<vertex_num;i++){
      distance[i]=cost[0][i];
      from[i]=0;
      visit[i]=0;
  }
  min_cost=0;
  no_edges=vertex_num-1;

  while(no_edges>0){
     min_distance=inf;
     for(i=1;i<vertex_num;i++){
         if(visit[i]==0 && distance[i]<min_distance){
             v=i;
             min_distance=distance[i];
         }
     }
     u=from[v];
     no_edges--;
     visit[v]=1;
     for(i=1;i<vertex_num;i++){
         if(visit[i]==0 && cost[i][v]<distance[i]){
             distance[i]=cost[i][v];
             from[i]=v;
         }
     }
     min_cost+=cost[u][v];
  }
  
  return min_cost;
}
*/

int Prim(){
  int vertex,min_vertex;
  int distance[max],parent[max],color[max],cost;
  int i,j;
  for(i=0;i<vertex_num;i++){
    distance[i]=inf;
    parent[i]=-1;
    color[i]=w;
  }
  distance[0]=0;
  while(1){
    min_vertex=inf;
    vertex=-1;
    for(i=0;i<vertex_num;i++){
      if(min_vertex>distance[i] && color[i]!=b){
	vertex=i;
	min_vertex=distance[i];
      }
    }
    if(vertex==-1)break;
    color[vertex]=b;
    for(i=0;i<vertex_num;i++){
      if(color[i]!=b && admat[vertex][i]!=inf){
	if(distance[i]>admat[vertex][i]){
	  distance[i]=admat[vertex][i];
          parent[i]=vertex;
	  color[i]=g;
	}
      }
    }
  }
  cost=0;
  for(i=0;i<vertex_num;i++){
    if(parent[i]!=-1){
      cost+=admat[i][parent[i]];
    }
  }
  return cost;
}




int main(){
  //admatは隣接行列
  int i,j,num;

  scanf("%d",&vertex_num);
  for(i=0;i<vertex_num;i++){
    for(j=0;j<vertex_num;j++){
      scanf("%d",&num);
      if(num==-1){
	admat[i][j]=inf;
      }else{
	admat[i][j]=num;
      }
  }
  /*
  for(i=0;i<vertex_num;i++){
    for(j=0;j<vertex_num;j++){
       if(admat[i][j]==-1){
           admat[i][j]=0;
       }
       //printf("%d ",admat[i][j]);
    }
*/
  }
  
  printf("%d\n",Prim());
  return 0;
}

/**/



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

int main(){
int p , q , r;
cin>>p>>q>>r;
int sum=p+q+r;
int max=p;
//max を求める
if(q>max){
	max=q;
}
	if(r>max){
	max=r;
}
cout<<sum-max<<endl;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = [0] + list(map(int, input().split()))

ans = 0

for i in range(n):
    if a[i] + a[i + 1] > x:
        t=a[i] + a[i + 1] - x
        a[i + 1] -= t
        ans += t

print(ans)

Measured memory_bytes: 14540
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m;
    cin>>n>>m;
    if(n>m)
    {
        cout<<n-1<<NL;
        return 0;
    }
    cout<<n<<NL;
    return 0;
}



Measured memory_bytes: 256
/*
    Author : DemonStar
*/

//#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pi pair<int, int>
#define pl pair<long long, long long>
#define pld pair<long double, long double>
#define endl '\n'
#define loop(i, n) for (ll i = 0; i < n; i++)
#define rep(i, begin, end) for (__typeof(begin) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(x) x.begin(), x.end()
#define vl vector<ll>
#define vi vector<int>
#define ml map<ll, ll>
#define vpl vector<pair<ll, ll>>
const ll mod = 1e9 + 7;

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t)
{
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t)
{
    for (auto &i : t)
        os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &t : v)
        is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v)
{
    for (pair<T1, T2> &t : v)
        is >> t.first >> t.second;
    return is;
}

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    cin >> s;
    vector<vl> dp(h, vl(w, 0));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (!i and !j)
                dp[i][j] = (s[i][j] == '.');
            else if (!i)
                dp[i][j] = (s[i][j] == '.') * dp[i][j - 1];
            else if (!j)
                dp[i][j] = (s[i][j] == '.') * dp[i - 1][j];
            else if (s[i][j] == '.')
                (dp[i][j] += dp[i - 1][j] + dp[i][j - 1]) %= mod;
        }
    }
    cout << dp[h - 1][w - 1] << endl;
#ifdef LOCAL
    cerr
        << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}

Measured memory_bytes: 9216
n, m, x, y = [int(elem) for elem in input().split()]
xs = [int(elem) for elem in input().split()]
ys = [int(elem) for elem in input().split()]

max_x = max(xs)
min_y = min(ys)
if max_x < min_y and min_y <= y and x < min_y:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3060
import math


def solve(N, K, As):
    ans = 1
    N = N - K
    return ans + math.ceil(N / (K - 1))


if __name__ == "__main__":
    N, K = map(int, input().split(" "))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))


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

int main()
{
	int D;
	cin >> D;
	if (D == 25)cout << "Christmas" << endl;
	if (D == 24)cout << "Christmas Eve" << endl;
	if (D == 23)cout << "Christmas Eve Eve" << endl;
	if (D == 22)cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
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;
typedef vector<cd> vcd;
 
#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 sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ld PI = 3.14159;
    ll R; cin >> R;
    cout << setprecision(10) << PI*2*R << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3800
/* created   : 2019-10-07 19:18:00
 * accepted  : 2019-10-07 19:18:27
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n; cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].x;
    v[i].y = i;
  }
  sort(v.begin(), v.end());
  trace(v);
  for (int i = 0; i < n; i++) {
    cout << v[i].y + 1 << (i == n - 1 ? '\n' : ' ');
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, q;
ll val[N];
vector <int> G[N];
int in[N], out[N], num[N], id;
void dfs(int u,int fa)  
{
	in[u] = ++id;
	num[id] = u;
	for(auto v : G[u])
	{
		if(v==fa) continue;
		dfs(v,u);
	}
	out[u] = id;
}
void upd(int rt, int x)
{
	val[in[rt]] += x;
	val[out[rt]+1] -= x;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> q;
 	for(int i=1; i<n; i++)
 	{
 		int u, v;
 		cin >> u >> v;
 		G[u].pb(v);
 		G[v].pb(u);
 	}
 	dfs(1, 0);
 	while(q--)
 	{
 		int p, x;
 		cin >> p >> x;
 		upd(p, x);
 	}
 	for(int i=1; i<=n; i++) val[i] += val[i-1];
 	for(int i=1; i<=n; i++)
 		cout << val[in[i]] << " \n"[i==n];
	return 0;
}


Measured memory_bytes: 26624
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    char a,b,c;
    a = s1[0]+'A'-'a';
    b = s2[0]+'A'-'a';
    c = s3[0]+'A'-'a';
    cout << a << b << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

vi binary_digit(ll a){
  vi ans(22);
  for (int i=0;i<22;++i){
    int t=(a>>i)&1;
    ans[i]=t;
  }
  return ans;
}

int find_diff_max(vi& v, vi&w){
  int ans=0;
  for (int i=0;i<22;++i){
    ans=max(ans, v[i]-w[i]);
  }
  return ans;
}



int main(){
  int N;cin>>N;
  vi a;
  for (int i=0;i<N;++i){
    int a_;cin>>a_;a.push_back(a_);
  }

  vi cumsum[N];
  cumsum[0]=binary_digit(a[0]);
  for (int i=1;i<N;++i){
    vi v=binary_digit(a[i]);
    for (int j=0;j<22;++j){
      cumsum[i].push_back(cumsum[i-1][j]+v[j]);
    }
  }

  ll count =0;
  
  for (int s=0;s<N;++s){
    int low=s;
    int high=N;
    int f;
    while(high-low>1){
      int mid=(high+low)/2;
      if(s==0){f=0;
        for (int i=0;i<22;++i){
          f=max(cumsum[mid][i], f);
        }
      }else{
        f=find_diff_max(cumsum[mid],cumsum[s-1]);
      }
      if(f<=1){low=mid;}else{high=mid;}
    }
    count+=low-s+1;
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 33908
K = int(input())
if K%2 == 0 or K%5 == 0:
    print(-1)
    exit()
if  K%7 == 0:
    K //=7
a = 0
r = 1
for i in range(1,K+1):
    p =  r%K
    a = (a+p)%K
    if a == 0:
        print(i)
        exit()
    r = p*10

Measured memory_bytes: 9188
#include <iostream>
#include <vector>

using namespace std;
int W;
vector<int> a(W);

void exit_right(int s, int t, vector<int>& r) {
	for (int i = s; i < t; ++i) {
		if (a[i] > 0) {
			r[i] = a[i];
		}
		else if (a[i] < 0) {
			for (int j = s; j < i; ++j) {
				if (r[j] > 0) {
					int temp = (i - j) + a[i];
					r[j] = min(r[j],-temp);
				}
			}
		}
	}
}

void exit_left(int s, int t, vector<int>& l) {
	for (int i = t; i > s; --i) {
		if (a[i] > 0) {
			l[i] = a[i];
		}
		else if (a[i] < 0) {
			for (int j = i+1; j < t; ++j) {
				if (l[j] > 0) {
					int temp = (j - i) + a[i];
					l[j] = min(l[j],-temp);
				}
			}
		}
	}
}

int main(void) {
	cin >> W;
	vector<int> exit;
	vector<bool> wall;
	int temp;
	bool find = false;
	for (int i = 0; i < W; ++i) {
		cin >> temp;
		a.push_back(temp);
		if (!find && a[i] < 0) {
			find = true;
		}
		if (a[i] == 0) {
			exit.push_back(i);
			wall.push_back(find);
			find = false;
		}
	}

	int res = 0;
	if (exit.size() > 0) {
		vector<int> r(W,0),l(W,0);
		int size = exit.size();
		for (int i = 0; i < size+1; ++i) {
			if (i == 0 || i == size) {
				if (i == 0) {
					exit_right(i,exit[i],r);
				}
				if (i == size) {
					exit_left(exit[i-1],W,l);
				}
			}
			else {
				exit_right(exit[i-1],exit[i],r);
				if (wall[i]) {
					exit_left(exit[i-1],exit[i],l);
				}
			}
		}

		for (int i = 0; i < W; ++i) {
			if (r[i] > 0 || l[i] > 0) {
				res += max(r[i],l[i]);
			}
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4552
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int T = sc.nextInt();
        int time = 0;
        if(N%X==0){
            time = N/X*T;
        }else {
            time = (N/X+1)*T;
        }
        System.out.println(time);       
    }    
}

Measured memory_bytes: 35688
#include<stdio.h>
#include <iostream>
using namespace std;

int main(){
  int HP;
  int N;
  cin >> HP >> N;
  int attack_array[N];
  for(int i=0;i<N;i++){cin >> attack_array[i];}
  
  int attack_sum = 0;
  for(int i=0;i<N;i++){attack_sum+=attack_array[i];}

  if (attack_sum >= HP){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  // int dum;
  // cin >> dum;
  return 0;
}

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

#define M 200005
#define MAXX 999999999999999
#define PI 3.14159265358979323846
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

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

//   freopen("input.txt","r",stdin);

   int n;
   cin>>n;
   
   vector<lli> v(n);
   for(int i=0;i<n;i++)
      cin>>v[i];
   
   lli ans = 0;
   for(int i=0;i<n;i++)
   {
      for(int j=i+1;j<n-1;j++)
      {
         for(int k=j+1;k<n;k++)
         {
            int a = v[i];
            int b = v[j];
            int c = v[k];
            if(a!=b && b!=c&& a!=c)
            {
               if(a+b>c && b+c>a && c+a>b)
               {
                  ans++;
//               cout<<"i = "<<i+1<<"  j = "<<j+1<<"  k = "<<k+1<<"\n";
               }
            }
         }
      }
   }
   
   cout<<ans<<"\n";
   
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    int n;
    cin>>n;
    
    vector<int> sp(n);
    vector<int> updown(n,0);
    
    for(int i=0; i<n; i++){
        cin>>sp[i];
    }
    for(int i=1; i<n; i++){
        if(sp[i]>sp[i-1]){
            updown[i-1]=1;
        }else if(sp[i]<sp[i-1]){
            updown[i-1]=-1;
        }
    }
    updown[n-1]=-1;

    long long mo=1000, st=0;
    for(int i=0; i<n; i++){
        if(updown[i]==1){
            st+=mo/sp[i];
            mo%=sp[i];
        }else if(updown[i]==-1){
            mo+=st*sp[i];
            st=0;
        }
    }
    cout<<mo<<endl;
    return 0;
}

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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<VB> VVB;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = INT_MAX;
const LL LINF = LLONG_MAX;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

VI dx = {1,0,-1,0};
VI dy = {0,1,0,-1};

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}

bool IsPrime(LL N){
  if(N <= 1) return false;
  for(int i = 2; i*i <= N; ++i){
    if(N%i == 0) return false;
  }
  return true;
}

bool ComPaiSec(PII a, PII b){
  if(a.SE != b.SE){
    return a.SE < b.SE;
  }else{
    return a.FI < b.FI;
  }
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,A=0,B=0;
  cin >> N;
  VI a(N);
  
  REP(i,N){
    cin >> a.at(i);
  }
  
  SORTR(a);
  
  REP(i,N){
    if(i%2==0){
      A += a.at(i);
    }else{
      B += a.at(i);
    }
  }
  
  cout << A-B << endl;
  
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int64> a(4);
	REP(i, 4) cin >> a[i];
	sort(all(a));
	int64 sum = 0;
	REP(i, 4) sum += a[i];
	int64 res = INF_LL;
	do {
	  res = min(res, abs((sum-a[0]-a[1]) - (a[0]+a[1])));
	} while(next_permutation(all(a)));
	cout << res << endl;
}



Measured memory_bytes: 3220
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main(int argc, char *argv[]){

	int n, m;
	long long int x = 1000000000 + 7;

	cin >> n >> m;

	if(abs(n - m) >= 2){
		cout << 0 << endl;
		return 0;
	}

	long long int pn = 1;
	long long int pm = 1;
	for(int i = n; i > 1; i--){
		pn *= i;
		pn %= x;
	}
	for(int i = m; i > 1; i--){
		pm *= i;
		pm %= x;
	}

	if(n == m){
		cout << (pn * pm * 2) % x;
	}else{
		cout << (pn * pm) % x;
	}

	return 0;
}


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

int N, INF = 100001;
int dist1[100000], dist2[100000];
int check[100000];
vector<int> G[100000];

void bfs(int s, int d[]){
    queue<int> q;
    
    for(int i=0;i<100000;i++) check[i] = 0;
    check[s] = 1;
    q.push(s);

    while(!q.empty()){
        int u = q.front();
        q.pop();

        for(int i=0;i<G[u].size();i++){
            int v = G[u][i];
            if(check[v]==0){
                check[v] = 1;
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
    }
}

int main(){
    int a, b;
    cin >> N;

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

    bfs(0, dist1);
    bfs(N-1, dist2);

    int cnt_f = 0;
    for(int i=0;i<N;i++)
        if(dist1[i] <= dist2[i]) cnt_f++;

    if(N/2 < cnt_f) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;

    return 0;
}


Measured memory_bytes: 7040
object Main extends App {
	val N = scala.io.StdIn.readInt
	val a = new Array[Int](N)
	val b = new Array[Int](N)

	for(i<-0 until N){
		val tp = scala.io.StdIn.readInt
		b(tp - 1) = i
	}

	var ans = 1
	var cnt = 1
	for(i<-1 until N){
		if(b(i) > b(i-1)) cnt += 1
		else cnt = 1

		ans = math.max(ans, cnt)
	}

	println(N - ans)
}

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

data = list(map(int,input().split()))

s = 0
x = 0
SUM = []
XOR = []
for i in range(n):
    s += data[i]
    x ^= data[i]
    SUM.append(s)
    XOR.append(x)
SUM.append(0)
XOR.append(0)


start = 0
end = 0

res = 0
F = [0]*n
while start<n:
    #move forward end
    while end < n and SUM[end]-SUM[start-1] == XOR[end]^XOR[start-1]:
        end += 1
    F[start] = end
    if end == n:
        for i in range(start,n):
            F[i] = end
        break
    #move forward start
    while start < n and SUM[end] - SUM[start-1] != XOR[end]^XOR[start-1]:
        F[start] = end
        start += 1
for i in range(n):
    res += F[i]-i 
print(res)


Measured memory_bytes: 37464
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<P> a_i(n);
    rep(i, n) {
        a_i[i] = P(a[i], i);
    }
    sort(RALL(a_i));
    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
    ll ans = 0;
    rep(l, n) {
        rep(r, n) {
            if (l + r == n) {
                chmax(ans, dp[l][r]);
                break;
            }
            chmax(dp[l+1][r], dp[l][r] + abs(a_i[l+r].second-l) * a_i[l+r].first);
            chmax(dp[l][r+1], dp[l][r] + abs(a_i[l+r].second-(n-1-r)) * a_i[l+r].first);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34628
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n;
    cin >> n;
    int a[n-1];//,b[n],c[n-1];
    
    fff(i,n-1)
    cin >> a[i];
    
    int ans=a[0];
    for(int i=0;i<n-2;i++) 
    ans+=(min(a[i],a[i+1]));                /// this question is done like this bcoz we have Bi >= max(ai,ai+1)
                                            /// thus to find ai we need to focus that what can be the min value at ai
                                            /// so that both statements contradicts and we will get the = max value for ai
                                            
    
    cout << ans+a[n-2];
    
	return 0;
    
}

Measured memory_bytes: 8832
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        
        int m = 0;

        m = 3*r*r;

        System.out.println(m);
        
    }

}

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

int main(){
  int a,i=0,b;
  while(cin>>a&&a){
    i=0;
    b=1000-a;
    i=b/500;
    b%=500;
    i+=b/100;
    b%=100;
    i+=b/50;
    b%=50;
    i+=b/10;
    b%=10;
    i+=b/5;
    b%=5;
    i+=b/1;
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
# 整数列A 
# abs(A1-(b+1))+abs(A2-(b+2))+...+abs(An-(b+N))の最小値
# bは任意
# すなわち、その時のbを求めれば良い問題

# 結局、bを、Ai-iの中央値にすれば最適解。

def calcVal(b):
	# print(b)
	val = 0
	for n in range(N):
		val += abs(A[n]-(b+n+1))
		# print(A[n])
		# print(n)
		# print(val)
		# print(abs(A[n]-(b+n+1)))
		# print("")
	return val

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

M=[]

for i,a in enumerate(A):
	#if a - (i+1) not in M:
	M.append( a - (i+1) )

M.sort()
lenM=len(M)

if lenM==1:
	ans=calcVal(M[0])

elif lenM==2:
	ans=min(calcVal(M[0]),calcVal(M[1]))


else:
	med1=lenM//2-1
	med2=lenM//2
	#print(M)
	ans=min(calcVal(M[med1]),calcVal(M[med2]),calcVal(0))



print(ans)



Measured memory_bytes: 25744
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
ll p=1000000007;
ll f[1000010];
ll s[1000010];
int main()
{
	int n;
	scanf("%d",&n);
	f[0]=1;
	f[1]=n;
	s[0]=1;
	s[1]=n+1;
	int i;
	for(i=2;i<=n;i++)
	{
		f[i]=f[i-1];
		f[i]=(f[i]+ll(n-1)*(n-1))%p;
		if(i<=2)
			f[i]=(f[i]+n-1)%p;
		else
			f[i]=(f[i]+s[i-3]+n-i+1)%p;
		s[i]=(s[i-1]+f[i])%p;
	}
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 15872
import collections

N = int(input())
words = [input() for i in range(N)]
judge = 'Yes'

count = collections.Counter(words)
if (count.most_common(1)[0][1] >= 2):
    judge = 'No'

for i in range(N-1):
    end_w = words[i][-1]
    beg_w = words[i + 1][0]

    if (end_w != beg_w):
        judge = 'No'
        break

print(judge)

Measured memory_bytes: 3316
#include<stdio.h>
int main(){
    int n, d, a, b;
    scanf("%d%d", &n, &d);
    a = n / (d * 2 + 1);
    if(n == (a * (d * 2 + 1))){
        b = 0;
    }else{
        b = 1;
    }
    printf("%d", a + b);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
long long actionFunction(vector<int> &weights, vector<long long> &values, int maxWeightCapacity) {
    if(weights.size()==0 || maxWeightCapacity<0)return 0;
    vector<long long> dp(maxWeightCapacity+1,0);
    for(int k=0;k<=maxWeightCapacity;k++) {
        dp[k]=(long long)(k>=weights[0])?(long long)values[0]:(long long)0;
    }
    for(int i=1;i<weights.size();i++) {
        vector<long long> cmp;//(maxWeightCapacity+1,0);
        for(int k=0;k<=maxWeightCapacity;k++) {
	      if(k-weights[i]>=0) {
	        cmp.push_back((long long)max((long long)dp[k-weights[i]]+(long long)values[i],(long long)dp[k]));
	      } else {
	      	cmp.push_back((long long)dp[k]);
	      }
	    }
	    /*
        for(int k=0;k<=maxWeightCapacity;k++) {
            cmp[k]=max(dp[k],(k>=weights[i])?values[i]+dp[k-weights[i]]:0);
        }
        */
        dp=cmp;
    }
    return dp[maxWeightCapacity];
}
int main(void){
    vector<int> weights;
    vector<long long> values;
    int n,k,tmp;
    long long tmpl;
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        cin>>tmp;cin>>tmpl;
        weights.push_back(tmp);
        values.push_back((long long)tmpl);
    }
    cout<<actionFunction(weights,values,k)<<endl;
  return 0;
}


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

int main(){
    
    int l,r;
    cin >> l >> r;
    const int num = 2019;
    int comp = INT_MAX;
    long long ans = 0;
    for(long long i=l; i<=r; i++){
        for(long long j=l; j<i; j++){
            ans = ((i%num) * (j%num))%num;
            if(ans < comp){
                comp = ans;
            }
            else if(ans == 0){
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << comp << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int k, x;

signed main() {
	cin >> k >> x;
	for (int i = x - k + 1; i < x + k; i++) {
		if (i != x + k - 1)cout << i << " ";
		else cout << i << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>

double avg(int n) {
	return (n+1)/2.0;
}

int main() {
	int n, k, p[2000010];
	std::cin >> n >> k;

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

	double sum = 0;
	for (int i = 0; i < k; ++i) {
		sum += avg(p[i]);
	}


	double ans = sum;
	for (int i = k; i < n; ++i) {
		sum -= avg(p[i-k]);
		sum += avg(p[i]);

		ans = std::max(ans, sum);
	}

	std::cout << std::setprecision(10) << std::fixed << ans;
}

Measured memory_bytes: 4516
import java.util.*;

public class Main {
    static int n;
    static int[] bit;

    static void add(int x, int y) {
        for (int i=x;i<=n;i+=i&(-i)) {
            bit[i]+=y;
        }
    }

    static int sum(int x) {
        int tmp = 0;
        for (int i=x;i>0;i-=i&(-i)) {
            tmp+=bit[i];
        }
        return tmp;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        n = s.length();
        bit = new int[n+1];
        int k = sc.nextInt();

        ArrayList<ArrayDeque<Integer>> list = new ArrayList<ArrayDeque<Integer>>();
        for (int i=0;i<26;i++) {
            ArrayDeque<Integer> add = new ArrayDeque<Integer>();
            list.add(add);
        }
        for (int i=0;i<n;i++) {
            list.get((int)c[i]-97).addLast(i);
            add(i+1, 1);
        }


        StringBuilder sb = new StringBuilder();
        for (int i=0;i<n;i++) {
            for (int j=0;j<26;j++) {
                if (list.get(j).size()==0) continue;
                int pos = list.get(j).getFirst();
                int cnt = sum(pos);

                if (cnt<=k) {
                    list.get(j).pollFirst();
                    k -= cnt;
                    sb.append((char)(97+j));
                    add(pos+1, -1);
                    break;
                }
            }
        }

        System.out.println(sb);
    }
}


Measured memory_bytes: 39460
package main
import "fmt"

func main() {
  var(
    a,b,c,d,e int
  )
    _, _= fmt.Scanf("%d", &a)
    _, _= fmt.Scanf("%d", &b)
    _, _= fmt.Scanf("%d", &c)
    _, _= fmt.Scanf("%d", &d)
    _, _= fmt.Scanf("%d", &e)
  l := []int{a,b,c,d,e}
  cnt := 9999
  for i1:=0; i1<5; i1++ {
    cnt1 := 0+l[i1]
    if cnt1%10!=0 { cnt1 += (10-cnt1%10) }
    for i2:=0; i2<5; i2++ {
      if i2==i1 { continue }
      cnt2 := cnt1+l[i2]
      if cnt2%10!=0 { cnt2 += (10-cnt2%10) }
      for i3:=0; i3<5; i3++ {
      	if i3==i1 || i3==i2 { continue }
      	cnt3 := cnt2+l[i3]
      	if cnt3%10!=0 { cnt3 += (10-cnt3%10) }
        for i4:=0; i4<5; i4++ {
          if i4==i1 || i4==i2 || i4==i3 { continue }
          cnt4 := cnt3+l[i4]
          if cnt4%10!=0 { cnt4 += (10-cnt4%10) }
          for i5:=0; i5<5; i5++ {
            if i5==i1 || i5==i2 || i5==i3 || i5==i4  { continue }
            cnt5 := cnt4+l[i5]
            if cnt>cnt5 {cnt=cnt5}
          }
        }
      }
    }
  }
  fmt.Println(cnt)
}

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

#define ine long long

using namespace std;

vector <pair<int,int> > v[100010];
bool vis[100010];
int c[100010];

void dfs(int n, int d)
{
	if(d%2)
		c[n] = 1;

	vis[n] = true;

	for(auto i:v[n])
	{
		if(!vis[i.first])
			dfs(i.first, d+i.second);
	}
}

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

	int x,y,z;

	for(int i=0;i<n;i++)
	{
		cin >> x >> y >> z;
		v[x].push_back({y,z});
		v[y].push_back({x,z});
	}

	dfs(1,0);

	for(int i=1;i<=n;i++)
		cout << c[i] << "\n";
}


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

const int N = 4005;
const int mod = 998244353;

void add(int &x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int mul(int x,int y) {
	return (long long) x * y % mod;
}

int pw(int x,int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = mul(ret, x);
		x = mul(x, x);
		y >>= 1;
	}
	return ret;
}

int n, k;
int fac[N], ifac[N], pw2[N];

int C(int n,int k) {
	if (n < k || k < 0) return 0;
	return mul(fac[n], mul(ifac[k], ifac[n - k]));
}

int candy(int n,int k) {
	return C(n + k - 1, k - 1);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> k >> n;
	fac[0] = 1; pw2[0] = 1;
	for (int i = 1; i <= n + k; ++i) fac[i] = mul(fac[i - 1], i), pw2[i] = mul(pw2[i - 1], 2);
	ifac[n + k] = pw(fac[n + k], mod - 2);
	for (int i = n + k - 1; i >= 0; --i) ifac[i] = mul(ifac[i + 1], i + 1);
	for (int i = 2; i <= k + k; ++i) {
		int f = 0, g = 0;
		for (int j = 1; j <= k; ++j) {
			int l = i - j;
			if (l < 1 || l > k) f++;
			else if (j < l) f++, g++;
		}
		int ans = 0;
		for (int j = 0; j <= g; ++j) {
			int coef = candy(n - j, f - g + j);
			if (i % 2 == 0) add(coef, candy(n - j - 1, f - g + j));
			coef = mul(coef, mul(pw2[j], C(g, j)));
			add(ans, coef);
		}
		cout << ans << '\n';
	}
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>


#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)


typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <int, int> pii;


const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 1000000007;
const ll INF = 0x3F3F3F3F;


template <typename T>
inline T Abs(T x)
{
	return x < 0 ? x * -1 : x;
}


template <typename T>
inline T Max(T x, T y, T z)
{
	return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
	return std::min(std::min(x, y), z);
}


template <typename T>
inline void Ckmax(T &x, T y)
{
	x = std::max(x, y);
}


template <typename T>
inline void Ckmin(T &x, T y)
{
	x = std::min(x, y);
}


template <typename T>
inline T Sqr(T x)
{
	return x * x;
}


template <typename T>
inline T Pow(T x, T y)
{
	T r = 1;
	while (y > 0)
	{
		if (y % 2 > 0)
			(r *= x) %= MOD;
		(x *= x) %= MOD;
		y /= 2;
	}
	return r % MOD;
}


template <typename T>
T Pow(T x, T y, T z)
{
	T r = 1;
	while (y > 0)
	{
		if (y % 2 > 0)
			(r *= x) %= z;
		(x *= x) %= z;
		y /= 2;
	}
	return r % z;
}


template <typename T>
inline T gcd(T x, T y)
{
	return y > 0 ? gcd(y, x % y) : x;
}


template <typename T>
inline T lcm(T x, T y)
{
	return x / gcd(x, y) * y;
}


inline void cinspu(void)
{
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
}


inline ll read(void)
{
	char x;
	while (x = getchar(), x != '-' && !isdigit(x))
		;
	char flg = x == '-';
	ll num = (flg ? getchar() : x) - '0';
	while (isdigit(x = getchar()))
		(num *= 10) += x - '0';
	return flg ? -num : num;
}

int main()
{
	int n, t, a;
	std::cin >> n >> t >> a;
	int ans = 0;
	double x = INT_MAX;
	for (int i = 1; i <= n; ++i)
	{
		int b;
		std::cin >> b;
		double c = (t - b * 0.006);
		if (Abs(c - a) < x)
		{
			x = Abs(c - a);
			ans = i;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
def sa(c,d):
    
    if c>d:
        nn=int(c/d)
        c2=c-d*nn
        if c2<d:
            return c2,d
        else:
            return d,c2
    else :
        nn=int(d/c)
        c2=d-c*nn
        if c2<c:
            return c2,c
        else:
            return c,c2

a,b,c,d=map(int,input().split())

mp=c*d

c1=c+1-1
d1=d+1-1
for i in range(10**18):
    c2,d2=sa(c1,d1)
#    print("c1,d1,c2,d2",c1,d1,c2,d2)    
    if c2<=0:
        break
    c1=c2
    d1=d2

mcm=int(mp/c1)

ac2=int(int(a-1)//int(c))
ad2=int(int((a-1))//int(d))
am2=int(int((a-1))//mcm)

bc2=int(int(b)//int(c))
bd2=int(int(b)//int(d))
bm2=int(int(b)//mcm)
#print(mcm,ac2,bc2,ad2,bd2,am2,bm2)     

icnt=(bc2-ac2)+(bd2-ad2)-(bm2-am2)
icnt=(b+1-a)-icnt

print(icnt)


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

int main() {
    int n, m, res = 1;
    cin >> n >> m;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            if (n <= i) {
                res = max(res, m / i);
            }
            else if (n <= m / i) {
                res = max(i, res);
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  char	b;
//  int N, K, KK, x, s=0;
  cin >> b;
  if ( b == 'A' ) cout << 'T';
  else if ( b == 'T' ) cout << 'A';
  else if ( b == 'G' ) cout << 'C';
  else cout << 'G';
  cout << endl;
}


Measured memory_bytes: 256
# 再帰関数の上限解除
import sys
sys.setrecursionlimit(10**9)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self,x):
        if(self.parents[x] < 0):
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def size(self, x):
        return self.parents[ self.find(x) ] * -1

    def same(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)
        return (x_root == y_root)

    def union(self,x,y):
        x_root = self.find(x)
        y_root = self.find(y)
        if(x_root == y_root):
            return

        if( self.parents[x_root] <= self.parents[y_root] ):
            self.parents[x_root] += self.parents[y_root]
            self.parents[y_root] = x_root
        else:
            self.parents[y_root] += self.parents[x_root]
            self.parents[x_root] = y_root

    def members(self,x):
        root = self.find(x)
        ret = [ i for i in range(self.n) if self.find(i) == root ]
        return ret

    def roots(self):
        ret = [ i for i in range(self.n) if self.parents[i] < 0]
        return ret

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m,*ab = map(int,read().split())

uf = UnionFind(n)
it = iter(ab)
for a,b in zip(it,it):
    a -= 1
    b -= 1
    uf.union(a,b)

print(uf.group_count() - 1)

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

typedef long long lint;
typedef pair<lint,lint> pll;
typedef long double louble;

#define lf ('\n')

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 103 , mo = 1000000007;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

int n,hig[_];

// pll = (not have adjacent same color, have adjacent same color)

pll dfs(int l,int r,int h)
{
	int mih=2e9;
	for(int i=l;i<=r;i++)mih=min(mih,hig[i]);

	pll ans=pll(2,1);
	for(int i=l;i<=r;i++)
	{
		if(hig[i]==mih)ans.second=ans.second*2%mo;
		else
		{
			int j=i;
			while(j<r && hig[j+1]>mih)j++;
			pll ret=dfs(i,j,mih);
			ans.first=ans.first*ret.first%mo;
			ans.second=(ret.first+ret.first+ret.second)%mo*ans.second%mo;
			i=j;
		}
	}

	ans.second=(ans.second-ans.first+mo)%mo;
	ans.first=ans.first*powa(2,mih-h-1)%mo;

	return ans;
}

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)hig[i]=ty();
	pll ret=dfs(1,n,0);
	printf("%lld\n",(ret.first+ret.second)%mo);

	return 0;
}


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

using namespace std;

double f(double x) {
  return x * x;
}

int main(int argc, char *argv[]) {
  double d;
  double s;
  vector<int> result;

  while (cin >> d) {
    s = 0.0;
    for (int i = 0; i < 600/d; i++)
      s += d * f(d * i);
    result.push_back((int)s);
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}

Measured memory_bytes: 1244
import java.util.*;

public class Main {



    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = sc.nextInt();


        List<Integer> l = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            int ai = sc.nextInt();
            l.add(ai);
        }

        Collections.sort(l);

        int ans = 0;
        long sum = 0;

        for(int i = 0; i < n; i++) {
            sum += l.get(i);
            if(sum <= x)
                ans = i + 1;
        }

        if(ans == n && sum != x)
            ans--;

        System.out.println(ans);

    }
}


Measured memory_bytes: 25300
n = int(input())
n_hype = n
ans = []
for i in range(2,int(n**0.5)+2):
    while True:
        if n_hype%i==0:
            ans.append(i)
            n_hype /=i
        else:
            break
if n_hype!=1:
    ans.append(int(n_hype))
    
print('{}:'.format(n),end = '')
for a in ans:
    print('',a,end = '')
print()


Measured memory_bytes: 5640
import sys

stdin = sys.stdin

ni = lambda: int(ns())
ns = lambda: stdin.readline().rstrip()
na = lambda: list(map(int, stdin.readline().split()))

# code here
N = ni()
X = na()

minc = 99999999999999999

for i in range(1, 101):
    cost = 0
    for x in X:
        cost += (x-i)**2

    minc = min(cost, minc)

print(minc)


Measured memory_bytes: 9132
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string w;
    cin >> w;
    int ans=0;
    for(char i='a';i<='z';i++){
        if(count(w.begin(),w.end(),i)%2!=0)
        ans++;
    }
    if(ans>0)
    cout << "No" <<endl;
    else cout << "Yes" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};


int main(){
  string s;
  cin >> s;
  int ans = 0;
  int tmp = 0;
  rep(i,int(s.size())) {
	if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
	  tmp++;
	}
	else {
	  ans = max(tmp,ans);
	  tmp = 0;
	}
	if(i == int(s.size())-1) {
	  ans = max(tmp,ans);
	}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628