akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

#define int long long




signed main(){
  
    ios::sync_with_stdio(false);
    cin.tie(0);
	//cin高速化


    
    int a,b;
    cin>>a>>b;

    int ans=1;
    int hoge=2;
    int tmp=1;
    while(1){
        a=2*a;
        // cout<<a<<endl;


        if(a>b)break;


        ans++;



       
    }
    cout<<ans<<endl;




}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 100000000000000
int main() {
	int x[2], y[2];
	REP(i, 2) {
		cin >> x[i] >> y[i];
	}
	string ans;
	REP(i, x[1] - x[0]) {
		ans.push_back('R');
	}
	REP(i, y[1] - y[0]) {
		ans.push_back('U');
	}
	ans.push_back('R');
	REP(i,1+y[1] - y[0]) {
		ans.push_back('D');
	}
	REP(i, x[1] - x[0] + 1) {
		ans.push_back('L');
	}
	ans.push_back('U');
	REP(i, y[1] - y[0]) ans.push_back('U');
	REP(i, x[1] - x[0])ans.push_back('R');
	ans.push_back('U');
	REP(i, x[1] - x[0] + 1) ans.push_back('L');
	REP(i, y[1] - y[0] + 1) ans.push_back('D');
	ans.push_back('R');
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
#include<numeric>
#include<set>
#include<iterator>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
#define ll long long 
int main(){
    int n;
    cin>>n;
    vector<int>p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=1;i<=n-2;i++){
        if(p[i]>p[i-1]&&p[i]<p[i+1]){
            ans++;
        }
        if(p[i]>p[i+1]&&p[i]<p[i-1]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
b = 0
w = s.count(".")
l = [w]
for i in range(1, n + 1):
    if s[i - 1] == "#":
        b += 1
    if s[i - 1] == ".":
        w -= 1
    l.append(b + w)
    # print(l)
print(min(l))


Measured memory_bytes: 11264
#include<stdio.h>
int teto(int,int,int);
int teto2(int,int);
int n,a[500005];
int n1,count=0,i,k,j,n2,L[500005],R[500005];

int main(void){
  int i,left,right;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  left=0;
  right=n;
  teto2(left,right);
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}

teto(int left,int mid,int right){
  n1=mid-left;
  n2=right-mid;
  for (i=0;i<n1;i++){
    L[i]=a[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
  }
  L[n1]=1000000001;
  R[n2]=1000000001;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      count++;
      a[k]=L[i];
      i=i+1;
    }
    else{
      count++;
      a[k]=R[j];
      j=j+1;
    }
  }
}

teto2(int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    teto2(left,mid);
    teto2(mid,right);
    teto(left,mid,right);
  }
}

Measured memory_bytes: 5488
import math
n=int(input())
A=[int(input()) for i in range(n)]

def insertion_sort(ar,num,g):
    count=0
    for i in range(g,num):
        v=ar[i]
        j=i-g
        while j>=0 and ar[j]>v:
            ar[j+g]=ar[j]
            j=j-g
            count+=1
        ar[j+g]=v
    return count

def shell_sort(AR,num):
    count=0
    m = math.floor(math.log(2 * n + 1) / math.log(3))
    print(m)
    G = [0 for i in range(m)]   
    G[0] = 1
    for i in range(1, m):
        G[i] = 3 * G[i - 1] + 1
    G.reverse()
    print(*G)
   
    for i in range(m):
        count+= insertion_sort(A, n, G[i])
    print(count)


shell_sort(A,n)
for i in A:
        print(i)
    

Measured memory_bytes: 47524
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B;cin>>A>>B;
  
  if(A<6){
    cout<<0<<endl;
  }
  else if(6<=A&&A<13){
    cout<<B/2<<endl;
  }
  else{
    cout<<B<<endl;
  }
}

Measured memory_bytes: 3504
n=int(input())
a=[0]*n
b=[0]*n
c=[]
for i in range(n):
	a[i],b[i]=map(int,input().split())
	c.append((a[i]+b[i],i))
d=sorted(c,reverse=True)
ta=0
ao=0
turn=0
for i in range(n):
	if turn==0:
		ta+=a[d[i][1]]
		turn=1
	else:
		ao+=b[d[i][1]]
		turn=0
print(ta-ao)

Measured memory_bytes: 25692
A,B,C = map(int,input().split())

l = [A,B,C]
flg = [A%2,B%2,C%2]
cnt = 0
if flg.count(1) == 1:
    for i in range(3):
        if flg[i] == 0:
            l[i] += 1
    cnt += 1
        
elif flg.count(1) == 2:
    for i in range(3):
        if flg[i] == 1:
            l[i] += 1
    cnt += 1

mx = max(l)
SUM = 0
for i in l:
    SUM += (mx - i)
print(SUM//2+cnt)


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

using namespace std;

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

int findGCD(vector<int> arr) 
{ 
	int n=3;
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
    { 
        result = gcd(arr[i], result); 
  
        if(result == 1) 
        { 
           return 1; 
        } 
    } 
    return result; 
} 

int main()
{
	int n;
	cin>>n;
	long long int sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				vector<int> s;
				s.push_back(i);
				s.push_back(j);
				s.push_back(k);
				sum = sum + findGCD(s);
			}
		}
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<stdio.h>
#include<vector>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#include<set>
#define ws " "
#define nl "\n"
#define tc ll test; cin>>test; while(test--)
#define f(i, a, b) for(ll i = a; i<b; i++)
using namespace std;

#define pid pair<int, double>
bool compare(pid a, pid b)
{
	//for descending order replace with a.roll >b.roll
    //if(a.second==b.second)


    if(a.second > b.second)
        return 1;
	else
		return 0;
}

struct monster{

double a, b, prof;
int ind;

};

bool compa(monster a, monster b)
{
	//for descending order replace with a.roll >b.roll
    //if(a.second==b.second)


    if(a.prof > b.prof)
        return 1;
	else
		return 0;
}



bool com(monster a, monster b)
{
	//for descending order replace with a.roll >b.roll
    //if(a.second==b.second)


    if(a.ind < b.ind)
        return 1;
	else
		return 0;
}


void solve()
{

    int n;
    string s;
    cin>>n;
    cin>>s;
    if(s.size()<=n)
    {
        cout<<s<<nl;
        return;
    }
    else
    {
        int i = 0;
        while(i<n)
        {
            cout<<s[i];
            i++;
        }

        cout<<"..."<<nl;

    }

}



int main()
{
    //tc
    solve();
}



/*
    map <int, int> mp;

    comp arr[100001] = {0};

    vector< pair<int, int> > v(n);
    f(i, 0, n)
    cin>>v[i].first;

    f(i, 0, n)
    {
        cin>>v[i].second;
        if(v[i].second==1)
        comp[v[i].first].oCount++;
        else
        comp[v[i].second].zCount++;
 //       mp[v[i].first]++;
    }

    int scarcity;
    f(i, 0, 100001)
    {
        if(comp[i].oCount==0&&comp[i].zCount==0)
            continue;
        if(abs(comp[i].oCount-comp[i].zCount)==1)
        {
            if(scarcity==9)
            {
                if(comp[i].oCount>comp[i].zCount)
                scarcity = 0;
                else if scarcity = 1;
              continue;
            }
            if(comp[i].oCount>comp[i].zCount)
                temp = 0;
            else if temp = 1;

            if(temp==scarcity)
            {
                cout<<"no"<<nl;
                return;
            }
            else scarcity = temp;

            if(prev==0)
                stk.push(scarcity);

            else if(prev==1)
            prev = 1;

        }
        else if(comp[i].oCount=comp[i].zCount)
        {
           // if(prev == 9)
                prev = 0;

        }


    }



*/


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int H, W; cin >> H >> W;

    ll ans = 2e9;

    // 行に三分割する場合
    if (H > 2) {
        if (H % 3 == 0) {
            cout << 0 << endl;
            return 0;
        } else {
            ans = min(ans, ll(W));
        }
    }

    // 列に三分割する場合
    if (W > 2) {
        if (W % 3 == 0) {
            cout << 0 << endl;
            return 0;
        } else {
            ans = min(ans, ll(H));
        }
    }

    // 行を二分割し、大きい方を二分割する場合
    repr (i, 1, H/2+1) {
        ll lower_h = H - i;
        ll max_s = max({i*ll(W), lower_h*(W/2), lower_h*(W-W/2)});
        ll min_s = min({i*ll(W), lower_h*(W/2), lower_h*(W-W/2)});
        ans = min(ans, max_s-min_s);
    }

    repr (j, 1, W/2+1) {
        ll right_w = W - j;
        ll max_s = max({j*ll(H), right_w*(H/2), right_w*(H-H/2)});
        ll min_s = min({j*ll(H), right_w*(H/2), right_w*(H-H/2)});
        ans = min(ans, max_s-min_s);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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(){
	ll n,y;
	cin >> n >> y;
	y /= 1000;
	int flag = 0;
	ll a,b,c;
	for(ll i = 0; i <= 2000; i++) {
		for(ll j = 0; j <= 2000; j++) {
			if(9 * i + 4 * j == y - n){
				flag = 1;
				a = i;
				b = j;
				break;
			}
		}
	}
	if (flag == 1){
		c = n - a - b;
		if (c >= 0){
			cout << a << " " << b << " " << c << endl;
		}
		else{
			cout <<"-1 -1 -1"<< endl;
		}
	}
	else{
		cout <<"-1 -1 -1"<< endl;
	}
	return 0;
}

Measured memory_bytes: 256
for i in range(20):
    n=int(input())
    if n==0:break
    
    x=[]
    for j in range(n):
        a=int(input())
        x.append(a)
        
    for k in range(10):
        y=x.count(k)
        
        if y==0:
            print('-')
        else:
            print('*'*y)


Measured memory_bytes: 5704
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    int a;
	cin >> a;

	string str, str2;

	cin >> str;

	int cnt = 0, pos = 0;
	int i;
	for (i = pos; i <= a-1; i++) {
		int j;
		for (j = i+1; j < a; j++) {
			if (str[i] != str[j]) {
				cnt++;
				break;
			} 
		}
		pos = j;
		i = pos-1;
	}

	cnt++;

	cout << cnt << endl;

}

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

int main(){
	int n;
	cin >> n;
	n%=10;
	if(n == 2||n==4||n==5||n==7||n==9){
		cout << "hon" << endl;
	}else if(n==0|| n==1 || n == 6||n==8){
		cout << "pon" << endl;
	}
	else{
		cout << "bon" << endl;
	}

	return 0;
}




Measured memory_bytes: 3512
#include<iostream>
#include<cstdio>
using namespace std;
int ans,cov[222222],n,m,x,y,a[222222],cnt[222222],pos;
int main()
{
	scanf("%d%d",&n,&m);
	ans=n;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	for (int i=1;i<=n;i++)
	{
		pos=i-cnt[i]+1;
		if (pos<=0) pos=1;
		for (int j=pos;j<=i;j++)
		{
			if (!cov[j])
			{
				ans--;
			}
			cov[j]++;
		}
	}
	while(m--)
	{
		scanf("%d%d",&x,&y);
		pos=a[x]-cnt[a[x]]+1;
		if (pos>0)
		{
			cov[pos]--;
			if (!cov[pos]) ans++;
		}
		cnt[a[x]]--;
		a[x]=y;
		cnt[a[x]]++;
		pos=a[x]-cnt[a[x]]+1;
		if (pos>0)
		{
			if (!cov[pos]) ans--;
			cov[pos]++;
		}
		printf("%d\n",ans);
	}
	return 0;
} 

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int dp[1001][1001];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s1,s2;
  cin >> s1 >> s2;
//   reverse(all(s2));
  rep(i,s1.size()+1){
    dp[i][0] = i;
  }
  rep(j,s2.size()+1){
    dp[0][j] = j;
  }
  REP(i,1,s1.size()+1){
    REP(j,1,s2.size()+1){
      if(s1[i-1] == s2[j-1]){
        dp[i][j] = min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+0));
      }
      else{
        dp[i][j] = min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+1));
      }
    }
  }
  cout << dp[s1.size()][s2.size()]<<endl;
  return 0;
}

Measured memory_bytes: 7076
def main():
    input()
    x, y = [list(map(int, input().split())) for _ in range(2)]
    for p in (1, 2, 3):
        distance = (sum(map(lambda i: i ** p, [abs(xi - yi) for xi, yi, in zip(x, y)]))) ** (1/p)
        print('{:.5f}'.format(distance))
    distance = max([abs(xi - yi) for xi, yi in zip(x, y)])
    print('{:.5f}'.format(distance))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5652
#include <bits/stdc++.h>
#define ll long long int
#define Fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

int main() {
    Fast
    
    string a,b; cin>>a>>b;
    int m=a.size(), n=b.size();
    int dp[m+1][n+1];
    for(int i=0; i<=m; i++) dp[i][0]=0;
    for(int i=0; i<=n; i++) dp[0][i]=0;
 
    for(int i=1; i<=m; i++) {
        for(int j=1; j<=n; j++) {
            if(a[i-1]==b[j-1]) {dp[i][j]=1+dp[i-1][j-1];}
            else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
        }
    }

    string ans="";
    int i=m, j=n;
    while(i>0 && j>0) {
        if(a[i-1]==b[j-1]) {ans+=a[i-1]; i--; j--;}
        else {
            if(dp[i-1][j]>dp[i][j-1]) i--;
            else j--;
        }
    }

    reverse(ans.begin(), ans.end());
    cout<<ans;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);
	ll ans = 0;
	for (ll i = 1; i * i <= g; i++){
		if (g % i == 0){
			if (IsPrime(i)){
				ans++;
			}
			if (i * i != g){
				if (IsPrime(g / i)){
					ans++;
				}
			}
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n;
    cin>>n;
    int s = 0, mn = INF;
    for(int i = 0; i < n; i++){
        int x;
        cin>>x;
        if(x%10!=0)mn=min(mn, x);
        s+=x;
    }   
    if(s%10==0)s-=mn;
    if(s%10==0)cout<<0;
    else cout<<s;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		int d = ni();
		long g = nl() / 100;
		int[][] a = nia(d, 2);
		long[] dp = new long[1001];
		for (int i = 0; i < d; i++) {
			for (int k = 1000; k >= 1; k--) {
				for (int j = 1; j <= a[i][0] && j <= k; j++) {
					int inc = (j < a[i][0] ? 0 : a[i][1] / 100) + (i + 1) * j;
					dp[k] = Math.max(dp[k], dp[k - j] + inc);
				}
			}
		}
		for (int i = 1; i <= 1000; i++)
			if (dp[i] >= g) {
				out.println(i);
				break;
			}
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	int[][] nia(int n, int m) throws IOException {
		int[][] res = new int[n][];
		for (int i = 0; i < n; i++) {
			res[i] = nia(m);
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 24020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;

public class Main { // Template for CF
    public static class ListComparator implements Comparator<List<Integer>> {

        @Override
        public int compare(List<Integer> l1, List<Integer> l2) {
            for (int i = 0; i < l1.size(); ++i) {
                if (l1.get(i).compareTo(l2.get(i)) != 0) {
                    return l1.get(i).compareTo(l2.get(i));
                }
            }
            return 0;
        }
    }

    public static void main(String[] args) throws IOException {
        // Check for int overflow!!!!
        // Should you use a long to store the sum or smthn?
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int N = Integer.parseInt(f.readLine());
        StringTokenizer st = new StringTokenizer(f.readLine());
        long lcm = 1;
        long denom = 0;
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            long a = Integer.parseInt(st.nextToken());
            lcm = lcm(a, lcm);
            list.add(a);
        }
        for (int i = 0; i < N; i++) {
            denom += lcm / list.get(i);
        }
        double ans = (double) lcm / (double) denom;
        out.println(ans);
        out.close();
    }

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

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

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    int n; cin>>n; P a[n],b[n];
    for (int i = 0; i < n; i++)cin>>a[i].first>>a[i].second;
    for (int i = 0; i < n; i++)cin>>b[i].first>>b[i].second;
    sort(b,b+n); int ans=0; bool used[n]={};
    for (int i = 0; i < n; i++){
        P key=P(-1,-1);
        for (int j = 0; j < n; j++){
            if(b[i].first>a[j].first&&b[i].second>a[j].second&&!used[j]){
                if(key.first<a[j].second)key=P(a[j].second,j);
            }
        }
        if(key.second!=-1){
            ans++; used[key.second]=true;
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int m=1e9+7;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<s.size();++i){
    	if(s[i]!=t[i]) ++cnt;
    }
    cout<<cnt;
	return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi l(n);
	REP(i,n) cin>>l[i];
	sort(ALL(l));
	
	vi check(n,0);
	llong ans=0;
	REP(i,n-1)for(int j=i+2;j<n;++j){
		auto itr=lower_bound(l.begin()+i+1,l.begin()+j,l[i]+l[j]);
		auto itr2=upper_bound(l.begin()+i+1,l.begin()+j,abs(l[i]-l[j]));
		int p=itr-l.begin();
		int p2=itr2-l.begin();
		int num=itr-itr2;
		if(num>0){
			ans+=num;
			check[i]=1;
		}
	}
	
	cout<<ans<<endl;
}//reply.


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

public class Main {

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

        final int n = sc.nextInt();

        final int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }

        Arrays.sort(d);

        System.out.println(d[n/2] - d[n/2-1]);
    }
}


Measured memory_bytes: 50296
#include<stdio.h>
int main(void)
{
	int x[2],n,a[2][2],i,k;
	scanf("%d",&n);
	for(i=0;i<2;i++)	scanf("%d %d",&a[i][0],&a[i][1]);
//for(i=0;i<2;i++) printf("%d %d\n",a[i][0],a[i][1]);
	for(i=0;i<2;i++){
		for(k=1;k<=n;k++){
			if(k*a[i][0]>=n){
				x[i]=k*a[i][1];
				break;
			}
		}
	}
//printf("aaa\n");
	if(x[0]<x[1]) printf("%d\n",x[0]);
	else printf("%d\n",x[1]);
	return 0;
}


Measured memory_bytes: 2756
n=gets.to_i
T=gets.split(" ")
h=gets.split(" ")
ans=0
nums=[]
n.times do |i|
nums[i]=(T[1].to_i-(T[0].to_i-h[i].to_i*0.006)).abs
end
n.times do |i|
if nums[i]==nums.min then
ans=i
break
end
end
puts  ans+1

Measured memory_bytes: 1788
#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 5001;

vector<vi> C(MAXN, vi());

bool mark[MAXN] = {0};

vl B;
ll old = 0;
ll oldcyc = 0;

vi K;

bool nope = 0;
void dfs(ll i){
    mark[i] = 1;
    if(!nope)B[sz(B)-1]++;
    trav(j,C[i]){
        if(!mark[j])dfs(j);
    }
}

ll NP[MAXN] = {0};

ll SS[MAXN] = {0};


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

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

    ll a,b,c,d,e;

    cin >> n;
    k = 0;
    rep(c1,0,n){
        cin >> a;
        if(a == -1){
            k++;
            K.push_back(c1);
        }
        else{
            a--;
            C[a].push_back(c1);
            C[c1].push_back(a);
        }
    }

    trav(i, K){
        B.push_back(0);
        dfs(i);
    }

    ll t = 1;

    rep(c1,0,n){
        old += (mark[c1] == 0);
        NP[c1] = t;
        t *= (n-1);
        t %= big;
    }

    nope=1;
    rep(c1,0,n){
        if(!mark[c1]){
            oldcyc++;
            dfs(c1);
        }
    }

    ll a1 = 1;
    rep(c1,0,k){
        a1 *= (n-1);
        a1 %= big;
    }
    a1 *= (n - oldcyc);
    a1 %= big;

    m = sz(B);

    ll a2 = 0;
    SS[0] = 1;
    rep(c1,0,k){
        for(ll c2 = k; c2 >= 1; c2--){
            SS[c2] += B[c1]*SS[c2-1];
            SS[c2] %= big;
        }
    }

    t = 1;
    rep(c1,1,k+1){
        ll lst = NP[k-c1];
        ll mid = SS[c1];
        if(c1 == 1){
            mid -= k;
        }

        a2 += ((lst*mid)%big)*t;
        a2 %= big;

        t *= c1;
        t %= big;
    }

    cerr << a1 << " " << a2 << "\n";

    cout << (a1+big-a2)%big << "\n";

    return 0;
}


Measured memory_bytes: 4072
from collections import deque

def main():
    N,M = map(int, input().split())
    r = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        r[a-1].append(b-1)
        r[b-1].append(a-1)

    p=[-1]*N
    q=deque([0])
    while q:
        i=q.popleft()
        for j in r[i]:
            if p[j] == -1:
                p[j] = i
                q.append(j)
    print('Yes')
    for i in range(1,N):
        print(p[i]+1)

main()

Measured memory_bytes: 34024
n = int(input())
adj = [[] for _ in range(n)]
adj_dict = dict()

for i in range(n - 1):
    a, b = [int(x) - 1 for x in input().split()]
    adj[a].append(b)
    adj[b].append(a)
    if a > b:
        adj_dict[(b, a)] = i
    else:
        adj_dict[(a, b)] = i

m = int(input())
uv = []
for _ in range(m):
    uv.append([int(x) - 1 for x in input().split()])

def dfs(p, v, dest):
    if v == dest:
        return [v]
    if p != -1 and len(adj[v]) == 1:
        return False
    for nv in adj[v]:
        if nv == p:
            continue
        ret = dfs(v, nv, dest)
        if ret:
            return ret + [v]
    return False

edgest = [0] * (2 ** m)
for i, (u, v) in enumerate(uv):
    ret = dfs(-1, u, v)
    for uu, vv in zip(ret, ret[1:]):
        if uu > vv:
            uu, vv = vv, uu
        if (uu, vv) in adj_dict:
            edgest[1 << i] |= (1 << adj_dict[(uu, vv)])

for i in range(1, 2 ** m):
    lsb = i & (-i)
    edgest[i] = edgest[i ^ lsb] | edgest[lsb]

dp = [0] * (2 ** m)
dp[0] = 1 << (n - 1)
ans = dp[0]
for i in range(1, 2 ** m):
    lsb = i & (-i)
    lim = bin(edgest[i] ^ edgest[i ^ lsb]).count('1')
    dp[i] = dp[i ^ lsb] >> lim
    if bin(i).count('1') % 2 == 0:
        ans += dp[i]
    else:
        ans -= dp[i]
print(ans)


Measured memory_bytes: 86088
#include <stdio.h>
#include <stdlib.h>

#define HASH 9999991

typedef struct List {
	struct List *next;
	char *s;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i, x = 0;
	for (i = 0; s[i] != 0; i++) x = ((x << 5) + s[i] - 'a') % HASH;
	return x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(&(S[i][1]));
		d[i].s = S[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, m, dp[26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 32, HASH);
	for (k = 1, pow[0] = 32; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = l[i] - 2, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (S[i][1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[j] = 0;
		dp[S[i][0] - 'a'] = 1;
		for (j = 1, m = 1; j < l[i]; j++) {
			dp[S[i][j] - 'a'] = 1;
			for (p = hash[h[i]]; p != NULL; p = p->next) {
				if (dp[p->s[0] - 'a'] == 1 && lex_smaller(&(p->s[1]), &(S[i][j+1])) == 0) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (S[i][j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 87508
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadLongArray(N);
            var x = new long[N];

            x[0] = 0L;
            var sign = 1;
            for (int i = 0; i < N; i++)
            {
                x[0] += sign * A[i];
                sign *= -1;
            }
            for (int i = 1; i < N; i++)
            {
                // x[i]/2 + x[i+1]/2 = A[i]
                x[i] = 2 * A[i - 1] - x[i - 1];
            }

            Console.WriteLine(string.Join(" ", x));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 33372
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
int ls[maxn], rs[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &ls[i], &rs[i]);
  }
  return true;
}

set<pair<int, int>> st[2];

long long solve1() {
  int x = 0;
  st[0].clear();
  st[1].clear();
  for (int i = 0; i < n; i++) {
    st[0].insert(make_pair(rs[i], i));
    st[1].insert(make_pair(-ls[i], i));
  }
  int t = 0;
  long long res = 0;
  while (!st[0].empty()) {
    int id = st[t].begin()->second;
    st[0].erase(make_pair(rs[id], id));
    st[1].erase(make_pair(-ls[id], id));
    if (x < ls[id]) {
      res += ls[id] - x;
      x = ls[id];
    } else if (x > rs[id]) {
      res += x - rs[id];
      x = rs[id];
    }
    t ^= 1;
  }
  res += abs(x);
  x = 0;
  return res;
}

void solve() {
  long long res = 0;
  for (int it = 0; it < 2; it++) {
    res = max(res, solve1());
    for (int i = 0; i < n; i++) {
      ls[i] *= -1;
      rs[i] *= -1;
      swap(ls[i], rs[i]);
    }
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll dp[100005][3];
ll n;
ll fun(ll cur,ll a[],ll b[],ll c[],ll prev)
{
    if(cur==n)
        return 0;
    if(dp[cur][prev]!=-1)
        return dp[cur][prev];

    if(prev==0)
    {
        ll a1=b[cur]+fun(cur+1,a,b,c,1);
        ll a2=c[cur]+fun(cur+1,a,b,c,2);
        dp[cur][0]=max(a1,a2);
        return dp[cur][0];

    }
    if(prev==1)
    {
        ll a1=a[cur]+fun(cur+1,a,b,c,0);
        ll a2=c[cur]+fun(cur+1,a,b,c,2);
        dp[cur][1]=max(a1,a2);
        return dp[cur][1];
    }

    ll a1=b[cur]+fun(cur+1,a,b,c,1);
        ll a2=a[cur]+fun(cur+1,a,b,c,0);
        dp[cur][2]=max(a1,a2);
        return dp[cur][2];


}


int main()
{
    run;
    //ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    fr(i,0,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,-1ll,sizeof dp);
    ll ans=0ll;
    fr(i,0,3)
    {
        ans=max(ans,fun(0,a,b,c,i));
    }
    cout<<ans;





}


Measured memory_bytes: 12800
#include<stdio.h>

int main(){
    int s[30];
    int i;
    int n;
    
    for(i=0;i<30;i++){
        s[i]=0;
    }
    
    for(i=0;i<28;i++){
        scanf("%d",&n);
        s[n-1]=1;
    }
    
    for(i=0;i<30;i++){
        if(s[i]==0){
            printf("%d\n",i+1);
        }
    }
    
    return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	int X,A,B;
	cin >> X >> A >> B;
	string s;
	if(A>=B) s="delicious";
	else if(B-A <= X) s="safe";
	else s="dangerous";
	
	cout << s << endl;
	return 0;
}

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

int h,w;
char a[1001][1001];
int dp[1001][1001];
int dfs(int x,int y){
    if(x==h-1 && y== w-1){
        return 1;
    }
    if(dp[x][y]!=-1)return dp[x][y];
    dp[x][y]=0;
    if((x+1)<h && a[x+1][y]=='.'){
        dp[x][y]+=dfs(x+1,y);
        dp[x][y]=dp[x][y]%mod;
    }
    if((y+1)<w && a[x][y+1]=='.'){
        dp[x][y]+=dfs(x,y+1);
        dp[x][y]=dp[x][y]%mod;
    }
    return dp[x][y];
}
void solve()
{
    cin>>h>>w;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    dfs(0,0);
    cout<<dp[0][0];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 8700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000000
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=1e3+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,a[maxn];
ll sum[maxn];
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    int ret=1;
    rep(i,1,n)sum[i]=sum[i-1]+a[i];
    for(i=n-1;i>=1;i--){if(sum[i]*2>=a[i+1])ret++;else break;}
    printf("%d\n",ret);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int N , K;
	cin >> N >> K;
	cout<<min(N%K , K - N%K)<<endl;
}

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

int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("ourpur.txt", "w", stdout);
	#endif
	ll n;
	cin>>n;
	ll a[n],x=1000000000000000000;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			cout<<0;
			return 0;
		}
	}
         long long p=1;
	for(int i=0;i<n;i++)
	{
	       if(a[i]<=x/p)
		{
		        p=p*a[i];
		}
		else
		{
			cout<<-1;
			return 0;
		}
	}
	cout<<p;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int x;
    cin>>x;
    cout<<10-x/200<<endl;
}


Measured memory_bytes: 3648
n = int(input())
d = {}
for i in range(n):
	s = input()
	if s not in d:
		d[s] = 1
	else:
		d[s]+=1

if "AC" not in d:
	d["AC"] = 0
print("AC x {}".format(d["AC"]))
if "WA" not in d:
	d["WA"] = 0
print("WA x {}".format(d["WA"]))
if "TLE" not in d:
	d["TLE"] = 0
print("TLE x {}".format(d["TLE"]))
if "RE" not in d:
	d["RE"] = 0
print("RE x {}".format(d["RE"]))

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


int main() {
  int N;
  int D;
  cin >> N >> D;
  int anser = N / ((D * 2) + 1);
  if (N % ((D * 2) + 1) != 0) anser++;
  cout << anser << endl;
}

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

const int MAX_N = 101;
const int INF = 1e+9;
typedef pair<int,int> P;

int w, h;
// st[y][x] := (x,y) が店舗かどうか
int st[MAX_N][MAX_N];

// 移動6方向のベクトル(偶数列と奇数列で遷移の仕方が異なる)
int dx[2][6] = {  
	{ -1, 0, -1, 1, -1, 0 },
	{  0, 1, -1, 1,  0, 1 }
};
int dy[6] = { -1, -1, 0, 0, 1, 1 };

// BFSのときに利用
int d[MAX_N][MAX_N];
// m[y][x] := (x,y) から最短の店舗までの距離
int m[MAX_N][MAX_N];
// 解
int ans;

void init(){
	for(int y=0 ; y < MAX_N ; y++ ){
		for(int x=0 ; x < MAX_N ; x++ ){
			m[y][x] = st[y][x] = 0;
		}
	}
}

void clear_d(){
	for(int y=0 ; y < MAX_N ; y++ ){
		for(int x=0 ; x < MAX_N ; x++ ){
			d[y][x] = INF;
		}
	}
}

// (sx,sy) から最短の店舗までの距離を求める
void bfs(int sx, int sy){
	queue<P> q;
	clear_d();
	q.push( P(sx,sy) );
	d[sy][sx] = 0;
	
	while( !q.empty() ){
		int px = q.front().first; 
		int py = q.front().second;
		q.pop();
		
		if( st[py][px] == 1 ){
			m[sy][sx] = d[py][px];
			break;
		}
		for(int i=0 ; i < 6 ; i++ ){
			int mx = px + dx[py%2][i];
			int my = py + dy[i];
			if( mx < 0 || my < 0 || mx >= w || my >= h ) continue;
			
			if( d[my][mx] == INF ){
				q.push( P(mx,my) );
				d[my][mx] = d[py][px] + 1;
			}
		}
	}
}

// (sx,sy) からカバーできるブロック数
int solve(int sx, int sy){
	queue<P> q;
	clear_d();
	q.push( P(sx,sy) );
	d[sy][sx] = 0;
	int cnt = 0;
	
	while( !q.empty() ){
		int px = q.front().first; 
		int py = q.front().second;
		q.pop();
		if( d[py][px] < m[py][px] ){
			cnt++;
		}else{
			continue;
		}
		
		for(int i=0 ; i < 6 ; i++ ){
			int mx = px + dx[py%2][i];
			int my = py + dy[i];
			if( mx < 0 || my < 0 || mx >= w || my >= h ) continue;
			
			if( d[my][mx] == INF ){
				q.push( P(mx,my) );
				d[my][mx] = d[py][px] + 1;
			}
		}
	}
	return cnt;
}

int main(){
	while( cin >> w >> h , w || h ){
		init();
		
		int s, t;
		cin >> s;
		for(int i=0 ; i < s ; i++ ){
			int x, y;
			cin >> x >> y;
			x--; y--;
			st[y][x] = 1;
		}
		
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				bfs( x , y );
			}
		}
		
		ans = 0;
		cin >> t;
		for(int i=0 ; i < t ; i++ ){
			int x, y;
			cin >> x >> y;
			x--; y--;
			int cnt = solve( x, y );
			ans = max( ans , cnt );
		}
		cout << ans << endl;
	}
}

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

int main() {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) == '-')
    {
      count--;
    }
    else
    {
      count++;
    }
  }
  cout << count << endl;
}

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

int main(){
  long i,N;
  long long ans=0;
  scanf("%ld",&N);
  for(i=1;i*i+i<N;i++){
    if(N%i==0){
      ans+=N/i-1;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int d;
	int ans;
	
	while (scanf("%d", &d) != EOF){
		ans = 0;
		for (i = d; i <= 600 - d; i += d){
			ans += (i * i) * d;
		}
		printf("%d\n", ans);
	}
	return (0);
}

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

int main(){
	ll n,T;
	cin >> n >> T;
	vector<ll> t(n);
	rep(i,n){
		cin >> t[i];
	}
	ll ans = 0;
	ll now = T;
	rep(i,n){
		if(t[i] > now){
			ans += T;
			now = t[i] + T;
		}else{
			ans += T + t[i] - now;
			now = t[i] + T;
		}
	}
	cout << ans + T << endl;
    return 0;
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		int Price = 700;

		for(int i=0; i<3 ;i++ ) {
			String top = S.substring(i, i+1);
			if(top.equals("o")) {
				Price += 100;
			}
		}
		System.out.println(Price);
	}
}


Measured memory_bytes: 23124
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
vector<int>adj[M];
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    f(i,1,m)
    {
       int u,v;
       cin>>u>>v;
       adj[u].pb(v);
       adj[v].pb(u);
    }
    for(auto x:adj[1])
    {
        if(x!=n)
        {
            for(auto y:adj[x])
            {
                if(y==n)
                {
                    cout<<"POSSIBLE"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;

}





































Measured memory_bytes: 15744