akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define maxn 2005
#define inf (int)1e8
#define X first
#define Y second
int n;
int L[maxn], R[maxn], mx[maxn];
char a[maxn], b[maxn];
vector<pair<int,int> > p;
void shiftL() {
    int i,tL,tR;
    char tC;
    tC = a[0]; tL = L[0]; tR = R[0];
    for(i=0;i<n-1;i++) a[i] = a[i+1], L[i] = L[i+1], R[i] = R[i+1];
    a[n-1] = tC; L[n-1] = tL; R[n-1] = tR;
}
void shiftR() {
    int i,tL,tR;
    char tC;
    tC = a[n-1]; tL = L[n-1]; tR = R[n-1];
    for(i=n-1;i>=0;i--) a[i] = a[i-1], L[i] = L[i-1], R[i] = R[i-1];
    a[0] = tC; L[0] = tL; R[0] = tR;
}
main() {
    int i,cnt,last,ok1,ok2;
    int sz,ans;
    scanf(" %s %s",a,b);
    n = strlen(a);
    //Case -1 (b=0 but a!=0)
    ok1 = ok2 = 0;
    for(i=0;i<n;i++) if(a[i]=='1') ok1 = 1;
    for(i=0;i<n;i++) if(b[i]=='1') ok2 = 1;
    if(!ok2 && ok1) {
        printf("-1");
        return 0;
    }
    //Find L[]
    last = -1;
    for(i=0;i<n;i++) if(b[i]=='1') last = i;
    for(i=0;i<n;i++) {
        if(b[i]=='1') last = i;
        if(a[i]!=b[i]) L[i] = (i-last+n)%n;
    }
    //Find R[]
    last = -1;
    for(i=n-1;i>=0;i--) if(b[i]=='1') last = i;
    for(i=n-1;i>=0;i--) {
        if(b[i]=='1') last = i;
        if(a[i]!=b[i]) R[i] = (last-i+n)%n;
    }
    //Solve
    ans = inf;
    for(cnt=0;cnt<n;cnt++) {
//        printf("Lshift : %d : %s and %s\n",cnt,a,b);
        p.clear();
        for(i=0;i<n;i++) if(a[i]!=b[i]) p.push_back({L[i],R[i]});
        sz = p.size();
        sort(&p[0],&p[sz]); mx[sz] = 0;
        for(i=sz-1;i>=0;i--) mx[i] = max(mx[i+1],p[i].Y);
        for(i=-1;i<sz;i++) {
//            printf("\t%d %d\n",p[i].X,p[i].Y);
            ans = min(ans,sz + (max((i==-1 ? 0 : p[i].X),cnt) + mx[i+1])*2 - cnt);
        }
        shiftL();
    }
    for(i=0;i<n;i++) swap(L[i],R[i]);
    for(cnt=0;cnt<n;cnt++) {
//        printf("Rshift : %d : %s and %s\n",cnt,a,b);
        p.clear();
        for(i=0;i<n;i++) if(a[i]!=b[i]) p.push_back({L[i],R[i]});
        sz = p.size();
        sort(&p[0],&p[sz]); mx[sz] = 0;
        for(i=sz-1;i>=0;i--) mx[i] = max(mx[i+1],p[i].Y);
        for(i=-1;i<sz;i++) {
//            printf("\t%d %d\n",p[i].X,p[i].Y);
            ans = min(ans,sz + (max((i==-1 ? 0 : p[i].X),cnt) + mx[i+1])*2 - cnt);
        }
        shiftR();
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>

using namespace std;

int main() {
  const string a[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  char t[9];
  scanf("%s", t);
  string s = string(t);
  int ans = 1;
  for (int i = 0; i < 7; ++i) {
    if (a[i] == s) {
      for (int j = i + 1;; ++j) {
        if (a[j % 7] == "SUN") {
          break;
        }
        ++ans;
      }
      break;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
/*
    Bismillahir Rahmanir Raheem
    Think Twice Code Once
    author : reaziii
*/
#include<bits/stdc++.h>
#define sc(x)        scanf("%lld",&x)
#define pcase(x)     printf("Case %d: ",x++)
#define pn           printf("\n")
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x,e)   memset(x,e,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define m_v          3000000
#define pii          pair<int,int>
#define pch          pair<char,char>
#define pll          pair<ll,ll>
#define mgraph       map<int,set<int> >
#define mp           make_pair
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define frx(x,y)     for(int x=0;x<y;x++)
#define deb(x)       cout<<x
#define ideb(i,x)    cout<<i<<" "<<x
#define F            first
#define S            second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool checkbitt(ll num,int pos);
ll setbitt(ll num,ll pos);
ll resetbitt(ll num,int pos);
 //.................___Start from here___.................//
//.................._____________________................//
 
 
int setbitcount(ll n){
    int ans = 0;
    for(int i=0;i<32;i++){
        ans+=(n>>i)&1;
    }

    return ans;
}
void solve(){
    int n;
    cin>>n;
    int mask = 1<<n;
    mask--;
 
    int a[n+1],x[n+1][n+1],y[n+1][n+1];
 
    for(int u = 1 ; u <= n ; u++ ){
        cin>>a[u];
        for(int v = 1;v<=a[u];v++){
            cin>>x[u][v]>>y[u][v];
        }
    }
 
    int ans = 0;
 
    for(int i=1;i<=mask;i++){
        bool f =true;
 
        for(int j=1;j<=n;j++){
            if(checkbitt(i,j-1)){
                for(int k=1;k<=a[j];k++){
                    if(y[j][k]^checkbitt(i,(x[j][k]-1))) f = false;
                }
            }
        }
 
        if(f) ans = max(ans,setbitcount(i));
    }
 
    cout<<ans<<endl;
 
}
 
 
int main(){
    // input;
    // output;
 
    int cs=1;
    int cn=1;
    // cin>>cs;
    while(cs--){
        solve();
    }
}
 
 
 
 
 
 
bool checkbitt(ll num,int pos){
    return (num>>pos) & 1;
}
 
ll setbitt(ll num,ll pos){
    return (1<<pos) | num;
}
 
ll resetbitt(ll num,int pos){
    if(!checkbitt(num,pos)) {
        return num;
    }
    else{
        return (1<<pos)^num;
    }
}


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

using namespace std;

int main(){
    vector<int> v(10);
    int sp1, sp2;
    char k;

    while(cin>>v[0]){
        double all=v[0];
        for(int i=1; i<10; i++){
            cin >>k >>v[i];
            all += v[i];
        }
        cin>>k >>sp1 >>k >>sp2;

        double hour = all/(sp1+sp2);
        double len = sp1*hour;

        int k = 0;
        while(len>0){
            len -= (double)v[k];
            k++;
        }

        cout<< k<< endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    string s;
    int i;
    cin>>s;
    if(s[s.size()-1]=='2'||s[s.size()-1]=='4'||s[s.size()-1]=='5'||s[s.size()-1]=='7'||s[s.size()-1]=='9')
    {
        cout<<"hon"<<endl;
    }
    else if(s[s.size()-1]=='0'||s[s.size()-1]=='1'||s[s.size()-1]=='6'||s[s.size()-1]=='8')
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"bon"<<endl;
    }
    return 0;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N)  for (int i = 0; i < (N); i++)

int main(){

    float N, X, T;
    cin >> N >> X >> T;

    int ans = 0;
    ans = ceil(N/X)*T;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  int a[100]={},b[100]={};
  cin>>s>>t;
  for(int i=0;i<s.size();i++)a[i]=(int)s[i];
  for(int j=0;j<t.size();j++)b[j]=(int)t[j];
  sort(a,a+s.size());
  sort(b,b+t.size());
  for(int i=0;i<s.size();i++)s[i]=(char)a[i];
  for(int i=0;i<t.size();i++)t[i]=(char)b[t.size()-(i+1)];
  if(s>=t)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,x; cin>>n>>x;
	vector<int>m(n); for(auto&i:m)cin>>i,x-=i;
	sort(m.begin(),m.end());
	cout<<n+x/m.front()<<"\n"s;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N, p[4], t[4];

  cin >> N;

  for (int i=0; i<4; i++)
    cin >> p[i];

  for (int i=0; i<4; i++)
    cin >> t[i];

  int ans = INF;

  for (int i=0; i<=N; i++) {
    for (int j=0; j<=N; j++) {
      for (int k=0; k<=N; k++) {
        int sum = i * t[0] + j * t[1] + k * t[2];
        int l = max(0, (N - sum + t[3] - 1) / t[3]);
        ans = min(ans, i * p[0] + j * p[1] + k * p[2] + l * p[3]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	string s;cin>>s;
	int N=s.size();
	bool flag=false;int count=0;int temp;
	int A[N]={};
	rep(i,0,N){
		if(s.at(i)=='R'){
			if(flag) count++;
			else{ count=1;flag=true; }
		}else{
			if(flag){
				A[i-1]+=(count+1)/2;
				A[i]+=count/2+1;
				temp=i;flag=false;
			}else{
				if((i-temp)%2==0) A[temp]++;
				else A[temp-1]++;
			}
		}
	}print(A,N);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  int ans = N;
  sort(a.begin(),a.end());
  for(int i=1;i<N;i++){
    if(a.at(i) == a.at(i-1)){
      ans--;
    }
  }

  cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	int h, w;
	string t = ".";
	cin >> h >> w;

	vector<string> s(h + 2);

	for (int i = 0; i < w+1; i++) {
		t += ".";
	}

	
	s[0] = t; s[h + 1] = t;
	for (int i = 1; i < h+1; i++) {
		cin >> t;
		s[i] = "." + t + ".";
	}
	/*
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			cout << s[i][j];
		}
		cout << endl;
	}

	for (int i = 0; i < h + 2; i++) {
		cout << s[i] << endl;
	}
	*/
	
	for (int i = 1; i < h+1; i++) {
		for (int j = 1; j < w+1; j++) {
			if (s[i][j] == '#') {
				if (s[i-1][j]=='.'&&s[i][j-1] == '.'&&s[i][j + 1] == '.'&&s[i + 1][j] == '.') {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
    map<string,int> mp;
    map<int,string> mp2;
    mp["Sunny"] = 0;
    mp["Cloudy"] = 1;
    mp["Rainy"] = 2;
    mp2[0] = "Sunny";
    mp2[1] = "Cloudy";
    mp2[2] = "Rainy";
    string s;
    cin >> s;
    cout << mp2[(mp[s]+1)%3] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int N = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();
		int counter = 0;
		int counter2 = 0;
		
		for( int i = 1; i <= N; i++) {
			for( int j = i; j != 0; j /= 10) {
				counter += j % 10;	
			}
			if(A <= counter && B >= counter) {
				counter2 += i;
			}
			counter = 0;
		}
		System.out.println(counter2);
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

bool visit[100004][3] = {false};
int main() {
    int n, m, s, t;
    int a, b;
    cin >> n >> m;
    unordered_map<int, vector<int>> e;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        e[a].push_back(b);
    }
    cin >> s >> t;
    // unordered_set<int> visit;
    vector<int> dq = {s};
    visit[s][2] = true;
    if (s == t) {
        cout << 0 << endl;
        return 0;
    }
    int dis = 0;
    while (!dq.empty()) {
        dis += 1;
        for(int i = 1; i <= 3; i++) {
            vector<int> new_dq;
            for(int node: dq) {
                // cout << "step" << i << ", node = "<<node << endl;
                for(int neibor: e[node]) {
                    if (visit[neibor][i-1] == false) {
                        new_dq.push_back(neibor);
                        visit[neibor][i-1] = true;
                        if (i == 3 && neibor == t) {
                            cout << dis << endl;
                            return 0;
                        }
                    }
                }
            }
            dq.swap(new_dq);
        }

    }
    cout << -1 << endl;

    return 0;
}



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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

int n, m;
vvi Edge;
vvi rEdge;
vi order;
vi group;
vector<bool> used;

void dfs(int v) {
  used[v] = true;
  for(auto next : Edge[v]) {
    if(!used[next]) dfs(next);
  }
  order.push_back(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  group[v] = k;
  for(auto next : rEdge[v]) {
    if(!used[next]) rdfs(next, k);
  }
  order.push_back(v);
}

int StrngConctComp() {
  rep(v, 0, n) {
    if(!used[v]) dfs(v);
  }
  used.assign(n, false);
  int k = 0;
  for(int i = order.size() - 1; i >= 0; --i) {
    int v = order[i];
    if(!used[v]) rdfs(v, k++);
  }
  return k;
}

int FindNumNewEdges(int nGroup) {
  if(nGroup == 1) return 0;

  vi inCnt(nGroup);
  vi outCnt(nGroup);

  rep(s, 0, n) {
    int grp_s = group[s];

    for(auto t : Edge[s]) {
      int grp_t = group[t];

      if(grp_s != grp_t) {
        inCnt[grp_t]++;
        outCnt[grp_s]++;
      }
    }
  }

  int inZero = count(all(inCnt), 0);
  int outZero = count(all(outCnt), 0);
  return max(inZero, outZero);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> n >> m;
  Edge.resize(n);
  rEdge.resize(n);
  used.resize(n);
  group.resize(n);

  rep(i, 0, m) {
    int s, t;
    cin >> s >> t;
    Edge[s].push_back(t);
    rEdge[t].push_back(s);
  }

  cout << FindNumNewEdges(StrngConctComp()) << endl;
}



Measured memory_bytes: 5868
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define sz(x) ((int)x.size())
#define ff first
#define ss second
typedef long long ll;
const int MAXN = -1;

int n;
string S;

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%d", &n) == 1){
        cin >> S; int L = 0, R = 0, ans = 1e6;
        forr(i, 1, n)if(S[i] == 'E')R++;
        forn(i, n-1){
            ans = min(ans, L + R);
            if(S[i] == 'W')L++;
            if(S[i+1] == 'E')R--;
        }
        ans = min(ans, L + R);
        printf("%d\n", ans);
    }
	return 0;
}


Measured memory_bytes: 900
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int n;
	cin >> n;

	int left=1,right=1,sum=0;
	for(int i=1;;i++){
		sum+=i;
		if(sum>=n) {
			cout << i << "\n";
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, m; cin >> n >> m;
  vector<long long int> x(n);
  vector<long long int> y(m);
  for(int i=0; i<n; i++) scanf("%lld", &x[i]);
  for(int i=0; i<m; i++) scanf("%lld", &y[i]);

  long long int ansx = 0;
  for(int i=0; i<n; i++){
    ansx += x[i] * (2*i-n+1);
    ansx %= mod;
  }

  long long int ansy = 0;
  for(int i=0; i<m; i++){
    ansy += (y[i] * (2*i-m+1));
    ansy %= mod;
  }
  cerr << ansx << " " << ansy << endl;
  long long int ans = ((ansx%mod) * (ansy%mod))%mod;

  cout << ans << endl;

  return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K; cin >> K;
    int ans = 0;
    for(int i = 1; i <= K; i++){
        int g = i;
        for(int j = 1; j <= K; j++){
            int h = __gcd(g, j);
            for(int k = 1; k <= K; k++){
                //cout << i << ": " << j << ": " << k << ": " << __gcd(h, k) << endl;
                ans += __gcd(h, k);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    static Scanner s = new Scanner(System.in);
    public static void main(String[] args) {
        int n = s.nextInt();
        int max = 0;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int tmp = s.nextInt();
            if (max < tmp) {
                max = tmp;
            }
            sum += tmp;
        }
        System.out.println(max < (sum - max) ? "Yes" : "No");
    }
}


Measured memory_bytes: 23252
#include <iostream>

using namespace std;

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

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

    int ans = 0;

    ans = (n-1)/(k - 1);
    
    if ((n - 1)%(k-1) != 0){ ans += 1;}

    cout << ans << endl;
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Alchemist | diff Alchemist.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Alchemist.cpp && ./a.out

/*
 
 8/18/2019
 
 21:03-21:04
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  sort(A,A+N);
  double res=(A[0]+A[1])*0.5;
  FOR(i,2,N) res=(res+A[i])*0.5;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
llint mod = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  int h = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    h += a;
    q.push(a);
  }
  bool f = 1;
  for (int i = 0; i < m; i++) {
    if (q.top() * 4 * m >= h) {
      q.pop();
    }
    else {
      f = 0;
      break;
    }
  }
  if (f) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	vi p, s, c;
	int i, j, k, l, m, n, d, g;
	vector<bool> t;
	bool carry;

	cin >> n >> g;
	p.resize(n);
	s.resize(n);
	c.resize(n);
	t.resize(n);

	rep(i, n) {
		cin >> p[i] >> c[i];
		s[i] = p[i] * (i + 1) * 100;
		t[i] = 0;
	}

	m = pow(10, 9);

	while (1) {
		k = 0;
		j = 0;
		rep(i, n) {
			if (t[i] == 1) {
				k += p[i];
				j += s[i] + c[i];
			}
		}
		if (j >= g) {
			m = min(m, k);
		}
		else if (j < g) {
			rep(i, n) {
				if (t[i] == 0) {
					if (j + s[i] >= g) {
						l = g - j;
						if (l % ((i + 1) * 100) == 0) {
							d = l / ((i + 1) * 100);
						}
						else {
							d = (int)(l / ((i + 1) * 100)) + 1;
						}
						m = min(m, k + d);
					}
					else if (j + s[i] + c[i] >= g) {
						m = min(m, k + p[i]);
					}
				}
			}
		}
		carry = true;
		j = 0;
		while (carry) {
			if (j >= n+1)
				break;
			carry = t[j];
			t[j] = !t[j];
			j++;
		}
		if (j >= n+1)
			break;
	}

	cout << m;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int votes[105];
int main(){
	int n,m;
	cin>>n>>m;
	int total=0;
	for(int i = 0; i<n; i++){ 
		cin>>votes[i];
		total += votes[i];
	}
	int count=0;
	int coef=ceil((float)total/(4*m));
	
	for(int i = 0; i<n; i++){
		if(votes[i] >= coef) count++;
		if(count == m) break;
	}
	if(count == m) cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 1e9+7;
vector<P> hen;

int main()
{
	int n,k;
	ll ans=0;
	cin>>n>>k;
	int mx=(n-2)*(n-1)/2;//最大数
	cerr<<mx<<endl;
	if(k>mx)
	{
		cout<<-1<<endl;
	}else{
		for(int i=1;i<n;i++)
			hen.push_back(P(i,n));
		//潰す個数だけ辺を張る
		int cnt=0;
		bool f=true;
		if(k!=mx)
		{
			for(int i=1;i<n;i++)
			{
				for(int j=i+1;j<n;j++)
				{
					hen.push_back(P(i,j));
					cnt++;
					if(cnt==mx-k)
					{
						f=false;
						break;
					}
				}
				if(!f)
					break;
			}
		}
		cout<<hen.size()<<endl;
		for(int i=0;i<hen.size();i++)
			cout<<hen[i].first<<" "<<hen[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MX=5e5+9;
const ll mod=1e9+7;
ll n,m;
ll fac[MX],ifac[MX];

ll pow(ll a,ll b){
    ll ans=1;
    while( b ){
        if( b&1 )
            ans=(ans*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ans;
}

ll prem(ll x,ll y){return fac[y]*ifac[y-x]%mod;}
ll C(ll x,ll y){return prem(x,y)*ifac[x]%mod;}

void init(){
    fac[0]=1;
    for( ll i=1 ; i<=m ; i++ )
        fac[i]=(fac[i-1]*i)%mod;
    ifac[m]=pow(fac[m],mod-2);
    for( ll i=m ; i>=1 ; i-- )
        ifac[i-1]=(i*ifac[i])%mod;
}

int main()
{
//    freopen("input.txt","r",stdin);
    scanf("%lld %lld",&n,&m);
    init();
    ll ans=C(n,m)*fac[n]%mod*C(n,m)%mod*fac[n]%mod;
    for( ll i=1 ; i<=n ; i++ ){
        ll val=(C(i,n)*C(i,m)%mod*fac[i]%mod)*(C(n-i,m-i)*C(n-i,m-i)%mod*fac[n-i]%mod*fac[n-i]%mod)%mod;
        if( i%2 )
            ans=(ans+mod-val)%mod;
        else
            ans=(ans+val)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 11520
class Main{
    public static void main(String[] args){
        int s,m,h;
        s = new java.util.Scanner(System.in).nextInt();
        h = s / 3600;
        m = (s % 3600) / 60;
        System.out.println((s / 3600) + ":" + ((s % 3600) / 60)  + ":" + s % 60);
    }
}


Measured memory_bytes: 26248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    string ss = "";
    rep(i, SZ(s)){
        if(s[i] != 'x'){
            ss += s[i];
        }
    }
    string ssr = ss;
    reverse(ALL(ssr));
    if(ss != ssr){
        cout << -1 << endl;
        return 0;
    }
    int xc[100010] = {0};
    int c = 0;
    rep(i, SZ(s)){
        if(s[i] == 'x'){
            xc[c]++;
        }else{
            c++;
        }
    }
    ll ans = 0;
    for(int i = 0; i < SZ(ss)-i; i++){
        ans += abs(xc[i]-xc[SZ(ss)-i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;

struct node{
    int a;
    int b;
}A[N];

int H, n;
int dp[10010];

int main() {
    scanf("%d%d", &H, &n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &A[i].a, &A[i].b);
    for (int i = 1; i <= H; i++) dp[i] = INT_MAX;
    dp[0] = 0;
    for (int i = 0; i <= H; i++) {
        for (int j = 1; j <= n; j++) {
            if (i >= A[j].a) {
                dp[i] = min(dp[i], dp[i-A[j].a] + A[j].b);
            } else {
                dp[i] = min(dp[i], dp[0] + A[j].b);
            }
        }
    }
    cout << dp[H] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<cmath>
#include<tuple>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

vector<pair<int ,int> > v;

struct UF{
    vector<int> d;
    UF(int n):d(n,-1){}
    bool set(int x,int y){
        x=root(x),y=root(y);
        if(x!=y){if(d[y]<d[x])swap(x,y);d[x]+=d[y];d[y]=x;}
        return x!=y;
    }
    bool find(int x,int y){return root(x)==root(y);}
    int root(int x){
        while(d[x]>=0){if(d[d[x]]>=0)d[x]=d[d[x]];x=d[x];}
        return x;
    }
    int size(int x){return -d[root(x)];}
};



int main()
{
	int n,m,ans = 0;
	cin >> n >> m;
	
	
	REP(i,m)
	{
		int a,b;
		cin >> a >> b;
		v.PB(MP(a-1,b-1));
	}
	
	REP(i,m)
	{
		UF uf(n);
		
		REP(k,m)
		{
			if( k != i)
			{
				uf.set(v[k].FI,v[k].SE);
			}
		}
		
		int ju = 0;
		
		REP(k,n)
		{
			if(uf.d[k] < 0)ju++;
		}
		
		if(ju > 1)ans++;
	
	//SHOW1d(uf.d,n);
	
	}
	
	cout << ans << endl;
		
	
	return 0;
}

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

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   int a,b;scanf("%d%d",&a,&b);
   int ab;
   if(b<10)ab = a*10 +b;
   else if(b<100)ab= a*100 +b;
   else  ab = a*1000 +b;
   for(int i = 0;i < 100000;i++){
      if(i*i==ab){
         printf("Yes");
         return 0;
      }
   }
   printf("No");
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<algorithm>

#define N 1000
#define UNDEFINED -1

int n, u, k, v;
int G[N][N];
std::queue<int> Q;
int d[N];

int main() {
    for(int i = 0; i < N; i++) {
        d[i] = UNDEFINED;
        for(int j = 0; j < N; j++) {
            G[i][j] = 0;
        }
    }

    std::cin >> n;
    for(int i = 0; i < n; i++) {
        std::cin >> u >> k;
        for(int j = 0; j < k; j++) {
            std::cin >> v;
            G[u][v] = 1;
        }
    }

    d[1] = 0;
    Q.push(1);
    while(!Q.empty()) {
        int q = Q.front();
        Q.pop();
        for(int i = 1; i <= n; i++) {
            if(G[q][i] != 0 && d[i] == UNDEFINED){
                d[i] = d[q] + 1;
                Q.push(i);
            }
        }
    }

    for(int i = 1; i <= n; i++) {
        printf("%d %d\n", i, d[i]);
    }

    return 0;
}



Measured memory_bytes: 7120
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
int dp[100010];
int main(){
	int n,q;
	string s;
	cin>>n>>q>>s;
	s=' '+s;
	for(int i=2;i<=n;i++){
		if(s[i]=='C' && s[i-1]=='A')
			dp[i]=dp[i-1]+1;
		else
			dp[i]=dp[i-1];
	}
	for(int i=1;i<=q;i++){
		int l,r;
		cin>>l>>r;
		if(s[l]=='C' && s[l-1]=='A')
			cout<<dp[r]-dp[l-1]-1;
		else
			cout<<dp[r]-dp[l-1];
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1404
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int m,n,i;
	int x[200000],y[200000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
		y[i]=x[i];
	}
	m=n/2;
	sort(y,y+n);
	
	for(i=0;i<n;i++){
		if(x[i]<y[m]) printf("%d\n",y[m]);
		else printf("%d\n",y[m-1]);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;
double pi=3.141592653589793238;
int main() {
  long double a,b,h,m;
  cin>>a>>b>>h>>m;
  ////
  long double aw,bw;
  h=h+m/60;
  aw=h/12*2*pi;
  bw=m/60*2*pi;
  long double ans;
  ans=a*a+b*b-2*a*b*cos(bw-aw);
  ans=pow(ans,0.5);
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
}

Measured memory_bytes: 4164
n = int(input())
a = list(map(int, input().split()))
B, SUM = [], 0

for i in range(n):
    SUM += a[i]-i-1
    B.append(a[i]-i-1)

Bs = sorted(B)
if n%2 == 1:
    b = Bs[n//2]
else:
    b = (Bs[n//2-1]+Bs[n//2])//2
ans = 0
for i in B:
    ans += abs(i-b)
print(ans)

Measured memory_bytes: 26020
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int A,B,C;
	ll X,Y;
	ll sum = 0;
	cin >> A >> B >> C >> X >> Y;
	while(X != 0 || Y != 0){
		if (X > 0 && Y > 0){
			sum += min(A+ B,2*C);
			X--;
			Y--;
		}
		else if(X > 0){
			sum += min(A,2*C);
			X--;
		}
		else{
			sum += min(B,2*C);
			Y--;
		}
	}
	cout << sum <<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		int i;
		int j;
		int temp;
		int first;
		int second;
		int third;

		int[] mountain = new int[10];

		Scanner sc = new Scanner(System.in);

		for(i = 0; i <10; i++) {

		mountain[i] = sc.nextInt();

		}

		for(i = 0; i <10; i++) {

			for(j = 0; j < 10; j++) {
				if( mountain[i] < mountain[j]) {


					temp = mountain[i];
					mountain[i] = mountain[j];
					mountain[j] = temp;
				}
			}
		}
		first = mountain[0];
		second = mountain[1];
		third = mountain[2];

		for(i = 9; i > 6; i--) {
		System.out.printf("%d",mountain[i] );
		System.out.println("");


		}

	}
}

Measured memory_bytes: 26372
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

//0-index 抽象化半開区間セグツリー verified AOJ DSL_2_AB
template<typename T, typename E>
class segment_tree{
    typedef function<T(T,T)> F;
    typedef function<T(T,E)> G;
private:
    int num_of_elm_;
    vector<T> dat_;
    F f_;
    G g_;
    T ident_;
public:
    segment_tree(int n, F f, G g, T ident):f_(f), g_(g), ident_(ident){
        num_of_elm_ = 1;
        while(num_of_elm_<n)num_of_elm_*=2;
        dat_.resize(2*num_of_elm_,ident);
    }

    void update(int pos,T val){
        int p = num_of_elm_ + pos;
        dat_[p] = g_(dat_[p],val);
        while(p!=1){
            p/=2;
            dat_[p] = f_(dat_[p*2], dat_[p*2+1]);
        }
    }

    T query(int L, int R,int l=0,int r=0, int k=1){
        if(k==1)r = num_of_elm_;
        if(r<=L || R<=l)return ident_;
        else if(L<=l && r<=R){
            return dat_[k];
        }
        else{
            return f_(query(L,R,l,(l+r)/2,k*2), query(L,R,(l+r)/2,r,k*2+1));
        }
    }
};


int main(){
    int n,q;
    cin>>n>>q;
    auto  f = [](int a, int b){ return min(a,b); };
    auto  g = [](int a, int b){ return b; };
    segment_tree<int,int> st(n,f,g,(1LL<<31)-1);

    rep(i,q){
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0){
            st.update(x,y);
        }else{
            cout<<st.query(x,y+1)<<endl;
        }

    }
}





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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);

const int N = 2e2 + 105;
const int M = 2e5 + 105;

#define FILENAME ""

int n;
int m;

ll dp[M][N];
int c[N], w[N];

void fdp() {
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			dp[i][j] = max (dp[i][j - 1], ((i >= w[j]) ? dp[i - w[j]][j - 1] + c[j] : 0));
		}
	}
}

int main()
{
	ios::sync_with_stdio(0);
    cin.tie(NULL);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> w[i + 1] >> c[i + 1];
	}
	fdp();
	cout << dp[m][n];
	re 0;
}     

Measured memory_bytes: 239872
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<double,int> P;
typedef pair<ll,P> Pp;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
int n;
vector<P> dist[1010];
double cost[1010];
int done[1010];

double dijkstra(int start,int goal) {
    rep(i,n+2) {
        cost[i]=INF;
        done[i]=0;
    }
    cost[start]=0;
    done[start]=1;
    priority_queue<P> pq;
    pq.push(P(0,start));
    while (!pq.empty()) {
        double first = pq.top().first;
        int second = pq.top().second;
        pq.pop();
        done[second]=2;

        for (int i=0;i<dist[second].size();i++) {
            int v = dist[second][i].second;
            if (done[v]==2) continue;

            if (cost[v]>cost[second]+dist[second][i].first) {
                cost[v]=cost[second]+dist[second][i].first;
                pq.push(P(cost[v]*(-1),v));
                done[v]=1;
            }
        }
    }
    return cost[goal];
}

ll x[1010],y[1010],r[1010];

class ECosmicRays {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        ll a,b,c,d;
        cin>>a>>b>>c>>d>>n;
        x[0]=a;x[1]=c;y[0]=b;y[1]=d;r[0]=0;r[1]=0;
        rep(i,n) {
            cin>>x[i+2]>>y[i+2]>>r[i+2];
        }
        rep(i,n+2) {
            rep(j,n+2) {
                if (i!=j) {
//                    cout << i << " " << j << " ";
//                    if (j == n + 1) cout << endl;
                    dist[i].emplace_back(P(max(0.0, (double) (
                            (double) sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) -
                            (double) (r[i] + r[j]))), j));
                }
            }
        }
//        rep(i,n+2) {
//            rep(j,n+1) {
//                cout<<"("<<dist[i][j].first<<","<<dist[i][j].second<<")";
//                if (j==n) cout<<endl;
//            }
//        }
        cout << fixed << setprecision(10) << dijkstra(0,1) << endl;
    }
};


int main() {
	ECosmicRays solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 22640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

const int INF=1000000000;

class Schedule{
public:
    int idx;
    vector<bool> sch;
    Schedule(){
        idx=0;
    }
    void proceed(){
        idx=(idx+1)%sch.size();
    }
    bool currentSit(){
        return sch[idx];
    }
};

int main(){

    int n,duration;
    while(cin>>n>>duration&&!(n==0&&duration==0)){
        Schedule schedules[101];
        for(int i = 0; i < n; i++){
            int m;
            for(int j = 0; ; j++){
                int a,b;
                cin>>a;
                if(a==0)
                    break;
                for(int k = 0; k < a; k++)
                    schedules[i].sch.push_back(true);
                cin>>b;
                for(int k = 0; k < b; k++)
                    schedules[i].sch.push_back(false);
            }
        }
        int idxs[101];
        bool swh[101];
        memset(idxs,0,sizeof(idxs));
        memset(swh,0,sizeof(swh));
        // Ò¿L[
        queue<int> wait;
        bool isConsuming[201];
        // falseÈç»ÝÒ¿L[ÉüÁÄ¢È¢
        memset(isConsuming,0,sizeof(isConsuming));
        // Ôðißé
        int sumTime=0;
        for(int i = 0; i < duration; i++){
            for(int j = 0; j < n; j++){
                // Ò¿sñÉüÁÄ¢éàÌÍð³êéÜÅÀs³êÈ¢
                if(isConsuming[j])continue;
                // »ê¼êÔðißé
                // Ò¿óÔÉüêé
                if(!schedules[j].currentSit()){
                    wait.push(j);
                    isConsuming[j]=true;
                }
                else{
                    // Ôðißé
                    schedules[j].proceed();
                }
            }
            if(wait.size()>=2)
                sumTime+=wait.size()-1;
            // Ò¿sñÉüÁÄ¢éàÌÌÅàÁÆàæªÌàÌÌÔðißé
            if(wait.size()){
                int node=wait.front();
                schedules[node].proceed();
                // óÔªÏíÁ½çðµAqueue©ço·
                if(schedules[node].currentSit()){
                    isConsuming[node]=false;
                    wait.pop();
                }
            }
        }
        cout<<sumTime<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> F(2e5);
  F[0]=0;F[1]=1;
  for(int i=2;i<2e5+1;i++){
    F[i]=(F[i-1]+F[i-2])%1000000007;
  }
  int n, m;
  cin >> n >> m;
  vector<int> a(m+1,-1);
  long long ans=1;
  for(int i=1;i<=m;i++){
    cin >> a[i];
    ans=(ans*F[a[i]-a[i-1]-1])%1000000007;
  }
  ans=(ans*F[n-a[m]])%1000000007;
  cout << ans << endl;
}

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

#define  int long long

using namespace std;

int sum(int n, int m, vector<int> x, vector<int> y, vector<int> z) {
  vector<int> t;
  for(int i=0;i<n;i++) {
    t.push_back(x[i]+y[i]+z[i]);
  }
  sort(t.begin(), t.end(), greater<int>());
  int sum = 0;
  for(int i=0;i<m;i++) {
    sum += t[i];
  }
  return sum;
}

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> x, y, z, xminus, yminus, zminus;
  for(int i=0;i<n;i++) {
    int p, q, r;
    cin >> p >> q >> r;
    x.push_back(p);
    xminus.push_back(-p);
    y.push_back(q);
    yminus.push_back(-q);
    z.push_back(r);
    zminus.push_back(-r);
  }

  int result = 0;

  //+++
  result = sum (n, m, x, y, z);
  //++-
  result = max(result, sum (n, m, x, y, zminus));
  //+-+
  result = max(result, sum (n, m, x, yminus, z));
  //+--
  result = max(result, sum (n, m, x, yminus, zminus));
  //-++
  result = max(result, sum (n, m, xminus, y, z));
  //-+-
  result = max(result, sum (n, m, xminus, y, zminus));
  //--+
  result = max(result, sum (n, m, xminus, yminus, z));
  //---
  result = max(result, sum (n, m, xminus, yminus, zminus));
  
  cout << result << endl;
  
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

int t1, t2, a1, a2, b1, b2;
void input() {
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;
  ;
  ;
}
void solve() {
  int p = (a1 - b1) * t1;
  int q = (a2 - b2) * t2;

  if (p > 0) {
    p *= -1;
    q *= -1;
  }

  if (p + q < 0) {
    cout << 0 << endl;
  } else if (p + q == 0) {
    cout << "infinity" << endl;
  } else {
    int s = -p / (p + q);
    int t = (-p) % (p + q);
    if (t != 0) {
      cout << (s * 2 + 1) << endl;
    } else {
      cout << (s * 2) << endl;
    }
  };
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main()
{
    int n; cin>>n;
    vector<long> a(n);
    long s=0;
    for(auto& e: a) { cin>>e; s+=e; }

    auto m=n*(n+1L)/2;
    if (s%m>0) return cout<<"NO"<<endl, 0;

    int k=s/m;
    int t=0;
    for(int i=0; i<n; ++i) {
        auto e=a[(i+1)%n]-a[i]-k;
        if (e%n!=0 or e>0) return cout<<"NO"<<endl, 0;
        t+=-e/n;
    }
    cout<<(t==k ? "YES" : "NO")<<endl;
}


Measured memory_bytes: 1024
n, k, q = map(int, input().split())
p = [0 for _ in range(n)]
for _ in range(q):
  c = int(input()) - 1
  p[c] += 1
for i in range(n):
  if k - q + p[i] > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 4604
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		int cnt = 0;
		for(int i = 100; i >= 1; i--) {
			if(A % i == 0 && B % i == 0 && A >= i && B >= i) {
				cnt++;
				if(cnt >= K) {
					System.out.println(i);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#define MAX 100001
int altura[MAX], custoMinimo[MAX];
int custo(int n)
{
    if(custoMinimo[n] != -1)
        return custoMinimo[n];
    return custoMinimo[n] = std::min(custo(n - 1) + std::abs(altura[n] - altura[n - 1]),
        custo(n - 2) + std::abs(altura[n] - altura[n - 2]));
}
int main()
{
    int n;
    std::ios::sync_with_stdio(false);
    std::cin >> n;
    for(int i = 1; i <= n; i++)
    {
        custoMinimo[i] = -1;
        std::cin >> altura[i];
    }
    custoMinimo[1] = 0;
    custoMinimo[2] = std::abs(altura[2] - altura[1]);
    std::cout << custo(n) << '\n';
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<climits>
using namespace std;

#define ll long long
#define tc                int T;cin>>T;while(T--)
int a[100000];
int main()
{
	int n, c, b, k ; cin >> n >> k;
	for (int& e : a)cin >> e;
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int e = i + 1; e <= i + k; ++e) {
			if (e < n)
				if ((dp[i] + abs(a[e] - a[i])) < dp[e])
					dp[e] = dp[i] + abs(a[e] - a[i]);
		}
	}
	cout << dp[n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int i;

int main() {
  scanf("%d", &i);
  printf("%d\n", 24 - i + 24);

  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int sum = 0;
		int N = scan.nextInt();
		int K = scan.nextInt();
		int[] l = new int[N];
		for(int i = 0; i < N; i++) {
			l[i] = scan.nextInt();
		}
		Arrays.sort(l);
		for(int i = 0; i < K; i++) {
			sum += l[N - 1 - i];
		}
		System.out.println(sum);
		scan.close();

	}

}


Measured memory_bytes: 27072
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll X, i = 0;
  cin >> X;
  while(1) {
    if(400 + 200 * i > X) {
      cout << 9 - i << endl;
      break;
    }
    i++;
  }
}

Measured memory_bytes: 3616
#import sys
#import math
import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
a,b,c=map(int,input().split())
count=c
for i in range(10):
  count=a*count-b
  print(count)

Measured memory_bytes: 12400